X-Git-Url: http://git.samba.org/?p=metze%2Fwireshark%2Fwip.git;a=blobdiff_plain;f=CMakeLists.txt;h=076735341e40c1d823b26d2a4adec5228070adb3;hp=503e3a5c3ab6822efae1f8e52d77c85a8fd8f77b;hb=dcfb28021e425d2c1e7c1928fa27b56ce6555cfd;hpb=8f6c3ee8e137a19cf8ffac1a0baebe3adc7105ad diff --git a/CMakeLists.txt b/CMakeLists.txt index 503e3a5c3a..076735341e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,6 +174,12 @@ if(NOT CMAKE_INSTALL_RPATH AND NOT (WIN32 OR APPLE)) endif() endif() +if(WIN32) + # Linking with wsetargv.obj enables "wildcard expansion" of + # command-line arguments. + set(WILDCARD_OBJ wsetargv.obj) +endif(WIN32) + # Banner shown at top right of Qt welcome screen. if(DEFINED ENV{WIRESHARK_VERSION_FLAVOR}) set(VERSION_FLAVOR "$ENV{WIRESHARK_VERSION_FLAVOR}") @@ -193,6 +199,7 @@ message(STATUS "V: ${PROJECT_VERSION}, MaV: ${PROJECT_MAJOR_VERSION}, MiV: ${PRO include(UseLemon) include(UseMakePluginReg) include(UseMakeTaps) +include(UseExecutableResources) include(UseAsn2Wrs) # The following snippet has been taken from @@ -251,10 +258,14 @@ if( NOT CMAKE_SYSTEM_NAME STREQUAL "Linux" AND endif() if(APPLE AND EXISTS /usr/local/opt/qt5) - # Homebrew installs Qt5 (up to at least 5.9.1) in - # /usr/local/qt5, ensure it can be found by CMake since - # it is not in the default /usr/local prefix. - list(APPEND CMAKE_PREFIX_PATH "/usr/local/opt/qt5") + # Homebrew installs Qt5 (up to at least 5.11.0) in + # /usr/local/qt5. Ensure that it can be found by CMake + # since it is not in the default /usr/local prefix. + # Add it to PATHS so that it doesn't override the + # CMAKE_PREFIX_PATH environment variable. + # QT_FIND_PACKAGE_OPTIONS should be passed to find_package, + # e.g. find_package(Qt5Core ${QT_FIND_PACKAGE_OPTIONS}) + set (QT_FIND_PACKAGE_OPTIONS PATHS /usr/local/opt/qt5) endif() # Always enable position-independent code when compiling, even for @@ -266,6 +277,13 @@ endif() # This option only has an effect on CMake >= 2.8.9 set(CMAKE_POSITION_INDEPENDENT_CODE ON) +# Path to our generated executables (or wrapper scripts) +if(WIN32) + set(WS_PROGRAM_PATH ./run/$) +else() + set(WS_PROGRAM_PATH ./run) +endif() + if( CMAKE_C_COMPILER_ID MATCHES "MSVC") if ((MSVC_VERSION LESS "1900") OR (MSVC_VERSION GREATER_EQUAL "2000")) message(FATAL_ERROR "You are using an unsupported version of MSVC") @@ -282,17 +300,11 @@ if( CMAKE_C_COMPILER_ID MATCHES "MSVC") # resolution of symbols, add Psapi.lib to the TARGETLIBS macro and compile the program # with -DPSAPI_VERSION=1.To use run-time dynamic linking, load Psapi.dll. # http://msdn.microsoft.com/en-us/library/windows/desktop/ms683219(v=vs.85).aspx - # -DBUILD_WINDOWS Starting from VS2013, GetVersionEx is deprecated and we are recommended to use - # VerifyVersionInfo instead - # http://msdn.microsoft.com/en-us/library/windows/desktop/ms724429(v=vs.85).aspx - # http://msdn.microsoft.com/en-us/library/windows/desktop/ms725491(v=vs.85).aspx - # To continue to use GetVersionEx, we can define BUILD_WINDOWS # -D_ALLOW_KEYWORD_MACROS For VS2012 onwards the, C++ STL does not permit macro redefinitions of keywords # (see http://msdn.microsoft.com/en-us/library/bb531344(v=vs.110).aspx) # This definition prevents the complaint about the redefinition of inline by WinPCap # in pcap-stdinc.h when compiling C++ files, e.g. the Qt UI /DPSAPI_VERSION=1 - /DBUILD_WINDOWS /D_ALLOW_KEYWORD_MACROS ) @@ -465,11 +477,12 @@ else() # ! MSVC ) endif() - set(COMMON_WARN_FLAGS + list(APPEND WIRESHARK_COMMON_FLAGS # The following are for C and C++ # -O and -g get set by the CMAKE_BUILD_TYPE -Wall -Wextra + -Wextra-semi -Wendif-labels -Wpointer-arith -Wformat-security @@ -484,6 +497,8 @@ else() # ! MSVC -Wno-overlength-strings -Wno-long-long -Wheader-guard + -Wcomma + -Wshorten-64-to-32 ) # @@ -496,12 +511,12 @@ else() # ! MSVC # the stack usage - we only care about stack # usage in normal operation. # - set(COMMON_WARN_FLAGS ${COMMON_WARN_FLAGS} + set(WIRESHARK_COMMON_FLAGS ${WIRESHARK_COMMON_FLAGS} -Wframe-larger-than=32768 ) endif() - set(C_WARN_FLAGS + list(APPEND WIRESHARK_C_ONLY_FLAGS # The following are C only, not C++ -Wc++-compat -Wunused-const-variable @@ -525,128 +540,97 @@ else() # ! MSVC -Wlogical-op -Wjump-misses-init # - # The Qt headers generate a ton of shortening warnings - # on 64-bit systems, so we only enable this for C for - # now. - # - -Wshorten-64-to-32 - # # Implicit function declarations are an error in C++ and most # likely a programming error in C. Turn -Wimplicit-int and # -Wimplicit-function-declaration into an error by default. # -Werror=implicit - # - # The Qt headers in version 5.10 introduced a lot of - # "Possible misuse of comma operator here" warnings. - # - -Wcomma ) - set(CXX_WARN_FLAGS + list(APPEND WIRESHARK_CXX_ONLY_FLAGS ) - find_package(Qt5Core) # Needed to check for Qt version - if (Qt5Core_VERSION VERSION_GREATER 5.8) - # The Qt headers in version 5.8 and older generate a ton of shortening - # errors on 64-bit systems so only enable this for version 5.9 and greater. - set(CXX_WARN_FLAGS ${CXX_WARN_FLAGS} - -Wshorten-64-to-32 - ) - endif() - if (Qt5Core_VERSION VERSION_LESS 5.10) - # The Qt headers in version 5.10 introduced a lot of - # "Possible misuse of comma operator here" warnings. - set(CXX_WARN_FLAGS ${CXX_WARN_FLAGS} - -Wcomma - ) - endif() - # # These are not enabled by default, because the warnings they # produce are very hard or impossible to eliminate. # - set(COMMON_EXTRA_WARN_FLAGS - # The following are for C and C++ - -Wpedantic - # - # As we use variadic macros, we don't want warnings - # about them, even with -Wpedantic. - # - -Wno-variadic-macros - # - # Various code blocks this one. - # - -Woverflow - -fstrict-overflow -Wstrict-overflow=4 - # - # Due to various places where APIs we don't control - # require us to cast away constness, we can probably - # never enable this one with -Werror. - # - -Wcast-qual - # - # Some generated ASN.1 dissectors block this one; - # multiple function declarations for the same - # function are being generated. - # - -Wredundant-decls - # - # Some loops are safe, but it's hard to convince the - # compiler of that. - # - -Wunsafe-loop-optimizations - # - # All the registration functions block these for now. - # - -Wmissing-prototypes - -Wmissing-declarations - # - # A bunch of "that might not work on SPARC" code blocks - # this one for now; some of it is code that *will* work - # on SPARC, such as casts of "struct sockaddr *" to - # "struct sockaddr_in *", which are required by some - # APIs such as getifaddrs(). - # - -Wcast-align - # - # Works only with Clang - # - -Wunreachable-code - # - # Works only with Clang but generates a lot of warnings - # (about glib library not using Doxygen) - # - -Wdocumentation - # - # Works only with GCC 7 - # - -Wduplicated-branches - # - # No longer supported by El Capitan clang on C++ - # XXX - is this one of those where CMake's check - # doesn't fail, so it won't reject this? - # - -fno-delete-null-pointer-checks - ) - - set(C_EXTRA_WARN_FLAGS - # The following are C only, not C++ - # - # Due to various places where APIs we don't control - # require us to cast away constness, we can probably - # never enable this one with -Werror. - # - -Wbad-function-cast - ) + if(ENABLE_EXTRA_COMPILER_WARNINGS) # This overrides -Werror + list(APPEND WIRESHARK_COMMON_FLAGS + # The following are for C and C++ + -Wpedantic + # + # As we use variadic macros, we don't want warnings + # about them, even with -Wpedantic. + # + -Wno-variadic-macros + # + # Various code blocks this one. + # + -Woverflow + -fstrict-overflow -Wstrict-overflow=4 + # + # Due to various places where APIs we don't control + # require us to cast away constness, we can probably + # never enable this one with -Werror. + # + -Wcast-qual + # + # Some generated ASN.1 dissectors block this one; + # multiple function declarations for the same + # function are being generated. + # + -Wredundant-decls + # + # Some loops are safe, but it's hard to convince the + # compiler of that. + # + -Wunsafe-loop-optimizations + # + # All the registration functions block these for now. + # + -Wmissing-prototypes + -Wmissing-declarations + # + # A bunch of "that might not work on SPARC" code blocks + # this one for now; some of it is code that *will* work + # on SPARC, such as casts of "struct sockaddr *" to + # "struct sockaddr_in *", which are required by some + # APIs such as getifaddrs(). + # + -Wcast-align + # + # Works only with Clang + # + -Wunreachable-code + # + # Works only with Clang but generates a lot of warnings + # (about glib library not using Doxygen) + # + -Wdocumentation + # + # Works only with GCC 7 + # + -Wduplicated-branches + # + # No longer supported by El Capitan clang on C++ + # XXX - is this one of those where CMake's check + # doesn't fail, so it won't reject this? + # + -fno-delete-null-pointer-checks + ) - set(CXX_EXTRA_WARN_FLAGS - ) + list(APPEND WIRESHARK_C_ONLY_FLAGS + # The following are C only, not C++ + # + # Due to various places where APIs we don't control + # require us to cast away constness, we can probably + # never enable this one with -Werror. + # + -Wbad-function-cast + ) - if(ENABLE_EXTRA_COMPILER_WARNINGS) # This overrides -Werror - set(COMMON_WARN_FLAGS ${COMMON_WARN_FLAGS} ${COMMON_EXTRA_WARN_FLAGS}) - set(C_WARN_FLAGS ${C_WARN_FLAGS} ${C_EXTRA_WARN_FLAGS}) - set(CXX_WARN_FLAGS ${CXX_WARN_FLAGS} ${CXX_EXTRA_WARN_FLAGS}) + list(APPEND WIRESHARK_CXX_ONLY_FLAGS + ) endif() add_definitions( @@ -655,30 +639,16 @@ else() # ! MSVC ) set(WIRESHARK_LD_FLAGS + # See also CheckCLinkerFlag.cmake -Wl,--as-needed # -flto # -fwhopr # -fwhole-program + # XXX: This is applicable only when linking executables. + -pie ) - # CMAKE_POSITION_INDEPENDENT_CODE is only supported starting with CMake - # 2.8.9. Do not add -pie automatically for older versions. - # - # XXX - are there other compilers that don't support -pie? It's - # not as if the only platforms we support are Windows and Linux.... - # - if(NOT CMAKE_VERSION VERSION_LESS "2.8.9") - set(WIRESHARK_LD_FLAGS ${WIRESHARK_LD_FLAGS} - -pie - ) - endif() endif() # ! MSVC -set( C_FLAG_TESTS ${WIRESHARK_COMMON_FLAGS} ${WIRESHARK_C_ONLY_FLAGS} ) -set( CXX_FLAG_TESTS ${WIRESHARK_COMMON_FLAGS} ${WIRESHARK_CXX_ONLY_FLAGS} ) - -set( C_WARN_TESTS ${COMMON_WARN_FLAGS} ${C_WARN_FLAGS} ) -set( CXX_WARN_TESTS ${COMMON_WARN_FLAGS} ${CXX_WARN_FLAGS} ) - # Counterhack to work around some cache magic in CHECK_C_SOURCE_COMPILES include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) @@ -689,54 +659,30 @@ else() set(BUILD_SHARED_LIBS 1) endif() -# Sigh: Have to use THIS_FLAG instead of ${F} for some reason -foreach(THIS_FLAG ${C_FLAG_TESTS}) - string( REGEX REPLACE "[^a-zA-Z0-9_]+" "_" F ${THIS_FLAG} ) - set(${F} ${THIS_FLAG}) - set(V C_${F}_VALID) - message(STATUS "Checking for c-compiler flag: ${THIS_FLAG}") - check_c_compiler_flag("${ADDED_CMAKE_C_FLAGS} ${${F}}" ${V}) - if (${${V}}) - set(ADDED_CMAKE_C_FLAGS "${ADDED_CMAKE_C_FLAGS} ${${F}}") +function(test_compiler_flag _lang _this_flag _valid_flags_var) + string(MAKE_C_IDENTIFIER "${_lang}${_this_flag}_VALID" _flag_var) + set(_test_flags "${${_valid_flags_var}} ${_this_flag}") + if(_lang STREQUAL "C") + check_c_compiler_flag("${_test_flags}" ${_flag_var}) + elseif(_lang STREQUAL "CXX") + check_cxx_compiler_flag("${_test_flags}" ${_flag_var}) + else() + message(FATAL_ERROR "Language must be C or CXX") endif() -endforeach() -set(CMAKE_C_FLAGS "${ADDED_CMAKE_C_FLAGS} ${CMAKE_C_FLAGS}") - -foreach(THIS_FLAG ${CXX_FLAG_TESTS}) - string( REGEX REPLACE "[^a-zA-Z0-9_]+" "_" F ${THIS_FLAG} ) - set(${F} ${THIS_FLAG}) - set(V CXX_${F}_VALID) - message(STATUS "Checking for c++-compiler flag: ${THIS_FLAG}") - check_cxx_compiler_flag("${ADDED_CMAKE_CXX_FLAGS} ${${F}}" ${V}) - if (${${V}}) - set(ADDED_CMAKE_CXX_FLAGS "${ADDED_CMAKE_CXX_FLAGS} ${${F}}") + if (${_flag_var}) + set(${_valid_flags_var} "${_test_flags}" PARENT_SCOPE) endif() -endforeach() -set(CMAKE_CXX_FLAGS "${ADDED_CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS}") +endfunction() -foreach(THIS_FLAG ${C_WARN_TESTS}) - string( REGEX REPLACE "[^a-zA-Z0-9_]+" "_" F ${THIS_FLAG} ) - set(${F} ${THIS_FLAG}) - set(V C_${F}_VALID) - message(STATUS "Checking for c-compiler flag: ${THIS_FLAG}") - check_c_compiler_flag("${C_FLAG_TESTS} ${${F}}" ${V}) - if (${${V}}) - set(ADDED_WARN_C_FLAGS "${ADDED_WARN_C_FLAGS} ${${F}}") - endif() +foreach(THIS_FLAG ${WIRESHARK_COMMON_FLAGS} ${WIRESHARK_C_ONLY_FLAGS}) + test_compiler_flag(C ${THIS_FLAG} ADDED_CMAKE_C_FLAGS) endforeach() -set(CMAKE_C_FLAGS "${ADDED_WARN_C_FLAGS} ${CMAKE_C_FLAGS}") +set(CMAKE_C_FLAGS "${ADDED_CMAKE_C_FLAGS} ${CMAKE_C_FLAGS}") -foreach(THIS_FLAG ${CXX_WARN_TESTS}) - string( REGEX REPLACE "[^a-zA-Z0-9_]+" "_" F ${THIS_FLAG} ) - set(${F} ${THIS_FLAG}) - set(V CXX_${F}_VALID) - message(STATUS "Checking for c++-compiler flag: ${THIS_FLAG}") - check_cxx_compiler_flag("${CXX_FLAG_TESTS} ${${F}}" ${V}) - if (${${V}}) - set(ADDED_WARN_CXX_FLAGS "${ADDED_WARN_CXX_FLAGS} ${${F}}") - endif() +foreach(THIS_FLAG ${WIRESHARK_COMMON_FLAGS} ${WIRESHARK_CXX_ONLY_FLAGS}) + test_compiler_flag(CXX ${THIS_FLAG} ADDED_CMAKE_CXX_FLAGS) endforeach() -set(CMAKE_CXX_FLAGS "${ADDED_WARN_CXX_FLAGS} ${CMAKE_CXX_FLAGS}") +set(CMAKE_CXX_FLAGS "${ADDED_CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS}") include(CMakePushCheckState) @@ -789,15 +735,26 @@ if(ENABLE_UBSAN) endif() set(WERROR_COMMON_FLAGS "") -set(NO_ERROR_DEPRECATED_DECLARATIONS_COMPILE_FLAGS "") if(NOT DISABLE_WERROR AND NOT ENABLE_EXTRA_COMPILER_WARNINGS) if(CMAKE_C_COMPILER_ID MATCHES "MSVC") set(WERROR_COMMON_FLAGS "/WX") else() - check_c_compiler_flag(-Werror WERROR) - if (WERROR) - set(WERROR_COMMON_FLAGS "-Werror") - set(NO_ERROR_DEPRECATED_DECLARATIONS_COMPILE_FLAGS "-Wno-error=deprecated-declarations") + # + # If a warning has been enabled by -Wall or -W, + # and have specified -Werror, there appears to be + # no way, in Apple's llvm-gcc, to prevent that + # particular warning from giving an error - not + # with a pragma, not with -Wno-{warning}, and not + # with -Wno-error={warning}. + # + # Therefore, with that compiler, we just disable + # -Werror. + # + if ((NOT APPLE) OR CMAKE_C_COMPILER_ID MATCHES "Clang") + check_c_compiler_flag(-Werror WERROR) + if (WERROR) + set(WERROR_COMMON_FLAGS "-Werror") + endif() endif() endif() endif() @@ -839,18 +796,15 @@ if( NOT CMAKE_C_COMPILER_ID MATCHES "MSVC") endif() include(CheckCLinkerFlag) -set(_C 0) -# Sigh: Have to use THIS_FLAG instead of ${F} for some reason + foreach(THIS_FLAG ${WIRESHARK_LD_FLAGS}) - set(F WS_LD_FLAG_${_C}) - set(${F} ${THIS_FLAG}) - set(V WS_LD_FLAG_VALID${_C}) - check_c_linker_flag(${${F}} ${V}) - if (${${V}}) - set(WS_LINK_FLAGS "${WS_LINK_FLAGS} ${${F}}") - endif() - math(EXPR _C "${_C} + 1") + string(MAKE_C_IDENTIFIER "LINK${THIS_FLAG}_VALID" _flag_var) + check_c_linker_flag(${THIS_FLAG} ${_flag_var}) + if (${_flag_var}) + set(WS_LINK_FLAGS "${WS_LINK_FLAGS} ${THIS_FLAG}") + endif() endforeach() +message(STATUS "Linker flags: ${WS_LINK_FLAGS}") if(APPLE AND EXISTS /usr/local/opt/gettext) # GLib on macOS requires libintl. Homebrew installs gettext (and @@ -874,6 +828,7 @@ set(GLIB2_FIND_OPTIONS REQUIRED) set(GLIB2_MIN_VERSION 2.32.0) set(GTHREAD2_OPTIONS REQUIRED) set(GCRYPT_OPTIONS "1.4.2" REQUIRED) +set(Perl_OPTIONS REQUIRED) set(PythonInterp_FIND_VERSION 2) set(Python_ADDITIONAL_VERSIONS 3) set(YACC_OPTIONS REQUIRED) @@ -896,6 +851,10 @@ if(ENABLE_AIRPCAP) set(PACKAGELIST ${PACKAGELIST} AIRPCAP) endif() +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(PACKAGELIST ${PACKAGELIST} Systemd) +endif() + # Build the Qt GUI? if(BUILD_wireshark) # Untested, may not work if CMAKE_PREFIX_PATH gets overwritten @@ -904,6 +863,7 @@ if(BUILD_wireshark) set( QT5_BASE_PATH "$ENV{QT5_BASE_DIR}" ) set( CMAKE_PREFIX_PATH "${QT5_BASE_PATH}" ) endif() + list (INSERT QT_FIND_PACKAGE_OPTIONS 0 REQUIRED) set(PACKAGELIST ${PACKAGELIST} Qt5Core Qt5LinguistTools @@ -912,19 +872,19 @@ if(BUILD_wireshark) Qt5Svg Qt5Widgets ) - set(Qt5Core_OPTIONS REQUIRED) - set(Qt5LinguistTools_OPTIONS REQUIRED) - set(Qt5Multimedia_OPTIONS REQUIRED) - set(Qt5PrintSupport_OPTIONS REQUIRED) - set(Qt5Svg_OPTIONS REQUIRED) - set(Qt5Widgets_OPTIONS REQUIRED) + set(Qt5Core_OPTIONS ${QT_FIND_PACKAGE_OPTIONS}) + set(Qt5LinguistTools_OPTIONS ${QT_FIND_PACKAGE_OPTIONS}) + set(Qt5Multimedia_OPTIONS ${QT_FIND_PACKAGE_OPTIONS}) + set(Qt5PrintSupport_OPTIONS ${QT_FIND_PACKAGE_OPTIONS}) + set(Qt5Svg_OPTIONS ${QT_FIND_PACKAGE_OPTIONS}) + set(Qt5Widgets_OPTIONS ${QT_FIND_PACKAGE_OPTIONS}) if (APPLE) set(PACKAGELIST ${PACKAGELIST} Qt5MacExtras) - set(Qt5MacExtras_OPTIONS REQUIRED) + set(Qt5MacExtras_OPTIONS ${QT_FIND_PACKAGE_OPTIONS}) endif() if( WIN32 ) set(PACKAGELIST ${PACKAGELIST} Qt5WinExtras) - set(Qt5WinExtras_OPTIONS REQUIRED) + set(Qt5WinExtras_OPTIONS ${QT_FIND_PACKAGE_OPTIONS}) endif() endif() @@ -997,6 +957,7 @@ endif() # Embedded Lua interpreter if(ENABLE_LUA) set(PACKAGELIST ${PACKAGELIST} LUA) + set(LUA_OPTIONS "5.1") endif() if(ENABLE_NETLINK) @@ -1093,9 +1054,6 @@ foreach(PACKAGE ${PACKAGELIST}) endif() endforeach() -# Provide Windows system lib names -include( UseWinLibs ) - # dist target that prepares source dir # XXX Duplicated in the RPM section below. add_custom_target(dist @@ -1103,7 +1061,6 @@ add_custom_target(dist WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) - if(HAVE_LIBAIRPCAP) set(HAVE_AIRPCAP 1) endif() @@ -1204,12 +1161,46 @@ if (Qt5Widgets_FOUND) # Squelch moc verbose "nothing to do" output set(MOC_OPTIONS -nn) endif() + + # CMake uses qmake to find Qt4. It relies on Qt's CMake modules + # to find Qt5. This means that we can't assume that the qmake + # in our PATH is the correct one. We can fetch qmake's location + # from Qt5::qmake, which is is defined in Qt5CoreConfigExtras.cmake. + get_target_property(QT_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION) + get_filename_component(_qt_bin_path "${QT_QMAKE_EXECUTABLE}" DIRECTORY) + set(QT_BIN_PATH "${_qt_bin_path}" CACHE INTERNAL + "Path to qmake, macdeployqt, windeployqt, and other Qt utilities." + ) + # Use qmake to find windeployqt and macdeployqt. Ideally one of + # the modules in ${QTDIR}/lib/cmake would do this for us. + if(WIN32) + find_program(QT_WINDEPLOYQT_EXECUTABLE windeployqt + HINTS "${QT_BIN_PATH}" + DOC "Path to the windeployqt utility." + ) + elseif(APPLE) + find_program(QT_MACDEPLOYQT_EXECUTABLE macdeployqt + HINTS "${QT_BIN_PATH}" + DOC "Path to the macdeployqt utility." + ) + endif() + endif() if(ENABLE_CHECKHF_CONFLICT) set(ENABLE_CHECK_FILTER 1) endif() +# +# Platform-specific additional libraries. +# +if(WIN32) + set(WIN_PSAPI_LIBRARY psapi.lib) + set(WIN_WSOCK32_LIBRARY wsock32.lib) + set(WIN_COMCTL32_LIBRARY comctl32.lib ) + set(WIN_VERSION_LIBRARY version.lib) +endif() + if(APPLE) # # We assume that APPLE means macOS so that we have the macOS @@ -1253,11 +1244,20 @@ include( UseCheckAPI ) # Windows: $DESTDIR/extcap # macOS app bundle: Wireshark.app/Contents/Resources/share/wireshark/extcap if (WIN32) - set(EXTCAP_DIR "extcap" CACHE INTERNAL "The extcap dir") + set(EXTCAP_INSTALL_LIBDIR "extcap" CACHE INTERNAL "The extcap dir") else () - set(EXTCAP_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/${CPACK_PACKAGE_NAME}/extcap" CACHE INTERNAL "The extcap dir") + set(EXTCAP_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${CPACK_PACKAGE_NAME}/extcap" CACHE INTERNAL "The extcap dir") endif() +# Directory where plugins and Lua dissectors can be found. +if(WIN32) + set(PLUGIN_INSTALL_LIBDIR "plugins" CACHE INTERNAL "The plugin dir") +else() + set(PLUGIN_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${CPACK_PACKAGE_NAME}/plugins" CACHE INTERNAL "The plugin dir") +endif() +set(PLUGIN_INSTALL_VERSION_LIBDIR "${PLUGIN_INSTALL_LIBDIR}/${PROJECT_RELEASE_VERSION}") +set(PLUGIN_VERSION_DIR "plugins/${PROJECT_RELEASE_VERSION}") + add_subdirectory( capchild ) add_subdirectory( caputils ) add_subdirectory( codecs ) @@ -1276,7 +1276,12 @@ add_subdirectory( writecap ) # application bundle, and on UNIX in general if # WIRESHARK_RUN_FROM_BUILD_DIRECTORY is set. if(ENABLE_APPLICATION_BUNDLE) - set(_datafile_dir "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/share/wireshark") + if(CMAKE_CFG_INTDIR STREQUAL ".") + set(_datafile_dir "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/share/wireshark") + else() + # Xcode + set(_datafile_dir "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}/Wireshark.app/Contents/Resources/share/wireshark") + endif() elseif(NOT CMAKE_CFG_INTDIR STREQUAL ".") # Visual Studio, Xcode, etc. set(_datafile_dir "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}") @@ -1299,23 +1304,13 @@ if(BUILD_wireshark AND QT_FOUND) add_subdirectory( ui/qt ) endif() -# Directory where plugins and Lua dissectors can be found. -set(PLUGIN_VERSION_DIR "plugins/${PROJECT_RELEASE_VERSION}") -set(PLUGIN_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${CPACK_PACKAGE_NAME}/${PLUGIN_VERSION_DIR}") -# Used by the WiresharkConfig.cmake.in module -if (WIN32) - set(PLUGIN_INSTALL_DIR "${PLUGIN_VERSION_DIR}") -else () - set(PLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${PLUGIN_INSTALL_LIBDIR}") -endif() - # Location of our plugins. PLUGIN_DIR should allow running # from the build directory similar to DATAFILE_DIR above. if(ENABLE_PLUGINS) # Target platform locations # UN*X in general, including macOS if not building an app bundle: # $DESTDIR/lib/wireshark/plugins/$VERSION - # Windows: $DESTDIR/wireshark/plubins/$VERSION + # Windows: $DESTDIR/wireshark/plugins/$VERSION # macOS app bundle: Wireshark.app/Contents/PlugIns/wireshark set(HAVE_PLUGINS 1) add_custom_target(plugins) @@ -1351,7 +1346,14 @@ else() endif() if(ENABLE_APPLICATION_BUNDLE) - set(_plugin_dir "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/PlugIns/wireshark/${PROJECT_RELEASE_VERSION}") + if(CMAKE_CFG_INTDIR STREQUAL ".") + set(_plugin_dir "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/PlugIns/wireshark/${PROJECT_RELEASE_VERSION}") + else() + # Xcode + set(_plugin_dir "${CMAKE_BINARY_DIR}/run/$/Wireshark.app/Contents/PlugIns/wireshark/${PROJECT_RELEASE_VERSION}") + endif() +elseif(WIN32 AND NOT CMAKE_CFG_INTDIR STREQUAL ".") + set(_plugin_dir "${CMAKE_BINARY_DIR}/run/$/${PLUGIN_VERSION_DIR}") else() set(_plugin_dir "${DATAFILE_DIR}/${PLUGIN_VERSION_DIR}") endif() @@ -1381,12 +1383,13 @@ set_target_properties(version PROPERTIES FOLDER "Auxiliary") set( configure_input "Built with CMake ${CMAKE_VERSION}" ) configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h) +configure_file(${CMAKE_SOURCE_DIR}/ws_version.h.in ${CMAKE_BINARY_DIR}/ws_version.h) + set( prefix "${CMAKE_INSTALL_PREFIX}" ) set( exec_prefix "\${prefix}" ) set( libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}" ) set( includedir "\${prefix}/include" ) set( plugindir "\${libdir}/wireshark/${PLUGIN_VERSION_DIR}" ) -set( VERSION_RELEASE "${PROJECT_RELEASE_VERSION}" ) # Doxygen variables file(GLOB TOP_LEVEL_SOURCE_LIST *.c *.cpp *.h) @@ -1394,36 +1397,23 @@ string (REPLACE ";" " " DOXYGEN_TOP_LEVEL_SOURCES "${TOP_LEVEL_SOURCE_LIST}") set(DOXYGEN_INPUT_DIRECTORY ${CMAKE_SOURCE_DIR}) set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) -set(ICON_PATH "${CMAKE_SOURCE_DIR}/image/") -set( IN_FILES - doxygen.cfg.in - image/libwireshark.rc.in - image/text2pcap.rc.in - image/capinfos.rc.in - image/wireshark.rc.in - image/mergecap.rc.in - image/tshark.rc.in - image/dumpcap.rc.in - image/reordercap.rc.in - image/rawshark.rc.in - image/file_dlg_win32.rc - image/tfshark.rc.in - image/editcap.rc.in - image/captype.rc.in - image/libwscodecs.rc.in - image/libwsutil.rc.in - image/wiretap.rc.in - image/wireshark.exe.manifest.in - packaging/macosx/Info.plist.in - packaging/macosx/osx-app.sh.in - packaging/macosx/osx-dmg.sh.in - packaging/macosx/Wireshark_package.pmdoc/index.xml.in - wireshark.pc.in +set(CFG_OUT_FILES + doxygen.cfg + image/libwireshark.rc + image/wireshark.rc + image/dumpcap.rc + image/libwscodecs.rc + image/libwsutil.rc + image/wiretap.rc + image/wireshark.exe.manifest + packaging/macosx/Info.plist + packaging/macosx/osx-app.sh + packaging/macosx/osx-dmg.sh + packaging/macosx/Wireshark_package.pmdoc/index.xml + wireshark.pc ) -foreach( _in_file ${IN_FILES} ) - get_filename_component( _path ${_in_file} PATH ) - string( REGEX REPLACE "(.*)\\.in" "\\1" _outfile ${_in_file} ) - configure_file( ${CMAKE_SOURCE_DIR}/${_in_file} ${CMAKE_BINARY_DIR}/${_outfile} @ONLY ) +foreach( _cfg_file ${CFG_OUT_FILES} ) + configure_file( ${CMAKE_SOURCE_DIR}/${_cfg_file}.in ${CMAKE_BINARY_DIR}/${_cfg_file} @ONLY ) endforeach() include(FeatureSummary) @@ -1514,7 +1504,6 @@ set(SHARK_COMMON_SRC set(TSHARK_TAP_SRC ${CMAKE_SOURCE_DIR}/ui/cli/tap-camelsrt.c - ${CMAKE_SOURCE_DIR}/ui/cli/tap-comparestat.c ${CMAKE_SOURCE_DIR}/ui/cli/tap-diameter-avp.c ${CMAKE_SOURCE_DIR}/ui/cli/tap-expert.c ${CMAKE_SOURCE_DIR}/ui/cli/tap-exportobject.c @@ -1762,7 +1751,6 @@ if(WIN32) ) endif(OPTIONAL_DLLS) - # This might not be needed since make-dissectors has the same dependency. add_dependencies(epan copy_cli_dlls) # We have a lot of choices for creating zip archives: @@ -1779,7 +1767,7 @@ if(WIN32) DOC "Path to the 7z utility." ) if(ZIP_EXECUTABLE) - add_custom_target(pdb_zip_package) + add_custom_target(pdb_zip_package COMMENT "This packages .PDBs but will not create them.") set_target_properties(pdb_zip_package PROPERTIES FOLDER "Packaging") set(_pdb_zip "${CMAKE_BINARY_DIR}/Wireshark-pdb-${WIRESHARK_TARGET_PLATFORM}-${VERSION}.zip") file(TO_NATIVE_PATH "${_pdb_zip}" _pdb_zip_win) @@ -1792,7 +1780,6 @@ if(WIN32) ${PLUGIN_VERSION_DIR}/wiretap/*.pdb WORKING_DIRECTORY "${_dll_output_dir}" ) - add_dependencies(pdb_zip_package epan) endif() endif(WIN32) @@ -1930,13 +1917,6 @@ foreach(_data_file ${_data_files}) list(APPEND copy_data_files_depends "${DATAFILE_DIR}/${_data_file}") endforeach() -add_custom_command( - OUTPUT "${DATAFILE_DIR}/dtds" "${DATAFILE_DIR}/diameter" "${DATAFILE_DIR}/radius" - COMMAND ${CMAKE_COMMAND} -E make_directory "${DATAFILE_DIR}/dtds" - COMMAND ${CMAKE_COMMAND} -E make_directory "${DATAFILE_DIR}/diameter" - COMMAND ${CMAKE_COMMAND} -E make_directory "${DATAFILE_DIR}/radius" -) - file(GLOB _dtds_src_files RELATIVE "${CMAKE_SOURCE_DIR}" "dtds/*.dtd") set (_dtds_data_files) @@ -1946,11 +1926,12 @@ endforeach() add_custom_command( OUTPUT ${_dtds_data_files} + COMMAND ${CMAKE_COMMAND} -E make_directory "${DATAFILE_DIR}/dtds" COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_dtds_src_files} "${DATAFILE_DIR}/dtds" VERBATIM - DEPENDS "${DATAFILE_DIR}/dtds" + DEPENDS ${_dtds_src_files} WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" ) @@ -1966,11 +1947,12 @@ endforeach() add_custom_command( OUTPUT ${_diameter_data_files} + COMMAND ${CMAKE_COMMAND} -E make_directory "${DATAFILE_DIR}/diameter" COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_diameter_src_files} "${DATAFILE_DIR}/diameter" VERBATIM - DEPENDS "${DATAFILE_DIR}/diameter" + DEPENDS ${_diameter_src_files} WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" ) @@ -1988,11 +1970,12 @@ endforeach() add_custom_command( OUTPUT ${_radius_data_files} + COMMAND ${CMAKE_COMMAND} -E make_directory "${DATAFILE_DIR}/radius" COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_radius_src_files} "${DATAFILE_DIR}/radius" VERBATIM - DEPENDS "${DATAFILE_DIR}/radius" + DEPENDS ${_radius_src_files} WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" ) @@ -2030,9 +2013,9 @@ if(BUILD_wireshark AND QT_FOUND) ) set(wireshark_FILES ${WIRESHARK_SRC} - ${CMAKE_BINARY_DIR}/image/wireshark.rc ${PLATFORM_UI_RC_FILES} ) + set_executable_resources(wireshark "Wireshark" UNIQUE_RC) endif() if(ENABLE_APPLICATION_BUNDLE) @@ -2109,6 +2092,7 @@ if(BUILD_wireshark AND QT_FOUND) ui capchild caputils + wiretap ${QT_LIBRARIES} ${GTHREAD2_LIBRARIES} wscodecs @@ -2121,7 +2105,7 @@ if(BUILD_wireshark AND QT_FOUND) ${WIN_VERSION_LIBRARY} ) - add_executable(wireshark WIN32 MACOSX_BUNDLE wireshark-qt.cpp ${wireshark_FILES} ${EXTRA_BUNDLE_FILES}) + add_executable(wireshark WIN32 MACOSX_BUNDLE ${wireshark_FILES} ${EXTRA_BUNDLE_FILES}) add_dependencies(wireshark version) set(PROGLIST ${PROGLIST} wireshark) if(CMAKE_VERSION VERSION_LESS "2.8.12" @@ -2153,13 +2137,16 @@ if(BUILD_wireshark AND QT_FOUND) wireshark PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_BINARY_DIR}/packaging/macosx/Info.plist ) - # Add a wrapper script which opens the bundle. This adds - # convenience but makes debugging more difficult. - file(REMOVE ${CMAKE_BINARY_DIR}/run/wireshark) - file(WRITE ${CMAKE_BINARY_DIR}/run/wireshark "#!/bin/sh\n") - file(APPEND ${CMAKE_BINARY_DIR}/run/wireshark "# Generated by ${CMAKE_CURRENT_LIST_FILE}\n") - file(APPEND ${CMAKE_BINARY_DIR}/run/wireshark "exec ${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/MacOS/Wireshark \"\$\@\"\n") - execute_process(COMMAND chmod a+x ${CMAKE_BINARY_DIR}/run/wireshark) + if(CMAKE_CFG_INTDIR STREQUAL ".") + # Add a wrapper script which opens the bundle. This adds + # convenience but makes debugging more difficult. + # It is not created if using Xcode + file(REMOVE ${CMAKE_BINARY_DIR}/run/wireshark) + file(WRITE ${CMAKE_BINARY_DIR}/run/wireshark "#!/bin/sh\n") + file(APPEND ${CMAKE_BINARY_DIR}/run/wireshark "# Generated by ${CMAKE_CURRENT_LIST_FILE}\n") + file(APPEND ${CMAKE_BINARY_DIR}/run/wireshark "exec ${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/MacOS/Wireshark \"\$\@\"\n") + execute_process(COMMAND chmod a+x ${CMAKE_BINARY_DIR}/run/wireshark) + endif() endif() target_link_libraries(wireshark ${wireshark_LIBS}) @@ -2169,63 +2156,52 @@ if(BUILD_wireshark AND QT_FOUND) BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} ) - if(WIN32 AND Qt5Core_FOUND) - # Use windeployqt to copy our required DLLs to the run path. - # Ideally one of the modules in ${QTDIR}/lib/cmake would expose - # the path to windeployqt. For that matter having a reliable - # path to qmake would be *amazingly convenient*. We don't have - # either of those so we try to discover the path via Qt5Core. - # http://stackoverflow.com/questions/24650936/qt5-with-cmake-how-to-find-qt-translations-dir - - get_target_property(_qmake_location Qt5::qmake IMPORTED_LOCATION) - get_filename_component(_qt_bin_path "${_qmake_location}" DIRECTORY) - find_program(QT_WINDEPLOYQT_EXECUTABLE windeployqt - HINTS "${_qmake_location}" - DOC "Path to the windeployqt utility." + if(QT_WINDEPLOYQT_EXECUTABLE) + add_custom_target(copy_qt_dlls ALL) + set_target_properties(copy_qt_dlls PROPERTIES FOLDER "Copy Tasks") + # Will we ever need to use --debug? Windeployqt seems to + # be smart enough to copy debug DLLs when needed. + add_custom_command(TARGET copy_qt_dlls + POST_BUILD + COMMAND set "PATH=${QT_BIN_PATH};%PATH%" + COMMAND "${QT_WINDEPLOYQT_EXECUTABLE}" + $<$:--debug> + $<$>:--release> + --no-compiler-runtime + --verbose 10 + "$" ) - if(QT_WINDEPLOYQT_EXECUTABLE) - set(QT_BIN_PATH "${_qt_bin_path}" CACHE INTERNAL - "Path to qmake, windeployqt, and other Qt utilities." - ) - add_custom_target(copy_qt_dlls ALL) - set_target_properties(copy_qt_dlls PROPERTIES FOLDER "Copy Tasks") - # Will we ever need to use --debug? Windeployqt seems to - # be smart enough to copy debug DLLs when needed. - add_custom_command(TARGET copy_qt_dlls - POST_BUILD - COMMAND set "PATH=${QT_BIN_PATH};%PATH%" - COMMAND "${QT_WINDEPLOYQT_EXECUTABLE}" - $<$:--debug> - $<$>:--release> - --no-compiler-runtime - --verbose 10 - "$" - ) - add_dependencies(copy_qt_dlls wireshark) - endif() - endif(WIN32 AND Qt5Core_FOUND) + add_dependencies(copy_qt_dlls wireshark) + endif(QT_WINDEPLOYQT_EXECUTABLE) endif() # Common properties for CLI executables macro(set_extra_executable_properties _executable _folder) set_target_properties(${_executable} PROPERTIES - LINK_FLAGS "${WS_LINK_FLAGS}" + LINK_FLAGS "${WILDCARD_OBJ} ${WS_LINK_FLAGS}" FOLDER ${_folder} ) set(PROGLIST ${PROGLIST} ${_executable}) if(ENABLE_APPLICATION_BUNDLE) - set_target_properties(${_executable} PROPERTIES - RUNTIME_OUTPUT_DIRECTORY run/Wireshark.app/Contents/MacOS - ) - # Add a wrapper script which runs each executable from the - # correct location. This adds convenience but makes debugging - # more difficult. - file(REMOVE ${CMAKE_BINARY_DIR}/run/${_executable}) - file(WRITE ${CMAKE_BINARY_DIR}/run/${_executable} "#!/bin/sh\n") - file(APPEND ${CMAKE_BINARY_DIR}/run/${_executable} "exec ${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/MacOS/${_executable} \"\$\@\"\n") - execute_process(COMMAND chmod a+x ${CMAKE_BINARY_DIR}/run/${_executable}) + if(NOT CMAKE_CFG_INTDIR STREQUAL ".") + # Xcode + set_target_properties(${_executable} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY run/$/Wireshark.app/Contents/MacOS + ) + else () + set_target_properties(${_executable} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY run/Wireshark.app/Contents/MacOS + ) + # Add a wrapper script which runs each executable from the + # correct location. This adds convenience but makes debugging + # more difficult. + file(REMOVE ${CMAKE_BINARY_DIR}/run/${_executable}) + file(WRITE ${CMAKE_BINARY_DIR}/run/${_executable} "#!/bin/sh\n") + file(APPEND ${CMAKE_BINARY_DIR}/run/${_executable} "exec ${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/MacOS/${_executable} \"\$\@\"\n") + execute_process(COMMAND chmod a+x ${CMAKE_BINARY_DIR}/run/${_executable}) + endif() endif() endmacro() @@ -2238,6 +2214,7 @@ if(BUILD_tshark) ui capchild caputils + wiretap ${LIBEPAN_LIBS} ${APPLE_CORE_FOUNDATION_LIBRARY} ${APPLE_SYSTEM_CONFIGURATION_LIBRARY} @@ -2248,9 +2225,9 @@ if(BUILD_tshark) tshark.c ${TSHARK_TAP_SRC} ${SHARK_COMMON_SRC} - ${CMAKE_BINARY_DIR}/image/tshark.rc ) + set_executable_resources(tshark "TShark" UNIQUE_RC) add_executable(tshark ${tshark_FILES}) add_dependencies(tshark version) set_extra_executable_properties(tshark "Executables") @@ -2261,6 +2238,7 @@ endif() if(BUILD_tfshark) set(tfshark_LIBS ui + wiretap ${LIBEPAN_LIBS} ${APPLE_CORE_FOUNDATION_LIBRARY} ${APPLE_SYSTEM_CONFIGURATION_LIBRARY} @@ -2269,8 +2247,8 @@ if(BUILD_tfshark) tfshark.c ${TSHARK_TAP_SRC} ${SHARK_COMMON_SRC} - ${CMAKE_BINARY_DIR}/image/tfshark.rc ) + set_executable_resources(tfshark "TFShark") add_executable(tfshark ${tfshark_FILES}) add_dependencies(tfshark version) set_extra_executable_properties(tfshark "Executables") @@ -2282,6 +2260,7 @@ if(BUILD_rawshark AND PCAP_FOUND) set(rawshark_LIBS caputils ui + wiretap ${LIBEPAN_LIBS} ${APPLE_CORE_FOUNDATION_LIBRARY} ${APPLE_SYSTEM_CONFIGURATION_LIBRARY} @@ -2289,8 +2268,8 @@ if(BUILD_rawshark AND PCAP_FOUND) set(rawshark_FILES ${SHARK_COMMON_SRC} rawshark.c - ${CMAKE_BINARY_DIR}/image/rawshark.rc ) + set_executable_resources(rawshark "Rawshark") add_executable(rawshark ${rawshark_FILES}) add_dependencies(rawshark version) set_extra_executable_properties(rawshark "Executables") @@ -2302,6 +2281,7 @@ if(BUILD_sharkd) set(sharkd_LIBS ui wscodecs + wiretap ${LIBEPAN_LIBS} ${APPLE_CORE_FOUNDATION_LIBRARY} ${APPLE_SYSTEM_CONFIGURATION_LIBRARY} @@ -2312,6 +2292,7 @@ if(BUILD_sharkd) sharkd_session.c ${SHARK_COMMON_SRC} ) + set_executable_resources(sharkd "SharkD") add_executable(sharkd ${sharkd_FILES}) add_dependencies(sharkd version) set_extra_executable_properties(sharkd "Executables") @@ -2322,6 +2303,7 @@ endif() if(BUILD_dftest) set(dftest_LIBS ui + wiretap ${LIBEPAN_LIBS} ) set(dftest_FILES @@ -2357,6 +2339,7 @@ endif() if(BUILD_fuzzshark) set(fuzzshark_LIBS + wiretap ${LIBEPAN_LIBS} ) set(fuzzshark_FILES @@ -2384,8 +2367,9 @@ if(BUILD_text2pcap) add_lex_files(text2pcap_LEX_FILES text2pcap_FILES text2pcap-scanner.l ) - add_executable(text2pcap ${text2pcap_FILES} - ${CMAKE_BINARY_DIR}/image/text2pcap.rc) + set_executable_resources(text2pcap "Text2pcap" + COPYRIGHT_INFO "2001 Ashok Narayanan ") + add_executable(text2pcap ${text2pcap_FILES}) add_dependencies(text2pcap version) set_extra_executable_properties(text2pcap "Executables") target_link_libraries(text2pcap ${text2pcap_LIBS}) @@ -2402,8 +2386,8 @@ if(BUILD_mergecap) set(mergecap_FILES mergecap.c version_info.c - ${CMAKE_BINARY_DIR}/image/mergecap.rc ) + set_executable_resources(mergecap "Mergecap") add_executable(mergecap ${mergecap_FILES}) add_dependencies(mergecap version) set_extra_executable_properties(mergecap "Executables") @@ -2421,8 +2405,8 @@ if(BUILD_reordercap) set(reordercap_FILES reordercap.c version_info.c - ${CMAKE_BINARY_DIR}/image/reordercap.rc ) + set_executable_resources(reordercap "Reordercap") add_executable(reordercap ${reordercap_FILES}) add_dependencies(reordercap version) set_extra_executable_properties(reordercap "Executables") @@ -2442,8 +2426,8 @@ if(BUILD_capinfos) set(capinfos_FILES capinfos.c version_info.c - ${CMAKE_BINARY_DIR}/image/capinfos.rc ) + set_executable_resources(capinfos "Capinfos") add_executable(capinfos ${capinfos_FILES}) add_dependencies(capinfos version) set_extra_executable_properties(capinfos "Executables") @@ -2462,8 +2446,8 @@ if(BUILD_captype) set(captype_FILES captype.c version_info.c - ${CMAKE_BINARY_DIR}/image/captype.rc ) + set_executable_resources(captype "Captype") add_executable(captype ${captype_FILES}) add_dependencies(captype version) set_extra_executable_properties(captype "Executables") @@ -2482,8 +2466,8 @@ if(BUILD_editcap) set(editcap_FILES editcap.c version_info.c - ${CMAKE_BINARY_DIR}/image/editcap.rc ) + set_executable_resources(editcap "Editcap") add_executable(editcap ${editcap_FILES}) add_dependencies(editcap version) set_extra_executable_properties(editcap "Executables") @@ -2514,8 +2498,8 @@ if(BUILD_dumpcap AND PCAP_FOUND) ringbuffer.c sync_pipe_write.c version_info.c - ${CMAKE_BINARY_DIR}/image/dumpcap.rc ) + set_executable_resources(dumpcap "Dumpcap" UNIQUE_RC) add_executable(dumpcap ${dumpcap_FILES}) add_dependencies(dumpcap version) set_extra_executable_properties(dumpcap "Executables") @@ -2526,6 +2510,10 @@ if(BUILD_dumpcap AND PCAP_FOUND) OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + if(ENABLE_DUMPCAP_GROUP) + install(CODE "execute_process(COMMAND chgrp ${DUMPCAP_INSTALL_GROUP} ${CMAKE_INSTALL_FULL_BINDIR}/dumpcap)") + install(CODE "execute_process(COMMAND chmod o-x ${CMAKE_INSTALL_FULL_BINDIR}/dumpcap)") + endif() if(DUMPCAP_INSTALL_OPTION STREQUAL "capabilities") install( CODE "execute_process( COMMAND @@ -2622,9 +2610,6 @@ if(ENABLE_APPLICATION_BUNDLE) COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF ${CMAKE_BINARY_DIR}/run/ChmodBPF - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${CMAKE_SOURCE_DIR}/packaging/macosx/Resources - ${CMAKE_BINARY_DIR}/run/Resources COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/packaging/macosx/Scripts ${CMAKE_BINARY_DIR}/run/Scripts @@ -2656,6 +2641,7 @@ endif() if(CMAKE_SYSTEM_NAME STREQUAL "Linux") find_program(RPMBUILD_EXECUTABLE rpmbuild) + find_program(DPKG_BUILDPACKAGE_EXECUTABLE dpkg-buildpackage) find_program(GIT_EXECUTABLE git) endif() @@ -2680,10 +2666,13 @@ if(RPMBUILD_EXECUTABLE) if(CMAKE_GENERATOR STREQUAL "Ninja") list(APPEND _rpmbuild_with_args --with ninja) endif() + if(CCACHE_EXECUTABLE) + list(APPEND _rpmbuild_with_args --with ccache) + endif() if (BUILD_wireshark) list(APPEND _rpmbuild_with_args --with qt5) endif() - if (BUILD_mmdbresolve) + if (MAXMINDDB_FOUND) list(APPEND _rpmbuild_with_args --with mmdbresolve) endif() if (LUA_FOUND) @@ -2707,6 +2696,9 @@ if(RPMBUILD_EXECUTABLE) if (NGHTTP2_FOUND) list(APPEND _rpmbuild_with_args --with nghttp2) endif() + if (SYSTEMD_FOUND) + list(APPEND _rpmbuild_with_args --with sdjournal) + endif() execute_process( COMMAND ${PERL_EXECUTABLE} @@ -2727,7 +2719,6 @@ if(RPMBUILD_EXECUTABLE) # XXX Replace with the "dist" target? set(_export_tarball "${CPACK_PACKAGE_NAME}-${_git_description}.tar.xz") - MESSAGE(STATUS "set(_export_tarball: ${_export_tarball}") add_custom_command( OUTPUT "${CMAKE_BINARY_DIR}/packaging/rpm/SOURCES/${_export_tarball}" COMMAND ./tools/git-export-release.sh @@ -2749,7 +2740,15 @@ if(RPMBUILD_EXECUTABLE) ) endif() +if(DPKG_BUILDPACKAGE_EXECUTABLE) + add_custom_target(deb-package + COMMAND ${DPKG_BUILDPACKAGE_EXECUTABLE} -us -uc + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) +endif() + set(CLEAN_C_FILES + ${dumpcap_FILES} ${wireshark_FILES} ${tshark_FILES} ${rawshark_FILES} @@ -2802,6 +2801,7 @@ set(SHARK_PUBLIC_HEADERS ws_diag_control.h ws_symbol_export.h version_info.h + ${CMAKE_BINARY_DIR}/ws_version.h ) if(NOT WIN32) @@ -2864,23 +2864,51 @@ install( PATTERN "Makefile.*" EXCLUDE ) -set(CMAKE_INSTALL_MODULES_DIR ${CMAKE_INSTALL_LIBDIR}/${CPACK_PACKAGE_NAME}) -configure_file("${CMAKE_MODULE_PATH}/WiresharkConfig.cmake.in" "${CMAKE_BINARY_DIR}/WiresharkConfig.cmake" @ONLY) -configure_file("${CMAKE_MODULE_PATH}/WiresharkConfigVersion.cmake.in" "${CMAKE_BINARY_DIR}/WiresharkConfigVersion.cmake" @ONLY) +set(CMAKE_INSTALL_MODULES_DIR "${CMAKE_INSTALL_LIBDIR}/${CPACK_PACKAGE_NAME}/cmake") install( FILES ${CMAKE_MODULE_PATH}/FindGLIB2.cmake - ${CMAKE_MODULE_PATH}/FindWireshark.cmake ${CMAKE_MODULE_PATH}/FindWSWinLibs.cmake ${CMAKE_MODULE_PATH}/UseAsn2Wrs.cmake ${CMAKE_MODULE_PATH}/LocatePythonModule.cmake ${CMAKE_MODULE_PATH}/UseMakePluginReg.cmake - ${CMAKE_BINARY_DIR}/WiresharkConfig.cmake - ${CMAKE_BINARY_DIR}/WiresharkConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_MODULES_DIR} ) +include(CMakePackageConfigHelpers) + +configure_package_config_file(WiresharkConfig.cmake.in + ${CMAKE_BINARY_DIR}/WiresharkConfig.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_MODULES_DIR} + PATH_VARS + CMAKE_INSTALL_LIBDIR + CMAKE_INSTALL_INCLUDEDIR + PLUGIN_INSTALL_VERSION_LIBDIR + EXTCAP_INSTALL_LIBDIR +) + +write_basic_package_version_file( + ${CMAKE_BINARY_DIR}/WiresharkConfigVersion.cmake + COMPATIBILITY AnyNewerVersion +) + +# XXX On Windows wsutil depends on a CMake zlib target for which there are no +# exports. +if(NOT WIN32) + install( + FILES + ${CMAKE_BINARY_DIR}/WiresharkConfig.cmake + ${CMAKE_BINARY_DIR}/WiresharkConfigVersion.cmake + DESTINATION + ${CMAKE_INSTALL_MODULES_DIR} + ) + + install(EXPORT WiresharkTargets + DESTINATION ${CMAKE_INSTALL_MODULES_DIR} + ) +endif() + if (DOXYGEN_EXECUTABLE) # API reference # We don't have a good way of tracking dependencies, so we simply @@ -2917,27 +2945,39 @@ set_target_properties(test-programs PROPERTIES enable_testing() # We could try to build this list dynamically, but given that we tend to # go years between adding suites just run -# test/test.py --list-suites | sort +# test/test.py --list-groups | sort # and paste the output here. -set(_test_suite_list +set(_test_group_list suite_capture suite_clopts suite_decryption - suite_dfilter + suite_dfilter.group_bytes_ether + suite_dfilter.group_bytes_ipv6 + suite_dfilter.group_bytes_type + suite_dfilter.group_double + suite_dfilter.group_integer + suite_dfilter.group_integer_1byte + suite_dfilter.group_ipv4 + suite_dfilter.group_membership + suite_dfilter.group_range_method + suite_dfilter.group_scanner + suite_dfilter.group_string_type + suite_dfilter.group_stringz + suite_dfilter.group_time_relative + suite_dfilter.group_time_type + suite_dfilter.group_tvb + suite_dfilter.group_uint64 suite_dissection suite_fileformats + suite_follow suite_io suite_mergecap suite_nameres suite_text2pcap + suite_sharkd suite_unittests suite_wslua ) -if(WIN32) - set(_test_suite_program_path ./run/$) -else() - set(_test_suite_program_path ./run) -endif() # We don't currently handle spaces in arguments. On Windows this # means that you will probably have to pass in an interface index @@ -2945,17 +2985,17 @@ endif() set(TEST_EXTRA_ARGS "" CACHE STRING "Extra arguments to pass to test/test.py") separate_arguments(TEST_EXTRA_ARGS) -foreach(_suite_name ${_test_suite_list}) +foreach(_group_name ${_test_group_list}) add_test( - NAME ${_suite_name} + NAME ${_group_name} COMMAND ${CMAKE_COMMAND} -E env PYTHONIOENCODING=UTF-8 ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/test/test.py --verbose - --program-path ${_test_suite_program_path} + --program-path ${WS_PROGRAM_PATH} ${TEST_EXTRA_ARGS} - ${_suite_name} + ${_group_name} ) - set_tests_properties(${_suite_name} PROPERTIES TIMEOUT 600) + set_tests_properties(${_group_name} PROPERTIES TIMEOUT 600) endforeach() if (GIT_EXECUTABLE) @@ -3017,9 +3057,19 @@ if(SHELLCHECK_EXECUTABLE) # --external-sources requires 0.4.0 or later. add_custom_command(TARGET shellcheck POST_BUILD COMMAND shellcheck --external-sources + image/stock_icons/svg-to-png.sh + packaging/macosx/osx-app.sh.in + packaging/macosx/osx-dmg.sh.in + tools/compress-pngs.sh + tools/debian-setup.sh + tools/git-export-release.sh tools/fuzz-test.sh + tools/gen-bugnote + tools/pre-commit tools/randpkt-test.sh + tools/release-update-debian-soversions.sh tools/test-captures.sh + tools/update-tx tools/valgrind-wireshark.sh WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" )