From d0b97a420d557042938ac5d6bf075fcd84df9371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Thu, 23 Aug 2018 22:03:28 +0100 Subject: CMake: Modernize config-file package support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A CMake config-file package provides support for downstreams using CMake and Wireshark libraries to easily configure the libwireshark dependency with: find_package(Wireshark CONFIG [REQUIRED]) target_link_libraries(foo epan) The FindWireshark.cmake file is no longer needed. See cmake-package(7) for more details on CMake's package system. Change-Id: Ie8af1d44417a99dd08d37959f7b2ffca88572ec2 Reviewed-on: https://code.wireshark.org/review/29208 Petri-Dish: João Valverde Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde --- doc/plugins.example/CMakeLists.txt | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) (limited to 'doc/plugins.example') diff --git a/doc/plugins.example/CMakeLists.txt b/doc/plugins.example/CMakeLists.txt index 23a7e8f713..244c22bd4d 100644 --- a/doc/plugins.example/CMakeLists.txt +++ b/doc/plugins.example/CMakeLists.txt @@ -12,25 +12,9 @@ cmake_policy(SET CMP0048 NEW) project(Hello VERSION 0.0.1 DESCRIPTION "Wireshark Hello Plugin" LANGUAGES C) -find_package(PkgConfig REQUIRED) +find_package(Wireshark CONFIG 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 -# Note: If using PKG_CONFIG_PATH the variable needs to be set as exported -# in the execution environment. -pkg_get_variable(WIRESHARK_PLUGIN_DIR wireshark plugindir) - -set(PLUGIN_INSTALL_LIBDIR "${WIRESHARK_PLUGIN_DIR}/epan") - -include(CMakePushCheckState) -include(CheckFunctionExists) - -cmake_push_check_state() -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) +if(NOT Wireshark_PLUGINS_ENABLED) message(FATAL_ERROR "Wireshark was compiled without support for plugins") endif() @@ -39,13 +23,12 @@ if (CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS "-Wall -Wextra ${CMAKE_C_FLAGS}") endif() -add_definitions(-DHAVE_PLUGINS -DVERSION=\"${PROJECT_VERSION}\") +add_definitions(-DVERSION=\"${PROJECT_VERSION}\") add_library(hello MODULE hello.c) set_target_properties(hello PROPERTIES PREFIX "" DEFINE_SYMBOL "") -target_link_libraries(hello ${WIRESHARK_LDFLAGS}) -target_compile_options(hello PUBLIC ${WIRESHARK_CFLAGS}) +target_link_libraries(hello epan) install(TARGETS hello - LIBRARY DESTINATION "${PLUGIN_INSTALL_LIBDIR}" NAMELINK_SKIP + LIBRARY DESTINATION "${Wireshark_PLUGIN_INSTALL_DIR}/epan" NAMELINK_SKIP ) -- cgit v1.2.3