TODO SMB2 NegotiateContext....
[metze/wireshark/wip.git] / CMakeLists.txt
index a6a59543fb07eb5ce6a8018ddba87679448e633d..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")
@@ -286,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
        )
 
@@ -469,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
@@ -489,6 +497,8 @@ else() # ! MSVC
                -Wno-overlength-strings
                -Wno-long-long
                -Wheader-guard
+               -Wcomma
+               -Wshorten-64-to-32
        )
 
        #
@@ -501,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
@@ -530,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(
@@ -660,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)
@@ -694,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)
 
@@ -794,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()
@@ -844,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
@@ -902,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
@@ -1004,6 +957,7 @@ endif()
 # Embedded Lua interpreter
 if(ENABLE_LUA)
        set(PACKAGELIST ${PACKAGELIST} LUA)
+       set(LUA_OPTIONS "5.1")
 endif()
 
 if(ENABLE_NETLINK)
@@ -1100,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
@@ -1110,7 +1061,6 @@ add_custom_target(dist
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
 )
 
-
 if(HAVE_LIBAIRPCAP)
        set(HAVE_AIRPCAP 1)
 endif()
@@ -1211,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
@@ -1260,10 +1244,19 @@ 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 )
@@ -1283,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}")
@@ -1306,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)
@@ -1358,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/$<CONFIG>/Wireshark.app/Contents/PlugIns/wireshark/${PROJECT_RELEASE_VERSION}")
+       endif()
+elseif(WIN32 AND NOT CMAKE_CFG_INTDIR STREQUAL ".")
+       set(_plugin_dir "${CMAKE_BINARY_DIR}/run/$<CONFIG>/${PLUGIN_VERSION_DIR}")
 else()
        set(_plugin_dir "${DATAFILE_DIR}/${PLUGIN_VERSION_DIR}")
 endif()
@@ -1388,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)
@@ -1401,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)
@@ -1521,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
@@ -1785,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)
@@ -1798,7 +1780,6 @@ if(WIN32)
                                ${PLUGIN_VERSION_DIR}/wiretap/*.pdb
                        WORKING_DIRECTORY "${_dll_output_dir}"
                )
-               add_dependencies(pdb_zip_package epan)
        endif()
 endif(WIN32)
 
@@ -2032,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)
@@ -2111,6 +2092,7 @@ if(BUILD_wireshark AND QT_FOUND)
                ui
                capchild
                caputils
+               wiretap
                ${QT_LIBRARIES}
                ${GTHREAD2_LIBRARIES}
                wscodecs
@@ -2155,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})
@@ -2171,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}"
+                               $<$<CONFIG:Debug>:--debug>
+                               $<$<NOT:$<CONFIG:Debug>>:--release>
+                               --no-compiler-runtime
+                               --verbose 10
+                               "$<TARGET_FILE:wireshark>"
                )
-               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}"
-                                       $<$<CONFIG:Debug>:--debug>
-                                       $<$<NOT:$<CONFIG:Debug>>:--release>
-                                       --no-compiler-runtime
-                                       --verbose 10
-                                       "$<TARGET_FILE:wireshark>"
-                       )
-                       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/$<CONFIG>/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()
 
@@ -2240,6 +2214,7 @@ if(BUILD_tshark)
                ui
                capchild
                caputils
+               wiretap
                ${LIBEPAN_LIBS}
                ${APPLE_CORE_FOUNDATION_LIBRARY}
                ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
@@ -2250,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")
@@ -2263,6 +2238,7 @@ endif()
 if(BUILD_tfshark)
        set(tfshark_LIBS
                ui
+               wiretap
                ${LIBEPAN_LIBS}
                ${APPLE_CORE_FOUNDATION_LIBRARY}
                ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
@@ -2271,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")
@@ -2284,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}
@@ -2291,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")
@@ -2304,6 +2281,7 @@ if(BUILD_sharkd)
        set(sharkd_LIBS
                ui
                wscodecs
+               wiretap
                ${LIBEPAN_LIBS}
                ${APPLE_CORE_FOUNDATION_LIBRARY}
                ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
@@ -2314,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")
@@ -2324,6 +2303,7 @@ endif()
 if(BUILD_dftest)
        set(dftest_LIBS
                ui
+               wiretap
                ${LIBEPAN_LIBS}
        )
        set(dftest_FILES
@@ -2359,6 +2339,7 @@ endif()
 
 if(BUILD_fuzzshark)
        set(fuzzshark_LIBS
+               wiretap
                ${LIBEPAN_LIBS}
        )
        set(fuzzshark_FILES
@@ -2386,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})
@@ -2404,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")
@@ -2423,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")
@@ -2444,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")
@@ -2464,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")
@@ -2484,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")
@@ -2516,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")
@@ -2528,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
@@ -2624,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
@@ -2658,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()
 
@@ -2682,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)
@@ -2709,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}
@@ -2729,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
@@ -2751,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}
@@ -2804,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)
@@ -2866,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
@@ -2943,6 +2969,7 @@ set(_test_group_list
        suite_dfilter.group_uint64
        suite_dissection
        suite_fileformats
+       suite_follow
        suite_io
        suite_mergecap
        suite_nameres
@@ -2951,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
@@ -2969,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}
                )
@@ -3039,6 +3061,7 @@ if(SHELLCHECK_EXECUTABLE)
                        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