diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 20:34:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 20:34:10 +0000 |
commit | e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc (patch) | |
tree | 68cb5ef9081156392f1dd62a00c6ccc1451b93df /doc/plugins.example/CMakeLists.txt | |
parent | Initial commit. (diff) | |
download | wireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.tar.xz wireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.zip |
Adding upstream version 4.2.2.upstream/4.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'doc/plugins.example/CMakeLists.txt')
-rw-r--r-- | doc/plugins.example/CMakeLists.txt | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/doc/plugins.example/CMakeLists.txt b/doc/plugins.example/CMakeLists.txt new file mode 100644 index 00000000..26e3ad25 --- /dev/null +++ b/doc/plugins.example/CMakeLists.txt @@ -0,0 +1,74 @@ +# CMakeLists.txt +# +# Wireshark - Network traffic analyzer +# By Gerald Combs <gerald@wireshark.org> +# Copyright 1998 Gerald Combs +# +# SPDX-License-Identifier: GPL-2.0-or-later +# + +cmake_minimum_required(VERSION 3.12) +cmake_policy(SET CMP0048 NEW) + +project(Hello VERSION 0.0.1 DESCRIPTION "Wireshark Hello Plugin" LANGUAGES C) + +find_package(Wireshark CONFIG REQUIRED) + +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${Wireshark_INSTALL_PREFIX}" + CACHE PATH "Installation prefix" FORCE + ) +endif() + +if(NOT Wireshark_PLUGINS_ENABLED) + message(WARNING "Wireshark was compiled without support for plugins") +endif() + +# External plugins must define HAVE_SSIZE_T for the plugin toolchain. +include(CheckTypeSize) +check_type_size("ssize_t" SSIZE_T) + +set(CMAKE_C_VISIBILITY_PRESET hidden) +if(CMAKE_COMPILER_IS_GNUCC) + set(CMAKE_C_FLAGS "-Wall -Wextra ${CMAKE_C_FLAGS}") +endif() + +add_compile_definitions( + VERSION=\"${PROJECT_VERSION}\" + $<$<BOOL:${HAVE_SSIZE_T}>:HAVE_SSIZE_T> +) + +add_library(hello MODULE hello.c) +set_target_properties(hello PROPERTIES PREFIX "" DEFINE_SYMBOL "") +target_link_libraries(hello epan) + +# This is the normal installation target to CMAKE_INSTALL_PREFIX. It is relocatable +# using DESTDIR or cmake --install. By default CMAKE_INSTALL_PREFIX should be configured +# correctly for Wireshark's system installation prefix. +install(TARGETS hello + LIBRARY DESTINATION "${Wireshark_PLUGIN_LIBDIR}/epan" NAMELINK_SKIP +) + +# This custom target installs the plugin to the plugin dir in WiresharkConfig.cmake. +# It does not use CMAKE_INSTALL_PREFIX. +add_custom_target(copy_plugin + COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:hello> "${Wireshark_PLUGIN_INSTALL_DIR}/epan" + COMMENT "Installing plugin to: ${Wireshark_PLUGIN_INSTALL_DIR}/epan" +) + +string(TOLOWER "${PROJECT_NAME}-${PROJECT_VERSION}" _pkgname) + +add_custom_target(package_prep + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/${_pkgname} + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/README $<TARGET_FILE:hello> ${CMAKE_BINARY_DIR}/${_pkgname} +) + +add_custom_target(package + COMMAND ${CMAKE_COMMAND} -E tar czf ${CMAKE_BINARY_DIR}/${_pkgname}.tar.gz --format=gnutar -- ${CMAKE_BINARY_DIR}/${_pkgname} +) +add_dependencies(package package_prep) + +add_custom_target(package_zip + COMMAND ${CMAKE_COMMAND} -E tar cf ${CMAKE_BINARY_DIR}/${_pkgname}.zip --format=zip -- ${CMAKE_BINARY_DIR}/${_pkgname} +) +add_dependencies(package_zip package_prep) |