more
[metze/wireshark/wip.git] / CMakeLists.txt
index aecc22b6b04989cea85faa00007c4e6726117491..076735341e40c1d823b26d2a4adec5228070adb3 100644 (file)
@@ -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
@@ -270,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/$<CONFIG>)
+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")
@@ -463,7 +477,7 @@ else() # ! MSVC
                )
        endif()
 
-       set(COMMON_WARN_FLAGS
+       list(APPEND WIRESHARK_COMMON_FLAGS
                # The following are for C and C++
                # -O<X> and -g get set by the CMAKE_BUILD_TYPE
                -Wall
@@ -483,6 +497,8 @@ else() # ! MSVC
                -Wno-overlength-strings
                -Wno-long-long
                -Wheader-guard
+               -Wcomma
+               -Wshorten-64-to-32
        )
 
        #
@@ -495,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
@@ -524,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 ${QT_FIND_PACKAGE_OPTIONS}) # 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(
@@ -654,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)
@@ -688,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)
 
@@ -788,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()
@@ -838,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
@@ -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
@@ -998,6 +957,7 @@ endif()
 # Embedded Lua interpreter
 if(ENABLE_LUA)
        set(PACKAGELIST ${PACKAGELIST} LUA)
+       set(LUA_OPTIONS "5.1")
 endif()
 
 if(ENABLE_NETLINK)
@@ -1094,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
@@ -1104,7 +1061,6 @@ add_custom_target(dist
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
 )
 
-
 if(HAVE_LIBAIRPCAP)
        set(HAVE_AIRPCAP 1)
 endif()
@@ -1235,6 +1191,16 @@ 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
@@ -1431,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)
@@ -1551,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
@@ -2061,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)
@@ -2226,7 +2178,7 @@ 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}
        )
 
@@ -2273,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")
@@ -2295,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")
@@ -2316,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")
@@ -2340,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")
@@ -2414,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 <ashokn@cisco.com>")
+       add_executable(text2pcap ${text2pcap_FILES})
        add_dependencies(text2pcap version)
        set_extra_executable_properties(text2pcap "Executables")
        target_link_libraries(text2pcap ${text2pcap_LIBS})
@@ -2432,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")
@@ -2451,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")
@@ -2472,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")
@@ -2492,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")
@@ -2512,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")
@@ -2544,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")
@@ -2656,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
@@ -2690,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()
 
@@ -2714,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)
@@ -2741,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}
@@ -2782,6 +2740,13 @@ 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}
@@ -3013,11 +2978,6 @@ set(_test_group_list
        suite_unittests
        suite_wslua
 )
-if(WIN32)
-       set(_test_group_program_path ./run/$<CONFIG>)
-else()
-       set(_test_group_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
@@ -3031,7 +2991,7 @@ foreach(_group_name ${_test_group_list})
                COMMAND ${CMAKE_COMMAND} -E env PYTHONIOENCODING=UTF-8
                        ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/test/test.py
                        --verbose
-                       --program-path ${_test_group_program_path}
+                       --program-path ${WS_PROGRAM_PATH}
                        ${TEST_EXTRA_ARGS}
                        ${_group_name}
                )