aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2018-08-21 16:49:28 +0100
committerJoão Valverde <j@v6e.pt>2018-08-21 17:55:12 +0000
commit319186125c3aa518cd0e8c042dfe4346157cf058 (patch)
tree22033c27bf5ae8477a8c86f950b7c47798d1055d
parentd99ef1f9fa8d1c2d1ff5e90a8dbd2face1513e4f (diff)
plugins: Fix CMake build example
Fix combination of pkg-config and CMake variables for feature detection. Remove non-system installation option. Just copy it manually for now. Change-Id: Ia80c703c6ec3df0a49f8d56f1bd6da69471c523f Reviewed-on: https://code.wireshark.org/review/29223 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde <j@v6e.pt>
-rw-r--r--doc/plugins.example/CMakeLists.txt27
1 files changed, 12 insertions, 15 deletions
diff --git a/doc/plugins.example/CMakeLists.txt b/doc/plugins.example/CMakeLists.txt
index ec14efa9de..e7a20219e7 100644
--- a/doc/plugins.example/CMakeLists.txt
+++ b/doc/plugins.example/CMakeLists.txt
@@ -12,22 +12,25 @@ cmake_policy(SET CMP0048 NEW)
project(Hello VERSION 0.0.1 DESCRIPTION "Wireshark Hello Plugin" LANGUAGES C)
-option(SYSTEM_INSTALLATION "Install to system plugin directory" ON)
-
find_package(PkgConfig REQUIRED)
pkg_check_modules(WIRESHARK REQUIRED wireshark>=2.5)
+### CMake Bug: Use PKG_CONFIG_PATH instead of CMAKE_PREFIX_PATH
+# https://gitlab.kitware.com/cmake/cmake/issues/15805
+### CMake Bug: If you run into problems please use the "Unix Makefiles" generator.
+### Ninja just wipes the pkg-config variables.
+# https://gitlab.kitware.com/cmake/cmake/issues/17531 (and probably others)
pkg_get_variable(WIRESHARK_VERSION_RELEASE wireshark VERSION_RELEASE)
pkg_get_variable(WIRESHARK_PLUGIN_DIR wireshark plugindir)
+set(PLUGIN_INSTALL_LIBDIR "${WIRESHARK_PLUGIN_DIR}/epan")
+
include(CMakePushCheckState)
-include(CheckSymbolExists)
+include(CheckFunctionExists)
cmake_push_check_state()
-set(CMAKE_REQUIRED_INCLUDES ${WIRESHARK_INCLUDE_DIRS})
-set(CMAKE_REQUIRED_LIBRARIES ${WIRESHARK_LIBRARIES})
-set(CMAKE_REQUIRED_DEFINITIONS -DHAVE_PLUGINS)
-check_symbol_exists("proto_register_plugin" "epan/proto.h" HAVE_PROTO_REGISTER_PLUGIN)
+set(CMAKE_REQUIRED_LIBRARIES ${WIRESHARK_LDFLAGS})
+check_function_exists("proto_register_plugin" HAVE_PROTO_REGISTER_PLUGIN)
cmake_pop_check_state()
if(NOT HAVE_PROTO_REGISTER_PLUGIN)
message(FATAL_ERROR "Wireshark was compiled without support for plugins")
@@ -42,15 +45,9 @@ add_definitions(-DHAVE_PLUGINS -DVERSION=\"${PROJECT_VERSION}\" -DVERSION_RELEAS
add_library(hello MODULE hello.c)
set_target_properties(hello PROPERTIES PREFIX "" DEFINE_SYMBOL "")
-target_link_libraries(hello ${WIRESHARK_LIBRARIES})
+target_link_libraries(hello ${WIRESHARK_LDFLAGS})
target_compile_options(hello PUBLIC ${WIRESHARK_CFLAGS})
-if(SYSTEM_INSTALLATION)
- set(PLUGIN_INSTALL_LIBDIR "${WIRESHARK_PLUGIN_DIR}/epan")
-else()
- set(PLUGIN_INSTALL_LIBDIR "$ENV{HOME}/.local/lib/wireshark/plugins/${WIRESHARK_VERSION_RELEASE}/epan")
-endif()
-
install(TARGETS hello
- LIBRARY DESTINATION ${PLUGIN_INSTALL_LIBDIR} NAMELINK_SKIP
+ LIBRARY DESTINATION "${PLUGIN_INSTALL_LIBDIR}" NAMELINK_SKIP
)