3 # Wireshark - Network traffic analyzer
4 # By Gerald Combs <gerald@wireshark.org>
5 # Copyright 1998 Gerald Combs
7 # SPDX-License-Identifier: GPL-2.0-or-later
9 if(DEFINED ENV{FORCE_CMAKE_NINJA_NON_VERBOSE})
11 # Forcibly unset CMAKE_VERBOSE_MAKEFILE,
12 # to make *CERTAIN* that we don't do
13 # anything verbose here!
15 unset(CMAKE_VERBOSE_MAKEFILE CACHE)
18 # https://doc.qt.io/qt-6/cmake-supported-cmake-versions.html
19 cmake_minimum_required(VERSION 3.16)
21 cmake_policy(SET CMP0135 NEW)
24 if(WIN32 AND NOT DEFINED ENV{MSYSTEM})
25 set(_project_name Wireshark)
26 set(STRATOSHARK_NAME Stratoshark)
28 set(_project_name wireshark)
29 set(STRATOSHARK_NAME stratoshark)
32 project(${_project_name} C CXX)
36 set(_repository False)
37 if(DEFINED ENV{MSYSTEM})
38 set(_msystem $ENV{MSYSTEM})
39 message(STATUS "Using MSYS2 with MSYSTEM=${_msystem}")
42 message(STATUS "Using 3rd party repository")
44 # Neither own package repository nor MSYS2 repository.
46 set(USE_MSYSTEM ${_msystem} CACHE INTERNAL "Use MSYS2 subsystem")
47 set(HAVE_MSYSTEM ${USE_MSYSTEM}) # For config.h
48 set(USE_REPOSITORY ${_repository} CACHE INTERNAL "Use Wireshark 3rd Party Repository")
51 # Updated by tools/make-version.py
52 set(PROJECT_MAJOR_VERSION 4)
53 set(PROJECT_MINOR_VERSION 5)
54 set(PROJECT_PATCH_VERSION 0)
55 set(PROJECT_BUILD_VERSION 0)
56 set(PROJECT_VERSION_EXTENSION "")
58 if(DEFINED ENV{WIRESHARK_VERSION_EXTRA})
59 set(PROJECT_VERSION_EXTENSION "$ENV{WIRESHARK_VERSION_EXTRA}")
62 set(PROJECT_VERSION "${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}.${PROJECT_PATCH_VERSION}${PROJECT_VERSION_EXTENSION}")
64 set(STRATOSHARK_MAJOR_VERSION 0)
65 set(STRATOSHARK_MINOR_VERSION 9)
66 set(STRATOSHARK_PATCH_VERSION 0)
67 set(STRATOSHARK_BUILD_VERSION 0)
68 set(STRATOSHARK_VERSION_EXTENSION "")
70 if(DEFINED ENV{STRATOSHARK_VERSION_EXTRA})
71 set(STRATOSHARK_VERSION_EXTENSION "$ENV{STRATOSHARK_VERSION_EXTRA}")
74 set(STRATOSHARK_VERSION "${STRATOSHARK_MAJOR_VERSION}.${STRATOSHARK_MINOR_VERSION}.${STRATOSHARK_PATCH_VERSION}${STRATOSHARK_VERSION_EXTENSION}")
76 include( CMakeOptions.txt )
78 # We require minimum C11
79 set(CMAKE_C_STANDARD 11)
80 set(CMAKE_C_STANDARD_REQUIRED ON)
82 # We require minimum C++11
83 set(CMAKE_CXX_STANDARD 11)
84 set(CMAKE_CXX_STANDARD_REQUIRED ON)
85 set(CMAKE_CXX_EXTENSIONS OFF)
87 message(STATUS "Generating build using CMake ${CMAKE_VERSION}")
90 # Prevent FindPython3.cmake from using the Python path in the registry,
91 # only use the $PATH environment variable (which is set up for MSYS2).
92 set(Python3_FIND_REGISTRY NEVER)
94 find_package(Python3 3.6 REQUIRED)
96 # Strawberry is a web browser away from being its own operating system. Find
97 # Perl before finding anything else so that we can avoid building with any of
98 # of Strawberry's components. Adding Strawberry's "/c" subdirectory to
99 # CMAKE_IGNORE_PREFIX_PATH should help us avoid pulling in libraries such as
100 # zlib and executables such as xsltproc. CMake 3.29.1 and later ignores their
101 # pkg-config: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9375
103 if(WIN32 AND PERL_EXECUTABLE)
104 string(TOLOWER ${PERL_EXECUTABLE} lower_perl)
105 if (${lower_perl} MATCHES "^.:/strawberry/")
106 string(REGEX REPLACE "^(.:/[^/]+).*" "\\1" strawberry_prefix ${PERL_EXECUTABLE})
107 # CMAKE_IGNORE_PREFIX_PATH must be an exact installation prefix.
108 list(APPEND CMAKE_IGNORE_PREFIX_PATH "${strawberry_prefix}/c")
109 message(STATUS "Added ${strawberry_prefix}/c to CMAKE_IGNORE_PREFIX_PATH")
111 unset(strawberry_prefix)
116 # Set a default build type if none was specified
117 set(_default_build_type "RelWithDebInfo")
118 if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
119 set(CMAKE_BUILD_TYPE "${_default_build_type}" CACHE STRING "Choose the type of build." FORCE)
120 # Set the possible values of build type for cmake-gui
121 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
124 # Build type is ignored by multi-config generators.
125 if (NOT CMAKE_CONFIGURATION_TYPES)
126 message(STATUS "Using \"${CMAKE_GENERATOR}\" generator and build type \"${CMAKE_BUILD_TYPE}\"")
128 message(STATUS "Using \"${CMAKE_GENERATOR}\" generator (multi-config)")
131 #Where to find local cmake scripts
132 set(WS_CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
133 set(CMAKE_MODULE_PATH ${WS_CMAKE_MODULE_PATH})
135 # CMake >= 3.9.0 supports LTO/IPO.
137 include(CheckIPOSupported)
138 check_ipo_supported(RESULT lto_supported OUTPUT lto_output)
140 set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
141 message(STATUS "LTO/IPO is enabled for Release configuration")
143 message(STATUS "LTO/IPO requested but it is not supported by the compiler: ${lto_output}")
146 message(STATUS "LTO/IPO is not enabled")
149 # If our target platform is enforced by our generator, set
150 # WIRESHARK_TARGET_PLATFORM accordingly. Otherwise use
151 # %WIRESHARK_TARGET_PLATFORM%.
154 if(DEFINED ENV{WIRESHARK_TARGET_PLATFORM})
155 string(TOLOWER $ENV{WIRESHARK_TARGET_PLATFORM} _target_platform)
156 set(WIRESHARK_TARGET_PLATFORM ${_target_platform})
157 elseif(USE_MSYSTEM MATCHES "MINGW64|CLANG64|UCRT64")
158 # https://www.msys2.org/docs/environments
159 # MSYS2 comes with different environments/subsystems and
160 # the first thing you have to decide is which one to use.
161 # The differences among the environments are mainly environment
162 # variables, default compilers/linkers, architecture,
163 # system libraries used etc. If you are unsure, go with UCRT64.
164 set(WIRESHARK_TARGET_PLATFORM x64)
166 if($ENV{MSYSTEM_CARCH} MATCHES "x86_64")
167 set(WIRESHARK_TARGET_PLATFORM x64)
168 elseif($ENV{MSYSTEM_CARCH} MATCHES "i686")
169 set(WIRESHARK_TARGET_PLATFORM win32)
170 elseif($ENV{MSYSTEM_CARCH} MATCHES "aarch64")
171 set(WIRESHARK_TARGET_PLATFORM "arm64")
173 set(WIRESHARK_TARGET_PLATFORM "$ENV{MSYSTEM_CARCH}")
175 elseif($ENV{Platform} MATCHES arm64 OR CMAKE_GENERATOR_PLATFORM MATCHES arm64)
176 set(WIRESHARK_TARGET_PLATFORM arm64)
177 elseif(CMAKE_CL_64 OR CMAKE_GENERATOR MATCHES x64)
178 set(WIRESHARK_TARGET_PLATFORM x64)
180 message(WARNING "Assuming \"x64\" target platform")
181 set(WIRESHARK_TARGET_PLATFORM x64)
184 if(WIRESHARK_TARGET_PLATFORM MATCHES "win32")
185 message(FATAL_ERROR "Deprecated target platform ${WIRESHARK_TARGET_PLATFORM}. See https://gitlab.com/wireshark/wireshark/-/issues/17779 for details.")
186 elseif(NOT (WIRESHARK_TARGET_PLATFORM MATCHES "x64" OR WIRESHARK_TARGET_PLATFORM MATCHES "arm64"))
187 message(FATAL_ERROR "Invalid target platform: ${WIRESHARK_TARGET_PLATFORM}")
191 if(MSVC AND DEFINED ENV{PLATFORM})
192 string(TOLOWER $ENV{PLATFORM} _vs_platform)
194 (_vs_platform STREQUAL "x64" AND NOT WIRESHARK_TARGET_PLATFORM STREQUAL "x64")
196 (_vs_platform STREQUAL "arm64" AND NOT WIRESHARK_TARGET_PLATFORM STREQUAL "arm64")
198 message(FATAL_ERROR "The PLATFORM environment variable (${_vs_platform})"
199 " doesn't match the generator platform (${WIRESHARK_TARGET_PLATFORM})")
204 "Building for ${WIRESHARK_TARGET_PLATFORM}"
207 if(NOT CMAKE_CROSSCOMPILING)
208 find_package(PowerShell REQUIRED)
211 # Determine where the 3rd party libraries will be
213 if( DEFINED ENV{WIRESHARK_LIB_DIR} )
214 # The buildbots set WIRESHARK_LIB_DIR but not WIRESHARK_BASE_DIR.
215 file( TO_CMAKE_PATH "$ENV{WIRESHARK_LIB_DIR}" _PROJECT_LIB_DIR )
216 elseif( DEFINED ENV{WIRESHARK_BASE_DIR} )
217 file( TO_CMAKE_PATH "$ENV{WIRESHARK_BASE_DIR}" _WS_BASE_DIR )
218 set( _PROJECT_LIB_DIR "${_WS_BASE_DIR}/wireshark-${WIRESHARK_TARGET_PLATFORM}-libs" )
220 # Don't know what to do
221 message(FATAL_ERROR "Neither WIRESHARK_BASE_DIR or WIRESHARK_LIB_DIR are defined")
224 # Download third-party libraries
225 file (TO_NATIVE_PATH ${CMAKE_SOURCE_DIR}/tools/win-setup.ps1 _win_setup)
226 file (TO_NATIVE_PATH ${_PROJECT_LIB_DIR} _ws_lib_dir)
227 file (TO_NATIVE_PATH ${CMAKE_COMMAND} _win_cmake_command)
229 # Is it possible to have a one-time, non-cached option in CMake? If
230 # so, we could add a "-DFORCE_WIN_SETUP" which passes -Force to
233 COMMAND ${POWERSHELL_COMMAND} "\"${_win_setup}\"" -Destination "${_ws_lib_dir}" -Platform ${WIRESHARK_TARGET_PLATFORM} -CMakeExecutable "\"${_win_cmake_command}\""
234 RESULT_VARIABLE _win_setup_failed
235 ERROR_VARIABLE _win_setup_error_output
237 if(_win_setup_failed)
238 message(FATAL_ERROR "Windows setup (win-setup.ps1) failed: ${_win_setup_error_output}.")
241 set(EXTRA_INSTALLER_DIR ${_ws_lib_dir})
243 # XXX Add a dependency on ${_ws_lib_dir}/current_tag.txt?
245 set(EXTRA_INSTALLER_DIR ${CMAKE_BINARY_DIR}/packaging/nsis)
248 include(FetchContent)
249 set(LIBS_URL "https://dev-libs.wireshark.org/windows/packages")
250 file(TO_CMAKE_PATH ${EXTRA_INSTALLER_DIR} _file_download_dir)
252 # Download Npcap required by the Windows installer
253 set(NPCAP_VERSION "1.80")
254 set(NPCAP_SHA256 "ac4f26d7d9f994d6f04141b2266f02682def51af63c09c96a7268552c94a6535")
255 set(NPCAP_FILENAME "npcap-${NPCAP_VERSION}.exe")
256 set(NPCAP_URL "${LIBS_URL}/Npcap/${NPCAP_FILENAME}")
257 FetchContent_Declare(Npcap
259 DOWNLOAD_DIR ${_file_download_dir}
260 URL_HASH SHA256=${NPCAP_SHA256}
261 DOWNLOAD_NO_EXTRACT True
264 # Download USBPcap required by the Windows installer
265 set(USBPCAP_VERSION "1.5.4.0")
266 set(USBPCAP_SHA256 "87a7edf9bbbcf07b5f4373d9a192a6770d2ff3add7aa1e276e82e38582ccb622")
267 set(USBPCAP_FILENAME "USBPcapSetup-${USBPCAP_VERSION}.exe")
268 set(USBPCAP_URL "${LIBS_URL}/USBPcap/${USBPCAP_FILENAME}")
269 FetchContent_Declare(USBPcap
271 DOWNLOAD_DIR ${_file_download_dir}
272 URL_HASH SHA256=${USBPCAP_SHA256}
273 DOWNLOAD_NO_EXTRACT True
277 include(UseCustomIncludes)
278 ADD_CUSTOM_CMAKE_INCLUDE()
280 # Ensure that all executables and libraries end up in the same directory. Actual
281 # files might end up in a configuration subdirectory, e.g. run/Debug or
282 # run/Release. We try to set DATAFILE_DIR to actual location below.
283 if(NOT ARCHIVE_OUTPUT_PATH)
284 set(ARCHIVE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/run CACHE INTERNAL
285 "Single output directory for building all archives.")
287 if(NOT EXECUTABLE_OUTPUT_PATH)
288 set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/run CACHE INTERNAL
289 "Single output directory for building all executables.")
291 if(NOT LIBRARY_OUTPUT_PATH)
292 set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/run CACHE INTERNAL
293 "Single output directory for building all libraries.")
297 # The release mode (CMAKE_BUILD_TYPE=release) defines NDEBUG for
298 # the Unix Makefile generator.
301 # Defines CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_DATADIR, etc ...
302 if(WIN32 AND NOT USE_MSYSTEM)
303 # Override some values on Windows, to match the existing
304 # convention of installing everything to a single root folder.
305 set(CMAKE_INSTALL_BINDIR ".")
306 set(CMAKE_INSTALL_LIBDIR ".")
307 set(CMAKE_INSTALL_INCLUDEDIR "include")
308 set(CMAKE_INSTALL_DATADIR ".")
309 set(CMAKE_INSTALL_DOCDIR ".")
311 include(GNUInstallDirs)
313 set(PROJECT_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}")
315 # Make sure our executables can load our libraries if we install into
316 # a non-default directory on Unix-like systems other than macOS.
317 # https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
318 set(LIBRARY_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}")
319 set(EXECUTABLE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}")
320 set(EXTCAP_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}")
321 if(NOT (WIN32 OR APPLE OR USE_STATIC))
322 # Try to set a RPATH for installed binaries if the library directory is
323 # not already included in the default search list.
324 list(FIND CMAKE_C_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_FULL_LIBDIR}" IS_SYSTEM_DIR)
325 if(IS_SYSTEM_DIR EQUAL -1)
326 # Some systems support $ORIGIN in RPATH to enable relocatable
327 # binaries. In other cases, only absolute paths can be used.
328 # https://www.lekensteyn.nl/rpath.html
330 # Also note that some systems (notably those using GNU libc)
331 # silently ignore $ORIGIN in RPATH for binaries that are
332 # setuid root or use privileged capabilities.
334 if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|SunOS|FreeBSD)$")
335 set(_enable_rpath_origin TRUE)
337 set(_enable_rpath_origin FALSE)
340 # Provide a knob to optionally force absolute rpaths,
341 # to support old/buggy systems and as a user preference
343 # XXX Should this be a CMake option?
344 set(ENABLE_RPATH_ORIGIN ${_enable_rpath_origin} CACHE BOOL
345 "Use $ORIGIN with INSTALL_RPATH")
346 mark_as_advanced(ENABLE_RPATH_ORIGIN)
348 if(ENABLE_RPATH_ORIGIN)
349 set(LIBRARY_INSTALL_RPATH "$ORIGIN")
350 set(EXECUTABLE_INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
351 set(EXTCAP_INSTALL_RPATH "$ORIGIN/../..")
353 set(LIBRARY_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
354 set(EXECUTABLE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
355 set(EXTCAP_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
357 # Include non-standard external libraries by default in RPATH.
358 if(NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH)
359 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
364 # Ensure that executables in the build directory always have the same RPATH.
365 # This ensures relocatable binaries and reproducible builds (invariant of the
366 # build directory location). (Requires CMake 3.14)
367 set(CMAKE_BUILD_RPATH_USE_ORIGIN ON)
370 # Linking with wsetargv.obj enables "wildcard expansion" of
371 # command-line arguments.
372 set(WILDCARD_OBJ wsetargv.obj)
375 include(CheckSymbolExists)
378 # Large file support on UN*X, a/k/a LFS.
380 # On Windows, we require _fseeki64() and _ftelli64(). Visual
381 # Studio has had supported them since Visual Studio 2005/MSVCR80,
382 # and we require newer versions, so we know we have them.
388 # Add the required #defines.
390 add_definitions(${LFS_DEFINITIONS})
394 # Check for fseeko as well.
401 # Add the required #defines.
403 add_definitions(${FSEEKO_DEFINITIONS})
407 # Banner shown at top right of Qt welcome screen.
408 if(DEFINED ENV{WIRESHARK_VERSION_FLAVOR})
409 set(VERSION_FLAVOR "$ENV{WIRESHARK_VERSION_FLAVOR}")
411 set(VERSION_FLAVOR "Development Build")
414 # Used in .rc files and manifests
415 set(MANIFEST_PROCESSOR_ARCHITECTURE ${WIRESHARK_TARGET_PLATFORM})
416 if (MANIFEST_PROCESSOR_ARCHITECTURE MATCHES "x64")
417 set(MANIFEST_PROCESSOR_ARCHITECTURE "amd64")
419 set(RC_VERSION ${PROJECT_MAJOR_VERSION},${PROJECT_MINOR_VERSION},${PROJECT_PATCH_VERSION},${PROJECT_BUILD_VERSION})
420 set(STRATOSHARK_RC_VERSION ${STRATOSHARK_MAJOR_VERSION},${STRATOSHARK_MINOR_VERSION},${PROJECT_PATCH_VERSION},${STRATOSHARK_BUILD_VERSION})
422 message(STATUS "V: ${PROJECT_VERSION}, MaV: ${PROJECT_MAJOR_VERSION}, MiV: ${PROJECT_MINOR_VERSION}, PL: ${PROJECT_PATCH_VERSION}, EV: ${PROJECT_VERSION_EXTENSION}.")
425 include(UseMakePluginReg)
427 include(UseExecutableResources)
430 # The following snippet has been taken from
431 # https://github.com/USESystemEngineeringBV/cmake-eclipse-helper/wiki/HowToWorkaroundIndexer
432 # The eclipse indexer otherwise assumes __cplusplus=199711L which will lead to broken
433 # lookup tables for the epan libraries
434 # Check if CXX flags have been set to c++11 -> Setup Eclipse Indexer correctly!
435 # Also setup the project slightly different
436 if(CMAKE_EXTRA_GENERATOR MATCHES "Eclipse CDT4")
438 LIST(LENGTH CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS LIST_LEN)
439 if(LIST_LEN GREATER 0)
443 LIST(LENGTH CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS LIST_LEN)
444 if(LIST_LEN GREATER 0)
447 if(C_ENABLED EQUAL 1 AND CXX_ENABLED EQUAL 1)
448 # Combined project (C and CXX). This will confuse the indexer. For that reason
449 # we unsert set the __cplusplus variable for the indexer
450 list(FIND CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS "__cplusplus" GEN_MACRO_INDEX)
451 if(GEN_MACRO_INDEX GREATER -1)
452 list(REMOVE_AT CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${GEN_MACRO_INDEX})
453 list(REMOVE_AT CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${GEN_MACRO_INDEX})
455 SET(CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS} CACHE INTERNAL "")
456 elseif((CXX_ENABLED EQUAL 1) AND (CMAKE_CXX_FLAGS MATCHES ".*-std=c\\+\\+11.*"))
457 #add_definitions (-D__cplusplus=201103L)
458 # CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS
459 list(FIND CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS "199711L" GEN_MACRO_INDEX)
460 if(GEN_MACRO_INDEX GREATER -1)
461 list(REMOVE_AT CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${GEN_MACRO_INDEX})
462 list(INSERT CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${GEN_MACRO_INDEX} "201103L")
463 SET(CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS} CACHE INTERNAL "")
471 ${CMAKE_SOURCE_DIR}/include
474 if( DUMPCAP_INSTALL_OPTION STREQUAL "suid" )
475 set( DUMPCAP_SETUID "SETUID" )
477 set( DUMPCAP_SETUID )
479 if( NOT CMAKE_SYSTEM_NAME STREQUAL "Linux" AND
480 DUMPCAP_INSTALL_OPTION STREQUAL "capabilities" )
481 message( WARNING "Capabilities are only supported on Linux" )
482 set( DUMPCAP_INSTALL_OPTION )
485 set(OSS_FUZZ OFF CACHE BOOL "Whether building for oss-fuzz")
486 mark_as_advanced(OSS_FUZZ)
489 # In oss-fuzz mode, the fuzzing engine can be afl or libFuzzer.
490 message(FATAL_ERROR "Cannot force libFuzzer when using oss-fuzz")
492 # Must not depend on external dependencies so statically link all libs.
497 set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
501 # Linking can consume a lot of memory, especially when built with ASAN and
502 # static libraries (like oss-fuzz) or Debug mode. With Ninja, the number of
503 # parallel linker processes is constrained by job parallelism (-j), but this can
504 # be reduced further by setting "job pools" to a lower number.
506 if(CMAKE_MAKE_PROGRAM MATCHES "ninja" AND OSS_FUZZ)
507 # Assume oss-fuzz linker jobs do not require more than 1.2G per task
508 set(per_job_memory_mb 1200)
509 cmake_host_system_information(RESULT total_memory_mb QUERY TOTAL_PHYSICAL_MEMORY)
510 math(EXPR parallel_link_jobs "${total_memory_mb} / ${per_job_memory_mb}")
511 if(parallel_link_jobs LESS 1)
512 set(parallel_link_jobs 1)
514 set_property(GLOBAL APPEND PROPERTY JOB_POOLS link_job_pool=${parallel_link_jobs})
515 set(CMAKE_JOB_POOL_LINK link_job_pool)
516 message(STATUS "Ninja job pool size: ${parallel_link_jobs}")
519 # Always enable position-independent code when compiling, even for
520 # executables, so you can build position-independent executables.
521 # -pie is added below for non-MSVC, but requires objects to be built with
522 # -fPIC/-fPIE (so set CMAKE_POSITION_INDEPENDENT_CODE to enable that).
523 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
525 # Preprocessor definitions common to all compilers
526 set_property(DIRECTORY
527 PROPERTY COMPILE_DEFINITIONS
528 "G_DISABLE_DEPRECATED"
529 "G_DISABLE_SINGLE_INCLUDES"
530 $<$<OR:$<BOOL:${ENABLE_DEBUG}>,$<CONFIG:Debug>>:WS_DEBUG>
531 $<$<OR:$<AND:$<BOOL:${ENABLE_DEBUG}>,$<BOOL:${ENABLE_DEBUG_UTF_8}>>,$<CONFIG:Debug>>:WS_DEBUG_UTF_8>
532 $<$<BOOL:${ENABLE_ASSERT}>:ENABLE_ASSERT>
537 # NOTE: Because of the way Qt moc is including "config.h" (not as the
538 # first header) this *MUST* be defined on the command line to precede
539 # every included header and not trigger symbol redefinition errors.
542 -DWIN32_LEAN_AND_MEAN
544 # Use Unicode in Windows runtime functions.
549 # NOMINMAX keeps windows.h from defining "min" and "max" via windef.h.
550 # This avoids conflicts with the C++ standard library.
559 # Enable POSIX APIs. This will switch stdio to ANSI C functions and
560 # enable C99 conformant vsnprintf() among other things.
564 list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_POSIX)
567 if( CMAKE_C_COMPILER_ID MATCHES "MSVC")
568 if (MSVC_VERSION LESS "1928")
569 message(FATAL_ERROR "Microsoft Visual Studio 2019 version 16.8 or later is required")
571 if (MSVC_VERSION GREATER_EQUAL "2000")
572 message(FATAL_ERROR "You are using an unsupported version of MSVC")
576 /D_CRT_SECURE_NO_DEPRECATE
577 # -DPSAPI_VERSION=1 Programs that must run on earlier versions of Windows as well as Windows 7 and later
578 # versions should always call this function as GetProcessMemoryInfo. To ensure correct
579 # resolution of symbols, add Psapi.lib to the TARGETLIBS macro and compile the program
580 # with -DPSAPI_VERSION=1.To use run-time dynamic linking, load Psapi.dll.
581 # https://docs.microsoft.com/en-us/windows/win32/api/psapi/nf-psapi-getprocessmemoryinfo
582 # -D_ALLOW_KEYWORD_MACROS For VS2012 onwards the, C++ STL does not permit macro redefinitions of keywords
583 # (see https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/bb531344(v=vs.110))
584 # This definition prevents the complaint about the redefinition of inline by WinPCap
585 # in pcap-stdinc.h when compiling C++ files, e.g. the Qt UI
587 /D_ALLOW_KEYWORD_MACROS
588 # Disable deprecation of POSIX function names.
589 # https://stackoverflow.com/questions/37845163/what-is-the-purpose-of-microsofts-underscore-c-functions
590 /D_CRT_NONSTDC_NO_WARNINGS
593 if(NOT WIRESHARK_TARGET_PLATFORM STREQUAL "x64")
594 add_definitions("/D_BIND_TO_CURRENT_CRT_VERSION=1")
597 # TODO: Re-enable /W3. It was disabled for a year and some warnings crept
598 # in that will fail with /Wx.
604 set(WS_LINK_FLAGS "/LARGEADDRESSAWARE /MANIFEST:NO /INCREMENTAL:NO /RELEASE")
606 # To do: Add /external:... See https://devblogs.microsoft.com/cppblog/broken-warnings-theory/
608 # /diagnostics:caret Place a caret under compilation issues similar to
610 # /Zo Enhanced debugging of optimised code
611 # /utf-8 Set Source and Executable character sets to UTF-8
612 # VS2015(MSVC14): On by default when /Zi or /Z7 used.
613 # /guard:cf Control Flow Guard (compile and link).
614 # See https://docs.microsoft.com/en-us/windows/win32/secbp/control-flow-guard
615 # Note: This requires CMake 3.9.0 or newer.
616 # https://gitlab.kitware.com/cmake/cmake/commit/f973d49ab9d4c59b93f6dac812a94bb130200836
617 # /Qspectre Speculative execution attack mitigation
618 # See https://devblogs.microsoft.com/cppblog/spectre-mitigations-in-msvc/
619 list(APPEND LOCAL_CFLAGS /diagnostics:caret /Zo /utf-8 /guard:cf)
620 set(WS_LINK_FLAGS "${WS_LINK_FLAGS} /guard:cf")
621 set(WS_LINK_FLAGS "${WS_LINK_FLAGS} /STACK:0x800000")
622 # /Qspectre depends on the optional "Microsoft.VisualStudio.Component...Spectre" components,
623 # so we need to test for its availability.
624 set(WIRESHARK_COMMON_FLAGS /Qspectre)
626 if(ENABLE_CODE_ANALYSIS)
627 # We should probably add a code_analysis.props file and use it to set
628 # CAExcludePath, otherwise we trigger on Qt's headers:
629 # https://stackoverflow.com/questions/59669026/how-to-add-property-to-affect-code-analysis-in-cmake
630 # https://gitlab.kitware.com/cmake/cmake/-/issues/19682
631 # For now, we set CAExcludePath=C:\Qt;%include% in the Visual Studio
632 # Code Analys builder's environment.
633 list(APPEND LOCAL_CFLAGS
635 /analyze:log:format:sarif
639 # Additional compiler warnings to be treated as "Level 3"
640 # when compiling Wireshark sources. (Selected from "level 4" warnings).
641 ## 4295: array is too small to include a terminating null character
642 ## 4100: unreferenced formal parameter
643 ## 4189: local variable is initialized but not referenced
644 # Disable warnings about use of flexible array members:
645 ## 4200: nonstandard extension used : zero-sized array in struct/union
646 list(APPEND LOCAL_CFLAGS /w34295 /w34100 /w34189 /wd4200)
648 # MSVC 14.28 + C11 enables C5105, but older Windows SDKs aren't completely compatible.
649 # Windows SDK 10.0.17763.0 generates syntax errors with C11 enabled.
650 # The variable CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION does not work with the Ninja generator. Presumably it requires a VS generator.
651 if (CMAKE_GENERATOR MATCHES "Visual Studio")
652 if (CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION VERSION_LESS 10.0.18362.0)
653 message(FATAL_ERROR "Windows SDK ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION} doesn't support C11. Please make sure you're using 10.0.20348.0 or later.")
655 # Windows SDK 10.0.18362.0 to 10.0.19041.685 generate warning C5105 with C11 enabled.
656 if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION VERSION_LESS 10.0.20348.0)
657 message(WARNING "Windows SDK ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION} doesn't support C11. Please make sure you're using 10.0.20348.0 or later.")
658 ## 5105: macro expansion producing 'defined' has undefined behavior
659 list(APPEND LOCAL_CFLAGS /wd5105)
663 # We've matched these to specific compiler versions using the
664 # checks above. There's no need to pass them to check_c_compiler_flag
665 # or check_cxx_compiler_flag, which can be slow.
666 string(REPLACE ";" " " _flags "${LOCAL_CFLAGS}")
667 set(CMAKE_C_FLAGS "${_flags} ${CMAKE_C_FLAGS}")
668 set(CMAKE_CXX_FLAGS "${_flags} ${CMAKE_CXX_FLAGS}")
672 # MIN_MACOS_VERSION is used to set LSMinimumSystemVersion
673 # in Info.plist, so start with something low.
674 set(MIN_MACOS_VERSION 10.13)
675 if(CMAKE_OSX_DEPLOYMENT_TARGET)
676 if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS MIN_MACOS_VERSION)
677 message(FATAL_ERROR "We don't support building for macOS < ${MIN_MACOS_VERSION}")
679 set(MIN_MACOS_VERSION ${CMAKE_OSX_DEPLOYMENT_TARGET})
684 # NOTE: Adding new warnings is a policy decision that can have far-reaching
685 # implications for the project and each developers workflow. Modern
686 # C compilers are on a race to add new warnings, not always sensibly.
687 # They are opt-in so take a moment to fully consider the implications
688 # of enabling the latest shiny new warning.
689 # If in doubt ask on the Wireshark developer list (recommended).
691 list(APPEND WIRESHARK_COMMON_FLAGS
693 ### Flags common to C and C++ ###
695 # -O<X> and -g get set by the CMAKE_BUILD_TYPE
700 -Wtrampolines # Enable warnings about trampolines that require executable stacks
704 -fexcess-precision=fast # GCC-only
707 -Wpragmas # Clang-only
708 -Wheader-guard # Clang-only
710 -Wshorten-64-to-32 # Clang-only
712 -Wunreachable-code # Clang-only
713 -Wdocumentation # Clang-only
714 -Wlogical-op # GCC-only
716 # Run-time protections mechanisms
717 -fstrict-flex-arrays=3 # Consider a trailing array in a struct as a flexible array if declared as []
718 -fstack-clash-protection # Increased reliability of stack overflow detection
719 -fcf-protection=full # Enable control flow protection to counter Return Oriented Programming (ROP) and Jump Oriented Programming (JOP) attacks on many x86 architectures
720 -mbranch-protection=standard # Enable branch protection to counter Return Oriented Programming (ROP) and Jump Oriented Programming (JOP) attacks on AArch64
721 -D_GLIBCXX_ASSERTIONS # Precondition checks for C++ standard library calls. Can impact performance.
722 -fstack-protector-strong # Stack smashing protector
723 -fno-delete-null-pointer-checks # Force retention of null pointer checks
724 # The above used to fail on macOS El Capitan clang (see below in PEDANTIC) Does it work now?
725 -fno-strict-overflow # Defines signed overflow as wrapping on gcc and clang, prevents optimizations that assume overflow never happens
726 -fno-strict-aliasing # Do not assume strict aliasing
727 -ftrivial-auto-var-init # Perform trivial auto variable initialization
728 -fexceptions # Enable exception propagation to harden multi-threaded C code
731 # Disable errors unconditionally for some static analysis warnings
732 # that are dormant at lower optimizations levels or active only in
733 # bleeding edge versions of a compiler and possibly also
734 # prone to false positives and compiler bugs. This is
735 # a big nuisance because the warning is dormant and a low
736 # priority target for action. That is very disruptive
737 # with -Werror enabled (the default on the master branch).
739 #-Wno-error=stringop-overflow=
741 # XXX Now that we have a CI job with Release build type (using
742 # -O3 optimization level) the dormancy issue should be ameliorated
743 # so comment out these exceptions to re-evaluate the impact.
744 #-Wno-error=maybe-uninitialized
745 #-Wno-error=alloc-size-larger-than=
747 # Updating external dependencies can introduce new deprecations.
748 # Also fixing new internal deprecations takes time.
749 # We want to be able to build with -Werror in that case. New
750 # code should not introduce new deprecations in any case.
752 #-Wno-error=deprecated-declarations
755 if (CMAKE_C_COMPILER_ID MATCHES "Clang")
756 # Avoid "argument unused during compilation" warnings for
757 # -fstack-clash-protection and -mbranch-protection=standard
758 list(APPEND WIRESHARK_COMMON_FLAGS -Qunused-arguments)
761 if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
762 # _FORTIFY_SOURCE requires -O1 or higher, and the Debug
763 # build type has no optimization
764 if((CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "12.0") OR
765 (CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "9.0"))
766 # On some gcc < 12.0, test_compiler_flag will report that
767 # -D_FORTIFY_SOURCE=3 is valid, but actually trying to compile
768 # with it will give a warning that it has the same effect as
769 # -D_FORTIFY_SOURCE=2
770 list(APPEND WIRESHARK_COMMON_FLAGS
771 -U_FORTIFY_SOURCE # Run-time buffer overflow detection. For dist like Ubuntu, U_FORTIFY_SOURCE must be input before D_FORTIFY_SOURCE
772 -D_FORTIFY_SOURCE=3 # Fortify sources with compile- and run-time checks for unsafe libc usage and buffer overflows. Requires -O1 or higher
777 # test_compiler_flag doesn't seem to test that a flag is supported on
778 # a cross-compiled target, only for the native architecture. (Thus
779 # conversely it does work to verify that -mbranch-protection=standard
780 # doesn't work on x64 when compiling natively.)
781 # TODO: Check that this approach works.
782 #if(NOT CMAKE_CROSSCOMPILING)
783 # list(APPEND WIRESHARK_COMMON_FLAGS
784 # -fhardened # Enable pre-determined set of hardening options in GCC. Currently, -fhardened is only supported on GNU/Linux targets
788 if((NOT ENABLE_ASAN) AND (NOT ENABLE_TSAN) AND (NOT ENABLE_UBSAN) AND (NOT DISABLE_FRAME_LARGER_THAN_WARNING))
790 # Only do this if none of ASan, TSan, and UBSan are
791 # enabled; the instrumentation they add increases
792 # the stack usage - we only care about stack
793 # usage in normal operation.
795 list(APPEND WIRESHARK_COMMON_FLAGS
796 -Wframe-larger-than=32768
800 list(APPEND WIRESHARK_C_ONLY_FLAGS
802 ### Flags for C only ###
805 # XXX - some versions of GCC, including the one in at
806 # least some Xcode versions that come with Mac OS X
807 # 10.5, complain about variables in function and
808 # function pointer *declarations* shadowing other
809 # variables. The autoconf script checked for that; we
812 -Wold-style-definition
814 -Wincompatible-pointer-types
819 # The universal zero initializer (in C: struct s x = { 0 };) for
820 # structures with multiple members is perfectly legal, but some older
821 # compilers warn about it. Silence those older compilers.
823 if((CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "5.1") OR
824 (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "6.0") OR
825 (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "12.0"))
826 if(NOT CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_VERSION VERSION_LESS "5.0")
827 list(APPEND WIRESHARK_C_ONLY_FLAGS -Wno-missing-field-initializers)
829 # Silence warnings for initialization of nested structs like
830 # struct { struct { int a, b; } s; int c; } v = { 0 };
831 list(APPEND WIRESHARK_C_ONLY_FLAGS -Wno-missing-braces)
834 list(APPEND WIRESHARK_CXX_ONLY_FLAGS
836 ### Flags for C++ only ###
838 -Wextra-semi # Clang-only
842 # Not all warnings are the same. They fall on a spectrum from "critical"
843 # to "pedantic nonsense". These are warnings that realistically are worth
845 # TODO https://gitlab.com/wireshark/wireshark/-/issues/19995
847 if(ENABLE_TODO_WARNINGS)
848 list(APPEND WIRESHARK_COMMON_FLAGS
850 # All the registration functions block these for now.
853 -Wmissing-declarations
858 # A bunch of "that might not work on SPARC" code blocks
859 # this one for now; some of it is code that *will* work
860 # on SPARC, such as casts of "struct sockaddr *" to
861 # "struct sockaddr_in *", which are required by some
862 # APIs such as getifaddrs().
867 list(APPEND WIRESHARK_COMMON_FLAGS
869 # Converting from g_printf() and g_snprintf() to stdio.h turns
870 # up many of these warnings. They will have to be handled later.
871 # It can be a lot of work to fix properly and none of them
872 # seem to flag very interesting issues.
874 -Wno-format-truncation # Enabled with -Wall
876 -Wno-format-nonliteral # Enabled with -Wformat=2
878 list(APPEND WIRESHARK_C_ONLY_FLAGS
879 -Wno-pointer-sign # Enabled with -Wall
884 # These are not enabled by default, because the warnings they
885 # produce are very hard or impossible to eliminate.
887 if(ENABLE_PEDANTIC_COMPILER_WARNINGS)
888 list(APPEND WIRESHARK_COMMON_FLAGS
889 # The following are for C and C++
891 -Wno-overlength-strings
894 # As we use variadic macros, we don't want warnings
895 # about them, even with -Wpedantic.
899 # Various code blocks this one.
902 -fstrict-overflow -Wstrict-overflow=4
904 # Due to various places where APIs we don't control
905 # require us to cast away constness, we can probably
906 # never enable this one with -Werror.
910 # Doesn't warn of interesting issues. Usually the
911 # duplicated branches are protocol constants that
912 # happen to be equal and are relevant for documentation
913 # and readability and are trivially optimized by the
916 -Wduplicated-branches # GCC-only
918 # No longer supported by El Capitan clang on C++
919 # XXX - is this one of those where CMake's check
920 # doesn't fail, so it won't reject this?
922 -fno-delete-null-pointer-checks
926 # Some loops are safe, but it's hard to convince the compiler of
927 # that. Always disable the warning on GCC 7 due to a bug that
928 # cause lots of false positives.
929 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81408
931 if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION MATCHES "^7\\.")
932 list(APPEND WIRESHARK_COMMON_FLAGS -Wunsafe-loop-optimizations)
935 list(APPEND WIRESHARK_C_ONLY_FLAGS
936 # The following are C only, not C++
938 # Due to various places where APIs we don't control
939 # require us to cast away constness, we can probably
940 # never enable this one with -Werror.
945 list(APPEND WIRESHARK_CXX_ONLY_FLAGS
949 if(ENABLE_COMPILER_COLOR_DIAGNOSTICS)
950 if(CMAKE_C_COMPILER_ID MATCHES "Clang")
951 set(WIRESHARK_COMMON_FLAGS ${WIRESHARK_COMMON_FLAGS}
954 elseif(CMAKE_C_COMPILER_ID MATCHES "GNU")
955 set(WIRESHARK_COMMON_FLAGS ${WIRESHARK_COMMON_FLAGS}
956 -fdiagnostics-color=always
961 set(WIRESHARK_LD_FLAGS
962 # See also CheckCLinkerFlag.cmake
970 # Counterhack to work around some cache magic in CHECK_C_SOURCE_COMPILES
971 include(CheckCCompilerFlag)
972 include(CheckCXXCompilerFlag)
975 set(BUILD_SHARED_LIBS 0)
977 set(BUILD_SHARED_LIBS 1)
980 function(test_compiler_flag _lang _this_flag _valid_flags_var)
981 string(MAKE_C_IDENTIFIER "${_lang}${_this_flag}_VALID" _flag_var)
982 set(_test_flags "${${_valid_flags_var}} ${_this_flag}")
983 if(_lang STREQUAL "C")
984 check_c_compiler_flag("${_test_flags}" ${_flag_var})
985 elseif(_lang STREQUAL "CXX")
986 check_cxx_compiler_flag("${_test_flags}" ${_flag_var})
988 message(FATAL_ERROR "Language must be C or CXX")
991 set(${_valid_flags_var} "${_test_flags}" PARENT_SCOPE)
995 foreach(THIS_FLAG ${WIRESHARK_COMMON_FLAGS} ${WIRESHARK_C_ONLY_FLAGS})
996 test_compiler_flag(C ${THIS_FLAG} ADDED_CMAKE_C_FLAGS)
998 set(CMAKE_C_FLAGS "${ADDED_CMAKE_C_FLAGS} ${CMAKE_C_FLAGS}")
1000 foreach(THIS_FLAG ${WIRESHARK_COMMON_FLAGS} ${WIRESHARK_CXX_ONLY_FLAGS})
1001 test_compiler_flag(CXX ${THIS_FLAG} ADDED_CMAKE_CXX_FLAGS)
1003 set(CMAKE_CXX_FLAGS "${ADDED_CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
1005 # Strips the source and build directory prefix from the __FILE__ macro to ensure
1006 # reproducible builds. Supported since GCC 8, Clang support is pending.
1007 if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
1008 # If the build dir is within the source dir, CMake will use something
1009 # like ../epan/dfilter/semcheck.c. Map these relative paths in addition
1010 # to CMAKE_BINARY_DIR since compile_commands.json uses absolute paths.
1011 file(RELATIVE_PATH _relative_source_dir "${CMAKE_BINARY_DIR}" "${CMAKE_SOURCE_DIR}")
1012 string(REGEX REPLACE "/$" "" _relative_source_dir "${_relative_source_dir}")
1014 check_c_compiler_flag(-fmacro-prefix-map=old=new C_fmacro_prefix_map_old_new_VALID)
1015 check_cxx_compiler_flag(-fmacro-prefix-map=old=new CXX_fmacro_prefix_map_old_new_VALID)
1016 foreach(_lang C CXX)
1017 if(${_lang}_fmacro_prefix_map_old_new_VALID)
1018 set(_flags CMAKE_${_lang}_FLAGS)
1019 set(${_flags} "${${_flags}} -fmacro-prefix-map=\"${CMAKE_SOURCE_DIR}/\"=")
1020 set(${_flags} "${${_flags}} -fmacro-prefix-map=\"${CMAKE_BINARY_DIR}/\"=")
1021 if(_relative_source_dir MATCHES "\\.\\.$")
1022 set(${_flags} "${${_flags}} -fmacro-prefix-map=\"${_relative_source_dir}/\"=")
1028 include(CMakePushCheckState)
1031 # Available since MSVC 2019 version 16.9 (https://gitlab.com/wireshark/wireshark/-/merge_requests/14912 for more details)
1032 cmake_push_check_state()
1033 set(ASAN_FLAG "-fsanitize=address")
1034 set(CMAKE_REQUIRED_FLAGS ${ASAN_FLAG})
1036 message(NOTICE "ENABLE_ASAN was requested. Checking if ASAN is supported requires SPECTRE-mitigation to be disabled globally impacting all build types.")
1037 message(NOTICE "If ASAN is supported, then it is re-enabled selectively depending on the build types.")
1038 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Qspectre-")
1039 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Qspectre-")
1041 check_c_compiler_flag(${ASAN_FLAG} C__fsanitize_address_VALID)
1042 check_cxx_compiler_flag(${ASAN_FLAG} CXX__fsanitize_address_VALID)
1043 cmake_pop_check_state()
1044 if(NOT C__fsanitize_address_VALID OR NOT CXX__fsanitize_address_VALID)
1045 message(FATAL_ERROR "ENABLE_ASAN was requested, but not supported!")
1048 message(NOTICE "ASAN is supported.")
1049 if(ENABLE_ASAN_WITH_SPECTRE)
1050 message(NOTICE "ENABLE_ASAN_WITH_SPECTRE was requested.")
1051 message(NOTICE "For Debug and RelWithDebInfo, SPECTRE-mitigation has been re-enabled and ASAN has been enabled too.")
1052 add_compile_options("$<$<CONFIG:Debug>:/Qspectre>" "$<$<CONFIG:Debug>:${ASAN_FLAG}>")
1053 add_compile_options("$<$<CONFIG:RelWithDebInfo>:/Qspectre>" "$<$<CONFIG:RelWithDebInfo>:${ASAN_FLAG}>")
1054 set(CPU ${WIRESHARK_TARGET_PLATFORM})
1055 if (${CPU} MATCHES "win32")
1058 add_link_options("$<$<CONFIG:Debug>:/libpath:$ENV{VCToolsInstallDir}lib\\spectre\\${CPU}>" "$<$<CONFIG:Debug>:/libpath:$ENV{VCToolsInstallDir}lib\\${CPU}>")
1059 add_link_options("$<$<CONFIG:RelWithDebInfo>:/libpath:$ENV{VCToolsInstallDir}lib\\spectre\\${CPU}>" "$<$<CONFIG:RelWithDebInfo>:/libpath:$ENV{VCToolsInstallDir}lib\\${CPU}>")
1061 message(NOTICE "ENABLE_ASAN_WITH_SPECTRE was not requested")
1062 message(NOTICE "For Debug and RelWithDebInfo, SPECTRE-mitigation stays disabled and ASAN has been enabled.")
1063 add_compile_options("$<$<CONFIG:Debug>:${ASAN_FLAG}>")
1064 add_compile_options("$<$<CONFIG:RelWithDebInfo>:${ASAN_FLAG}>")
1066 message(NOTICE "For Release and MinSizeRel, SPECTRE-mitigation has been re-enabled and ASAN has been skipped.")
1067 add_compile_options("$<$<CONFIG:Release>:/Qspectre>")
1068 add_compile_options("$<$<CONFIG:MinSizeRel>:/Qspectre>")
1070 add_compile_options(${ASAN_FLAG})
1073 # Using ASAN makes some of our code require object files with
1074 # a 32-bit index to the section table instead of 16-bit.
1075 # This makes the .obj files slightly larger (~2%) and makes
1076 # it so that Microsoft linkers prior to MSVC 2005 can't read
1077 # the files, but those are too old anyway.
1078 add_compile_options(/bigobj)
1079 # The Microsoft LINK linker doesn't recognize or need the
1080 # ASAN flag, and will give a LNK4044 warning.
1082 # Clang/gcc need the flag added to the linker
1083 # add_link_options since CMake 3.13 (our minimum)
1084 add_link_options(${ASAN_FLAG})
1089 if(NOT ENABLE_ASAN AND ENABLE_ASAN_WITH_SPECTRE)
1090 message(FATAL_ERROR "ENABLE_ASAN_WITH_SPECTRE was requested, but without ENABLE_ASAN!")
1095 # Available since Clang >= 3.2 and GCC >= 4.8
1096 cmake_push_check_state()
1097 set(CMAKE_REQUIRED_LIBRARIES "-fsanitize=thread")
1098 check_c_compiler_flag(-fsanitize=thread C__fsanitize_thread_VALID)
1099 check_cxx_compiler_flag(-fsanitize=thread CXX__fsanitize_thread_VALID)
1100 cmake_pop_check_state()
1101 if(NOT C__fsanitize_thread_VALID OR NOT CXX__fsanitize_thread_VALID)
1102 message(FATAL_ERROR "ENABLE_TSAN was requested, but not supported!")
1104 set(CMAKE_C_FLAGS "-fsanitize=thread ${CMAKE_C_FLAGS}")
1105 set(CMAKE_CXX_FLAGS "-fsanitize=thread ${CMAKE_CXX_FLAGS}")
1106 set(WS_LINK_FLAGS "-fsanitize=thread ${WS_LINK_FLAGS}")
1110 # Available since Clang >= 3.3 and GCC >= 4.9
1111 cmake_push_check_state()
1112 set(CMAKE_REQUIRED_LIBRARIES "-fsanitize=undefined")
1113 check_c_compiler_flag(-fsanitize=undefined C__fsanitize_undefined_VALID)
1114 check_cxx_compiler_flag(-fsanitize=undefined CXX__fsanitize_undefined_VALID)
1115 cmake_pop_check_state()
1116 if(NOT C__fsanitize_undefined_VALID OR NOT CXX__fsanitize_undefined_VALID)
1117 message(FATAL_ERROR "ENABLE_UBSAN was requested, but not supported!")
1119 set(CMAKE_C_FLAGS "-fsanitize=undefined ${CMAKE_C_FLAGS}")
1120 set(CMAKE_CXX_FLAGS "-fsanitize=undefined ${CMAKE_CXX_FLAGS}")
1124 # Available since Clang >= 3.4 and GCC >= 4.9
1125 cmake_push_check_state()
1126 set(CMAKE_REQUIRED_LIBRARIES "-fsanitize=leak")
1127 check_c_compiler_flag(-fsanitize=leak C__fsanitize_leak_VALID)
1128 check_cxx_compiler_flag(-fsanitize=leak CXX__fsanitize_leak_VALID)
1129 cmake_pop_check_state()
1130 if(NOT C__fsanitize_leak_VALID OR NOT CXX__fsanitize_leak_VALID)
1131 message(FATAL_ERROR "ENABLE_LSAN was requested, but not supported!")
1133 set(CMAKE_C_FLAGS "-fsanitize=leak ${CMAKE_C_FLAGS}")
1134 set(CMAKE_CXX_FLAGS "-fsanitize=leak ${CMAKE_CXX_FLAGS}")
1138 # Available since Clang >= 6
1139 # Will enable coverage flags which can be used by the fuzzshark target.
1140 cmake_push_check_state()
1141 set(CMAKE_REQUIRED_LIBRARIES "-fsanitize=fuzzer-no-link")
1142 check_c_compiler_flag(-fsanitize=fuzzer C__fsanitize_fuzzer_no_link_VALID)
1143 check_cxx_compiler_flag(-fsanitize=fuzzer CXX__fsanitize_fuzzer_no_link_VALID)
1144 cmake_pop_check_state()
1145 if(NOT C__fsanitize_fuzzer_no_link_VALID OR NOT CXX__fsanitize_fuzzer_no_link_VALID)
1146 message(FATAL_ERROR "ENABLE_FUZZER was requested, but not supported!")
1148 set(CMAKE_C_FLAGS "-fsanitize=fuzzer-no-link ${CMAKE_C_FLAGS}")
1149 set(CMAKE_CXX_FLAGS "-fsanitize=fuzzer-no-link ${CMAKE_CXX_FLAGS}")
1153 # Disable sanitizers for build-time tools, e.g. lemon
1154 check_c_compiler_flag(-fno-sanitize=all C__fno_sanitize_all_VALID)
1155 if(C__fno_sanitize_all_VALID)
1156 set(NO_SANITIZE_CFLAGS "-fno-sanitize=all")
1157 set(NO_SANITIZE_LDFLAGS "-fno-sanitize=all")
1165 message(FATAL_ERROR "ENABLE_VLD was requested, but not found!")
1167 message(STATUS "Enabling Visual Leak Detector in Debug configuration")
1168 set(WS_MSVC_DEBUG_LINK_FLAGS ${VLD_LINK_FLAGS})
1172 set(WERROR_COMMON_FLAGS "")
1174 if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
1175 set(WERROR_COMMON_FLAGS "/WX")
1178 # If a warning has been enabled by -Wall or -W,
1179 # and have specified -Werror, there appears to be
1180 # no way, in Apple's llvm-gcc, to prevent that
1181 # particular warning from giving an error - not
1182 # with a pragma, not with -Wno-{warning}, and not
1183 # with -Wno-error={warning}.
1185 # Therefore, with that compiler, we just disable
1188 if ((NOT APPLE) OR CMAKE_C_COMPILER_ID MATCHES "Clang")
1189 check_c_compiler_flag(-Werror WERROR)
1191 set(WERROR_COMMON_FLAGS "-Werror")
1198 # Try to have the compiler default to hiding symbols, so that only
1199 # symbols explicitly exported with WS_DLL_PUBLIC will be visible
1200 # outside (shared) libraries; that way, more UN*X builds will catch
1201 # failures to export symbols, rather than having that fail only on
1204 # We don't need that with MSVC, as that's the default.
1206 if( NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
1208 # Try the GCC-and-compatible -fvisibility-hidden first.
1210 check_c_compiler_flag(-fvisibility=hidden FVHIDDEN)
1212 set(CMAKE_C_FLAGS "-fvisibility=hidden ${CMAKE_C_FLAGS}")
1215 # OK, try the Sun^WOracle C -xldscope=hidden
1217 check_c_compiler_flag(-xldscope=hidden XLDSCOPEHIDDEN)
1219 set(CMAKE_C_FLAGS "-xldscope=hidden ${CMAKE_C_FLAGS}")
1223 # If there is anything else, we might want to
1224 # make a list of options to try, and try them
1227 message(WARNING "Hiding shared library symbols is not supported by the compiler."
1228 " All shared library symbols will be exported.")
1233 include(CheckCLinkerFlag)
1235 if(NOT CMAKE_C_COMPILER_ID MATCHES "MSVC" AND NOT OSS_FUZZ)
1237 # The -pie linker option produces a position-independent executable.
1238 # Some Linux distributions have this enabled by default in the compiler,
1239 # so setting it here will be superfluous though.
1241 # Note that linking with static libraries that are not position
1242 # independent may fail, the user can set CMAKE_EXE_LINKER_FLAGS=-no-pie
1245 if(CMAKE_VERSION VERSION_LESS "3.14")
1246 check_c_linker_flag(-pie LINK_pie_VALID)
1248 set(CMAKE_EXE_LINKER_FLAGS "-pie ${CMAKE_EXE_LINKER_FLAGS}")
1251 include(CheckPIESupported)
1252 check_pie_supported()
1256 foreach(THIS_FLAG ${WIRESHARK_LD_FLAGS})
1257 string(MAKE_C_IDENTIFIER "LINK${THIS_FLAG}_VALID" _flag_var)
1258 check_c_linker_flag(${THIS_FLAG} ${_flag_var})
1260 set(WS_LINK_FLAGS "${WS_LINK_FLAGS} ${THIS_FLAG}")
1263 message(STATUS "Linker flags: ${WS_LINK_FLAGS}")
1265 if(APPLE AND EXISTS /usr/local/opt/gettext)
1266 # GLib on macOS requires libintl. Homebrew installs gettext (and
1267 # libintl) in /usr/local/opt/gettext
1268 include_directories(SYSTEM /usr/local/opt/gettext/include)
1269 link_directories(/usr/local/opt/gettext/lib)
1272 # Resets cache variables if the <PackageName>_LIBRARY has become invalid.
1273 # Call it before a find_package(<PackageName> ...) invocation that uses
1274 # find_library(<PackageName>_LIBRARY ...).
1276 # Usage: reset_find_package(<PackageName> [<extra variables to clear>])
1277 function(reset_find_package _package_name)
1279 # find_library / find_package
1280 ${_package_name}_LIBRARY
1281 ${_package_name}_INCLUDE_DIR
1283 ${_package_name}_LIBRARIES
1284 ${_package_name}_INCLUDE_DIRS
1286 ${_package_name}_DLL_DIR
1287 ${_package_name}_DLLS
1288 ${_package_name}_DLL
1289 ${_package_name}_PDB
1292 if(NOT ${_package_name}_LIBRARY OR EXISTS ${${_package_name}_LIBRARY})
1293 # Cache variable is already missing or cache entry is valid.
1296 message(STATUS "Package ${_package_name} has changed, clearing cache.")
1297 foreach(_var IN LISTS variables)
1298 unset(${_var} CACHE)
1302 # ws_find_package(<PackageName>
1303 # <CMakeOptions.txt boolean variable>
1304 # <cmakeconfig.h.in macro definition>
1305 # [remaining find_package() arguments])
1306 macro(ws_find_package _package_name _enable_package _package_cmakedefine)
1307 if(${_enable_package})
1308 # Clear outdated cache variables if not already.
1309 reset_find_package(${_package_name})
1310 find_package(${_package_name} ${ARGN})
1311 if(${_package_name}_FOUND)
1312 set(${_package_cmakedefine} 1)
1317 # The minimum package list
1319 reset_find_package(GLIB2 GLIB2_MAIN_INCLUDE_DIR GLIB2_INTERNAL_INCLUDE_DIR)
1320 find_package(GLIB2 "2.54.0" REQUIRED)
1321 include_directories(SYSTEM ${GLIB2_INCLUDE_DIRS})
1322 reset_find_package(GMODULE2)
1323 find_package(GMODULE2)
1324 reset_find_package(GTHREAD2)
1325 find_package(GTHREAD2 REQUIRED)
1326 reset_find_package(GCRYPT GCRYPT_ERROR_LIBRARY)
1327 find_package(GCRYPT "1.8.0" REQUIRED)
1328 # C Asynchronous resolver
1329 reset_find_package(CARES)
1330 find_package(CARES "1.13.0" REQUIRED)
1331 if (CARES_VERSION VERSION_GREATER_EQUAL "1.28.0")
1332 # Suppress deprecation warnings.
1333 add_compile_definitions(CARES_NO_DEPRECATED)
1335 find_package(LEX REQUIRED)
1336 reset_find_package(PCRE2 PCRE2_DEBUG_LIBRARY)
1337 find_package(PCRE2 REQUIRED)
1340 find_package(Gettext)
1341 find_package(M REQUIRED)
1344 if(BUILD_sshdump OR BUILD_ciscodump OR BUILD_wifidump OR BUILD_sshdig)
1345 set(ENABLE_LIBSSH ON)
1347 set(ENABLE_LIBSSH OFF)
1349 ws_find_package(LIBSSH ENABLE_LIBSSH HAVE_LIBSSH "0.8.5")
1351 ws_find_package(PCAP ENABLE_PCAP HAVE_LIBPCAP)
1352 ws_find_package(Systemd BUILD_sdjournal HAVE_SYSTEMD)
1354 # Build one of the Qt GUIs?
1355 if(BUILD_wireshark OR BUILD_stratoshark)
1358 if(DEFINED ENV{WIRESHARK_QT6_PREFIX_PATH})
1359 list(APPEND CMAKE_PREFIX_PATH $ENV{WIRESHARK_QT6_PREFIX_PATH})
1362 set(CMAKE_CXX_STANDARD 17)
1363 # Setting CMAKE_CXX_STANDARD is not sufficient with MSVC, see
1364 # https://gitlab.kitware.com/cmake/cmake/-/issues/18837
1365 # The below test can be found in Qt6, lib/cmake/Qt6/QtFeature.cmake
1366 if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND MSVC_VERSION GREATER_EQUAL 1913)
1367 # Cannot use add_definitions() here because rc.exe does not understand this flag.
1368 # https://cmake.org/pipermail/cmake/2009-August/031672.html
1369 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Zc:__cplusplus")
1372 find_package(Qt6 REQUIRED
1386 if (WIN32 AND Qt6Widgets_VERSION VERSION_LESS 6.5.3)
1387 message(WARNING "Qt 6.5.3 or later is required.")
1389 if (APPLE AND Qt6Widgets_VERSION VERSION_LESS 6.5.3)
1390 message(WARNING "Qt 6.5.3 or later is required.")
1394 if(DEFINED ENV{WIRESHARK_QT5_PREFIX_PATH})
1395 list(APPEND CMAKE_PREFIX_PATH $ENV{WIRESHARK_QT5_PREFIX_PATH})
1397 if(APPLE AND EXISTS /usr/local/opt/qt5)
1398 # Homebrew installs Qt5 (up to at least 5.11.0) in
1399 # /usr/local/qt5. Ensure that it can be found by CMake
1400 # since it is not in the default /usr/local prefix.
1401 # Add it to PATHS so that it doesn't override the
1402 # CMAKE_PREFIX_PATH environment variable.
1403 # QT_FIND_PACKAGE_OPTIONS should be passed to find_package,
1404 # e.g. find_package(Qt5Core ${QT_FIND_PACKAGE_OPTIONS})
1405 list(APPEND QT5_FIND_PACKAGE_OPTIONS PATHS /usr/local/opt/qt5)
1416 set(QT5_OPTIONAL_PACKAGELIST
1420 list(APPEND QT5_PACKAGELIST Qt5WinExtras)
1422 if(NOT WIN32 AND NOT APPLE)
1423 # DBus is a core component of Qt6, but was an add-on in Qt5.
1424 list(APPEND QT5_OPTIONAL_PACKAGELIST Qt5DBus)
1426 foreach(_qt5_package IN LISTS QT5_PACKAGELIST)
1427 find_package(${_qt5_package} REQUIRED ${QT5_FIND_PACKAGE_OPTIONS})
1428 list(APPEND QT5_LIBRARIES ${${_qt5_package}_LIBRARIES})
1429 list(APPEND QT5_INCLUDE_DIRS ${${_qt5_package}_INCLUDE_DIRS})
1430 list(APPEND QT5_COMPILE_DEFINITIONS ${${_qt5_package}_COMPILE_DEFINITIONS})
1432 foreach(_qt5_package IN LISTS QT5_OPTIONAL_PACKAGELIST)
1433 find_package(${_qt5_package} ${QT5_FIND_PACKAGE_OPTIONS})
1434 list(APPEND QT5_LIBRARIES ${${_qt5_package}_LIBRARIES})
1435 list(APPEND QT5_INCLUDE_DIRS ${${_qt5_package}_INCLUDE_DIRS})
1436 list(APPEND QT5_COMPILE_DEFINITIONS ${${_qt5_package}_COMPILE_DEFINITIONS})
1439 if (Qt5Widgets_VERSION VERSION_LESS 5.15)
1440 message(FATAL_ERROR "Qt 5.15 or later is required. Qt 6 is recommended.")
1443 if(APPLE AND "/usr/local/opt/qt5/lib/QtCore.framework" IN_LIST Qt5Core_INCLUDE_DIRS)
1444 # When qt@6 and qt@5 are both installed via Homebrew,
1445 # /usr/local/include/QtCore/qvariant.h points to Qt 6 headers.
1446 # Normally the Headers from `-iframework /usr/local/opt/qt5/lib`
1447 # should be used, but `-isystem /usr/local/include` (via
1448 # Libgcrypt and others) seems to prioritized, resulting in use
1449 # of the Qt6 headers. Resolve this by explicit including Qt5.
1450 list(APPEND QT5_INCLUDE_DIRS /usr/local/opt/qt5/include)
1456 ws_find_package(Sparkle ENABLE_SPARKLE HAVE_SOFTWARE_UPDATE 2)
1458 if(Qt6Multimedia_FOUND OR Qt5Multimedia_FOUND)
1459 set(QT_MULTIMEDIA_LIB 1)
1461 if(Qt6DBus_FOUND OR Qt5DBus_FOUND)
1464 if(NOT DEFINED MOC_OPTIONS)
1465 # Squelch moc verbose "nothing to do" output
1466 set(MOC_OPTIONS -nn)
1470 # MaxMind DB address resolution
1471 reset_find_package(MAXMINDDB)
1472 ws_find_package(MaxMindDB BUILD_mmdbresolve HAVE_MAXMINDDB)
1475 reset_find_package(SMI SMI_SHARE_DIR)
1476 ws_find_package(SMI ENABLE_SMI HAVE_LIBSMI)
1478 # Support for TLS decryption using RSA private keys.
1479 ws_find_package(GNUTLS ENABLE_GNUTLS HAVE_LIBGNUTLS "3.5.8")
1482 ws_find_package(KERBEROS ENABLE_KERBEROS HAVE_KERBEROS)
1484 # Zlib-ng compression
1485 ws_find_package(ZLIBNG ENABLE_ZLIBNG HAVE_ZLIBNG)
1487 #if(NOT ZLIBNG_FOUND)
1489 ws_find_package(ZLIB ENABLE_ZLIB HAVE_ZLIB)
1492 # Minizip-ng compression
1493 ws_find_package(Minizipng ENABLE_MINIZIPNG HAVE_MINIZIPNG)
1495 if(NOT MINIZIPNG_FOUND)
1496 # Minizip compression
1497 ws_find_package(Minizip ENABLE_MINIZIP HAVE_MINIZIP)
1500 # Brotli compression
1501 ws_find_package(BROTLI ENABLE_BROTLI HAVE_BROTLI)
1504 ws_find_package(LZ4 ENABLE_LZ4 HAVE_LZ4 "1.8.0")
1506 # Snappy compression
1507 ws_find_package(SNAPPY ENABLE_SNAPPY HAVE_SNAPPY)
1510 ws_find_package(ZSTD ENABLE_ZSTD HAVE_ZSTD "1.0.0")
1512 # Enhanced HTTP/2 dissection
1513 ws_find_package(NGHTTP2 ENABLE_NGHTTP2 HAVE_NGHTTP2 "1.11.0")
1515 # Enhanced HTTP/3 dissection
1516 ws_find_package(NGHTTP3 ENABLE_NGHTTP3 HAVE_NGHTTP3)
1518 # Embedded Lua interpreter
1520 # Download and build lua
1521 include(${CMAKE_SOURCE_DIR}/cmake/external/lua54/Lua54.cmake)
1523 set(LUA_FIND_VERSIONS "5.4;5.3" CACHE STRING "Lua versions valid for the build (as a list)")
1524 ws_find_package(Lua ENABLE_LUA HAVE_LUA)
1527 ws_find_package(NL ENABLE_NETLINK HAVE_LIBNL)
1529 ws_find_package(SBC ENABLE_SBC HAVE_SBC)
1532 ws_find_package(SPANDSP ENABLE_SPANDSP HAVE_SPANDSP)
1534 ws_find_package(BCG729 ENABLE_BCG729 HAVE_BCG729)
1536 ws_find_package(AMRNB ENABLE_AMRNB HAVE_AMRNB)
1538 ws_find_package(ILBC ENABLE_ILBC HAVE_ILBC)
1540 ws_find_package(OPUS ENABLE_OPUS HAVE_OPUS)
1542 if (BUILD_stratoshark)
1543 # libsinsp+libscap, required for falco-bridge
1544 ws_find_package(Sinsp ENABLE_SINSP HAVE_SINSP "0.17.1")
1547 # CMake 3.9 and below used 'LIBXML2_LIBRARIES' as the name of the cache entry
1548 # storing the find_library result. Transfer it to the new cache variable such
1549 # that reset_find_package can detect and clear outdated cache variables.
1550 if(DEFINED LIBXML2_LIBRARIES AND NOT DEFINED LIBXML2_LIBRARY)
1551 set(LIBXML2_LIBRARY ${LIBXML2_LIBRARIES} CACHE FILEPATH "")
1553 # Call reset_find_package explicitly since variables are in upper case.
1554 reset_find_package(LIBXML2)
1555 ws_find_package(LibXml2 ENABLE_LIBXML2 HAVE_LIBXML2)
1556 if(NOT LIBXML2_FOUND)
1557 # CMake 3.9 and below used LIBXML2_LIBRARIES as the name of
1558 # the cache entry storing the find_library result.
1559 # Current CMake (3.13) and below sets LIBXML2_LIBRARIES and LIBXML2_INCLUDE_DIRS
1560 # to a non-empty value, be sure to clear it when not found.
1561 set(LIBXML2_LIBRARIES "")
1562 set(LIBXML2_INCLUDE_DIRS "")
1565 # Capabilities to run dumpcap as non-root user.
1566 if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
1567 ws_find_package(CAP ENABLE_CAP HAVE_LIBCAP)
1568 find_package(SETCAP)
1571 # Windows version updates
1572 ws_find_package(WinSparkle ENABLE_WINSPARKLE HAVE_SOFTWARE_UPDATE)
1574 find_package( Asciidoctor 1.5 )
1575 find_package( XSLTPROC )
1577 find_package(DOXYGEN)
1579 # The SpeexDSP resampler is required iff building wireshark or sharkd.
1580 if(BUILD_wireshark OR BUILD_stratoshark OR BUILD_sharkd)
1581 find_package(SpeexDSP REQUIRED)
1584 # Generate the distribution tarball.
1585 add_custom_target(dist
1586 COMMAND ${CMAKE_BINARY_DIR}/packaging/source/git-export-release.sh -d "${CMAKE_BINARY_DIR}"
1587 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
1591 # Calculating public keys from PKCS #11 private keys requires GnuTLS
1594 # Check that the support is present in case GnuTLS was compiled
1595 # --without-p11-kit as macos-setup.sh did until December 2020.
1596 cmake_push_check_state()
1597 if(WIN32 AND NOT MINGW)
1598 set(CMAKE_REQUIRED_DEFINITIONS -Dssize_t=int)
1600 set(CMAKE_REQUIRED_INCLUDES ${GNUTLS_INCLUDE_DIRS})
1601 set(CMAKE_REQUIRED_LIBRARIES ${GNUTLS_LIBRARIES})
1602 check_symbol_exists(gnutls_pkcs11_obj_list_import_url4 gnutls/pkcs11.h HAVE_GNUTLS_PKCS11)
1603 cmake_pop_check_state()
1607 # CMake uses qmake to find Qt4. It relies on Qt's CMake modules
1608 # to find Qt5. This means that we can't assume that the qmake
1609 # in our PATH is the correct one. We can fetch qmake's location
1610 # from Qt5::qmake, which is defined in Qt5CoreConfigExtras.cmake.
1611 get_target_property(QT_QMAKE_EXECUTABLE Qt${qtver}::qmake IMPORTED_LOCATION)
1612 get_filename_component(_qt_bin_path "${QT_QMAKE_EXECUTABLE}" DIRECTORY)
1613 set(QT_BIN_PATH "${_qt_bin_path}" CACHE INTERNAL
1614 "Path to qmake, macdeployqt, windeployqt, and other Qt utilities."
1616 # Use qmake to find windeployqt and macdeployqt. Ideally one of
1617 # the modules in ${QTDIR}/lib/cmake would do this for us.
1619 if (USE_qt6 AND USE_MSYSTEM)
1620 set(_windeployqt_name "windeployqt-qt6")
1622 set(_windeployqt_name "windeployqt")
1624 find_program(QT_WINDEPLOYQT_EXECUTABLE ${_windeployqt_name}
1625 HINTS "${QT_BIN_PATH}"
1626 DOC "Path to the windeployqt utility."
1628 # As of Qt 6.5.0, the official Qt "MSVC 2019 ARM64 (TP)" libraries don't ship
1629 # with native Arm64 executables. Instead, you get x64 executables installed in
1630 # msvc2019_x64. Look for the path to "qmake.bat", which has to be passed to
1631 # windeployqt so that it can install the proper DLLs.
1632 # https://bugreports.qt.io/browse/QTBUG-100070
1633 set(QT_WINDEPLOYQT_EXTRA_ARGS)
1634 find_program(_qt_qmake_bat qmake.bat
1635 HINTS ENV CMAKE_PREFIX_PATH
1637 DOC "Path to qmake.bat."
1640 set (QT_WINDEPLOYQT_EXTRA_ARGS "--qmake \"${_qt_qmake_bat}\"")
1643 find_program(QT_MACDEPLOYQT_EXECUTABLE macdeployqt
1644 HINTS "${QT_BIN_PATH}"
1645 DOC "Path to the macdeployqt utility."
1647 find_program(DMGBUILD_EXECUTABLE dmgbuild
1648 DOC "Path to the dmgbuild utility"
1650 # https://doc.qt.io/qt-5/supported-platforms.html
1651 # https://doc.qt.io/archives/qt-6.0/supported-platforms.html
1652 # https://doc.qt.io/qt-6.5/supported-platforms.html
1653 # https://doc.qt.io/qt-6.8/supported-platforms.html
1654 # https://doc-snapshots.qt.io/qt6-dev/supported-platforms.html
1655 if(Qt${qtver}Widgets_VERSION VERSION_GREATER_EQUAL "6.8.0" AND MIN_MACOS_VERSION VERSION_LESS "12.0")
1656 set(MIN_MACOS_VERSION 12.0)
1657 elseif(Qt${qtver}Widgets_VERSION VERSION_GREATER_EQUAL "6.5.0" AND MIN_MACOS_VERSION VERSION_LESS "11.0")
1658 set(MIN_MACOS_VERSION 11.0)
1659 elseif(Qt${qtver}Widgets_VERSION VERSION_GREATER_EQUAL "6.0.0" AND MIN_MACOS_VERSION VERSION_LESS "10.14")
1660 set(MIN_MACOS_VERSION 10.14)
1662 if(CMAKE_OSX_DEPLOYMENT_TARGET AND CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS MIN_MACOS_VERSION)
1663 message(FATAL_ERROR "Qt version ${Qt${qtver}Widgets_VERSION} requires CMAKE_OSX_DEPLOYMENT_TARGET (${CMAKE_OSX_DEPLOYMENT_TARGET}) >= ${MIN_MACOS_VERSION}")
1667 # Qt requires MSVC /permissive- option since 6.3 release
1668 if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND Qt${qtver}Widgets_VERSION VERSION_GREATER_EQUAL "6.3.0")
1669 add_compile_options("/permissive-")
1673 if(ENABLE_CHECKHF_CONFLICT)
1674 set(ENABLE_CHECK_FILTER 1)
1678 # Platform-specific additional libraries.
1681 set(WIN_COMCTL32_LIBRARY comctl32.lib)
1682 set(WIN_IPHLPAPI_LIBRARY iphlpapi.lib)
1683 set(WIN_PSAPI_LIBRARY psapi.lib)
1684 set(WIN_VERSION_LIBRARY version.lib)
1685 set(WIN_WS2_32_LIBRARY ws2_32.lib)
1690 # We assume that APPLE means macOS so that we have the macOS
1693 set(HAVE_MACOS_FRAMEWORKS 1)
1694 FIND_LIBRARY (APPLE_APPLICATION_SERVICES_LIBRARY ApplicationServices)
1695 FIND_LIBRARY (APPLE_APPKIT_LIBRARY AppKit)
1696 FIND_LIBRARY (APPLE_CORE_FOUNDATION_LIBRARY CoreFoundation)
1697 FIND_LIBRARY (APPLE_SYSTEM_CONFIGURATION_LIBRARY SystemConfiguration)
1699 message(STATUS "Building for Mac OS X/OS X/macOS ${MIN_MACOS_VERSION} using SDK ${CMAKE_OSX_SYSROOT}")
1702 include(ConfigureChecks.cmake)
1705 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1708 if(NOT (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang"))
1709 # https://ccache.dev/platform-compiler-language-support.html
1710 message(WARNING "Ccache is enabled, but your compiler is ${CMAKE_C_COMPILER_ID}."
1711 " We wish you the best of luck.")
1713 find_program(CCACHE_EXECUTABLE ccache)
1714 if(CCACHE_EXECUTABLE)
1715 set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}")
1716 set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}")
1717 set(CMAKE_C_LINKER_LAUNCHER "${CCACHE_EXECUTABLE}")
1718 set(CMAKE_CXX_LINKER_LAUNCHER "${CCACHE_EXECUTABLE}")
1722 # The top level checkAPIs target, add before subdirectory calls so it's available to all
1723 add_custom_target(checkAPI)
1724 set_target_properties(checkAPI
1727 EXCLUDE_FROM_ALL True
1728 EXCLUDE_FROM_DEFAULT_BUILD True
1731 include( UseCheckAPI )
1733 # Target platform locations
1734 # UN*X in general, including macOS if not building an app bundle:
1735 # $DESTDIR/lib/wireshark/extcap
1736 # Windows: $DESTDIR/extcap
1737 # macOS app bundle: Wireshark.app/Contents/Resources/share/wireshark/extcap
1738 # If you change the nesting level be sure to check also the INSTALL_RPATH
1740 if(WIN32 AND NOT USE_MSYSTEM)
1741 set(EXTCAP_INSTALL_LIBDIR "extcap/${PROJECT_NAME}" CACHE INTERNAL "The Wireshark extcap dir")
1742 if (BUILD_stratoshark)
1743 set(STRATOSHARK_EXTCAP_INSTALL_LIBDIR "extcap/${STRATOSHARK_NAME}" CACHE INTERNAL "The Stratoshark extcap dir")
1746 set(EXTCAP_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/extcap" CACHE INTERNAL "The Wireshark extcap dir")
1747 if (BUILD_stratoshark)
1748 set(STRATOSHARK_EXTCAP_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${STRATOSHARK_NAME}/extcap" CACHE INTERNAL "The Stratoshark extcap dir")
1754 # As https://developer.apple.com/library/archive/technotes/tn2206/_index.html
1757 # "Note that a location where code is expected to reside cannot generally
1758 # contain directories full of nested code, because those directories tend
1759 # to be interpreted as bundles. So this occasional practice is not
1760 # recommended and not officially supported. If you do do this, do not use
1761 # periods in the directory names. The code signing machinery interprets
1762 # directories with periods in their names as code bundles and will reject
1763 # them if they don't conform to the expected code bundle layout."
1765 set(PLUGIN_PATH_ID "${PROJECT_MAJOR_VERSION}-${PROJECT_MINOR_VERSION}")
1767 set(PLUGIN_PATH_ID "${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}")
1770 # Directory where plugins and Lua dissectors can be found.
1771 if(WIN32 AND NOT USE_MSYSTEM)
1772 set(PLUGIN_INSTALL_LIBDIR "plugins" CACHE INTERNAL "The plugin dir")
1774 set(PLUGIN_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/plugins" CACHE INTERNAL "The plugin dir")
1776 set(PLUGIN_INSTALL_FULL_LIBDIR "${CMAKE_INSTALL_PREFIX}/${PLUGIN_INSTALL_LIBDIR}")
1777 set(PLUGIN_INSTALL_VERSION_LIBDIR "${PLUGIN_INSTALL_LIBDIR}/${PLUGIN_PATH_ID}")
1778 set(PLUGIN_VERSION_DIR "plugins/${PLUGIN_PATH_ID}")
1780 add_subdirectory( capture )
1781 add_subdirectory( epan )
1782 add_subdirectory( extcap )
1783 add_subdirectory( randpkt_core )
1784 if(NOT LEMON_EXECUTABLE)
1785 add_subdirectory( tools/lemon )
1788 add_subdirectory( tools/radiotap-gen )
1790 add_subdirectory( ui )
1791 add_subdirectory( wiretap )
1792 add_subdirectory( writecap )
1794 # Location of our data files. This should be set to a value that allows
1795 # running from the build directory on Windows, on macOS when building an
1796 # application bundle, and on UNIX in general if
1797 # WIRESHARK_RUN_FROM_BUILD_DIRECTORY is set.
1798 if(ENABLE_APPLICATION_BUNDLE)
1799 if(CMAKE_CFG_INTDIR STREQUAL ".")
1800 set(_datafile_dir "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/share/wireshark")
1803 set(_datafile_dir "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}/Wireshark.app/Contents/Resources/share/wireshark")
1805 elseif(NOT CMAKE_CFG_INTDIR STREQUAL ".")
1806 # Visual Studio, Xcode, etc.
1807 set(_datafile_dir "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}")
1809 # Makefile, Ninja, etc.
1810 set(_datafile_dir "${CMAKE_BINARY_DIR}/run")
1813 set(DATAFILE_DIR ${_datafile_dir} CACHE INTERNAL "Build time data file location.")
1815 if(ENABLE_APPLICATION_BUNDLE)
1816 if(CMAKE_CFG_INTDIR STREQUAL ".")
1817 set(_stratoshark_datafile_dir "${CMAKE_BINARY_DIR}/run/Stratoshark.app/Contents/Resources/share/stratoshark")
1820 set(_stratoshark_datafile_dir "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}/Stratoshark.app/Contents/Resources/share/stratoshark")
1822 set(STRATOSHARK_DATAFILE_DIR ${_stratoshark_datafile_dir} CACHE INTERNAL "Build time log analysis data file location.")
1823 # XXX We need to update wsutil/filesystem.c and packaging/nsis/*stratoshark* to match.
1824 # elseif(NOT CMAKE_CFG_INTDIR STREQUAL ".")
1825 # # Visual Studio, Xcode, etc.
1826 # set(_stratoshark_datafile_dir "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}/share/stratoshark")
1828 # # Makefile, Ninja, etc.
1829 # set(_stratoshark_datafile_dir "${CMAKE_BINARY_DIR}/run/share/stratoshark")
1832 # wsutil must be added after DATAFILE_DIR is set such that filesystem.c can
1833 # learn about the directory location.
1834 add_subdirectory( wsutil )
1836 # doc/ must be added after DATAFILE_DIR is set so that the guides can be
1837 # copied there for running from the build directory
1838 add_subdirectory( doc )
1840 if(BUILD_wireshark AND QT_FOUND)
1841 add_subdirectory( ui/qt )
1842 elseif(BUILD_wireshark AND USE_qt6)
1843 message(VERBOSE "To use Qt5 instead of Qt6 use CMake option USE_qt6=OFF.")
1846 if(BUILD_stratoshark AND QT_FOUND)
1847 add_subdirectory( ui/stratoshark )
1850 # Location of our plugins. PLUGIN_DIR should allow running
1851 # from the build directory similar to DATAFILE_DIR above.
1853 # Target platform locations
1854 # UN*X in general, including macOS if not building an app bundle:
1855 # $DESTDIR/lib/wireshark/plugins/$VERSION
1856 # Windows: $DESTDIR/wireshark/plugins/$VERSION
1857 # macOS app bundle: Wireshark.app/Contents/PlugIns/wireshark
1859 add_custom_target(plugins)
1860 set_target_properties(plugins PROPERTIES FOLDER "Plugins")
1862 plugins/epan/ethercat
1863 plugins/epan/gryphon
1867 plugins/epan/profinet
1868 plugins/epan/stats_tree
1869 plugins/epan/transum
1870 plugins/epan/unistim
1872 plugins/epan/wimaxasncp
1873 plugins/epan/wimaxmacphy
1874 plugins/epan/dfilter/ipaddr
1875 plugins/wiretap/usbdump
1877 plugins/codecs/l16_mono
1878 ${CUSTOM_PLUGIN_SRC_DIR}
1880 set(STRATOSHARK_PLUGIN_SRC_DIRS)
1882 list(APPEND STRATOSHARK_PLUGIN_SRC_DIRS
1883 plugins/epan/falco_bridge
1887 list(APPEND PLUGIN_SRC_DIRS
1893 list(APPEND PLUGIN_SRC_DIRS
1898 list(APPEND PLUGIN_SRC_DIRS
1899 plugins/codecs/amrnb
1903 list(APPEND PLUGIN_SRC_DIRS
1908 list(APPEND PLUGIN_SRC_DIRS
1909 plugins/codecs/opus_dec
1913 list(APPEND PLUGIN_SRC_DIRS
1918 # Build demo plugin, only if asked explicitly
1919 if(ENABLE_PLUGIN_IFDEMO)
1920 list(APPEND PLUGIN_SRC_DIRS
1921 plugins/epan/pluginifdemo
1926 set(PLUGIN_SRC_DIRS )
1927 set(STRATOSHARK_PLUGIN_SRC_DIRS )
1930 if(ENABLE_APPLICATION_BUNDLE)
1931 if(CMAKE_CFG_INTDIR STREQUAL ".")
1932 set(_plugin_dir "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/PlugIns/wireshark/${PLUGIN_PATH_ID}")
1935 set(_plugin_dir "${CMAKE_BINARY_DIR}/run/$<CONFIG>/Wireshark.app/Contents/PlugIns/wireshark/${PLUGIN_PATH_ID}")
1937 if(CMAKE_CFG_INTDIR STREQUAL ".")
1938 set(_stratoshark_plugin_dir "${CMAKE_BINARY_DIR}/run/Stratoshark.app/Contents/PlugIns/stratoshark/${PLUGIN_PATH_ID}")
1941 set(_stratoshark_plugin_dir "${CMAKE_BINARY_DIR}/run/$<CONFIG>/Stratoshark.app/Contents/PlugIns/stratoshark/${PLUGIN_PATH_ID}")
1943 elseif(MSVC AND NOT CMAKE_CFG_INTDIR STREQUAL ".")
1944 set(_plugin_dir "${CMAKE_BINARY_DIR}/run/$<CONFIG>/${PLUGIN_VERSION_DIR}")
1945 set(_stratoshark_plugin_dir ${_plugin_dir})
1947 set(_plugin_dir "${DATAFILE_DIR}/${PLUGIN_VERSION_DIR}")
1948 set(_stratoshark_plugin_dir ${_plugin_dir})
1950 set (PLUGIN_DIR ${_plugin_dir} CACHE INTERNAL "Build time plugin location.")
1951 set (STRATOSHARK_PLUGIN_DIR ${_stratoshark_plugin_dir} CACHE INTERNAL "Build time Stratoshark plugin location.")
1953 foreach(_plugin_src_dir ${PLUGIN_SRC_DIRS} ${STRATOSHARK_PLUGIN_SRC_DIRS})
1954 add_subdirectory( ${_plugin_src_dir} )
1957 if(VCSVERSION_OVERRIDE)
1958 # Allow distributors to override detection of the Git tag and version.
1959 string(CONFIGURE "#define VCSVERSION \"@VCSVERSION_OVERRIDE@\"\n"
1960 _version_h_contents ESCAPE_QUOTES)
1961 file(WRITE "${CMAKE_BINARY_DIR}/vcs_version.h" "${_version_h_contents}")
1962 message(STATUS "VCSVERSION_OVERRIDE: ${VCSVERSION_OVERRIDE}")
1964 add_custom_target(vcs_version
1965 BYPRODUCTS vcs_version.h
1966 COMMAND ${Python3_EXECUTABLE}
1967 ${CMAKE_SOURCE_DIR}/tools/make-version.py
1970 set_target_properties(vcs_version PROPERTIES FOLDER "Auxiliary")
1973 set( configure_input "Built with CMake ${CMAKE_VERSION}" )
1974 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
1976 configure_file(${CMAKE_SOURCE_DIR}/ws_version.h.in ${CMAKE_BINARY_DIR}/ws_version.h)
1979 file(GLOB TOP_LEVEL_SOURCE_LIST *.c *.cpp *.h)
1980 string (REPLACE ";" " " DOXYGEN_TOP_LEVEL_SOURCES "${TOP_LEVEL_SOURCE_LIST}")
1981 set(DOXYGEN_INPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
1982 set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
1986 packaging/macosx/osx-app.sh
1987 packaging/macosx/osx-dmg.sh
1988 packaging/macosx/wireshark-app.dmgbuild
1989 packaging/macosx/wireshark-dsym.dmgbuild
1990 packaging/macosx/WiresharkInfo.plist
1991 packaging/source/git-export-release.sh
1992 resources/dumpcap.rc
1993 resources/libwireshark.rc
1994 resources/libwiretap.rc
1995 resources/libwsutil.rc
1996 resources/wireshark.exe.manifest
1997 resources/wireshark.pc
1998 resources/wireshark.rc
2001 if(BUILD_stratoshark)
2002 list(APPEND CFG_OUT_FILES
2003 packaging/macosx/StratosharkInfo.plist
2004 packaging/macosx/stratoshark-app.dmgbuild
2005 packaging/macosx/stratoshark-dsym.dmgbuild
2006 resources/stratoshark.exe.manifest
2010 foreach( _cfg_file ${CFG_OUT_FILES} )
2011 configure_file( ${CMAKE_SOURCE_DIR}/${_cfg_file}.in ${CMAKE_BINARY_DIR}/${_cfg_file} @ONLY )
2014 include(FeatureSummary)
2015 set_package_properties(CAP PROPERTIES
2016 DESCRIPTION "The Libcap package implements the user-space interfaces to the POSIX 1003.1e capabilities available in Linux kernels"
2017 URL "https://sites.google.com/site/fullycapable/"
2018 PURPOSE "Allow packet captures without running as root"
2020 set_package_properties(SBC PROPERTIES
2021 DESCRIPTION "Bluetooth low-complexity, subband codec (SBC) decoder"
2022 URL "https://git.kernel.org/pub/scm/bluetooth/sbc.git"
2023 PURPOSE "Support for playing SBC codec in RTP player"
2025 set_package_properties(SPANDSP PROPERTIES
2026 DESCRIPTION "a library of many DSP functions for telephony"
2027 URL "https://www.soft-switch.org"
2028 PURPOSE "Support for G.722 and G.726 codecs in RTP player"
2030 set_package_properties(BCG729 PROPERTIES
2031 DESCRIPTION "G.729 decoder"
2032 URL "https://www.linphone.org/technical-corner/bcg729"
2033 PURPOSE "Support for G.729 codec in RTP player"
2035 set_package_properties(AMRNB PROPERTIES
2036 DESCRIPTION "AMRNB decoder"
2037 URL "https://sourceforge.net/p/opencore-amr"
2038 PURPOSE "Support for AMRNB codec in RTP player"
2040 set_package_properties(ILBC PROPERTIES
2041 DESCRIPTION "iLBC decoder"
2042 URL "https://github.com/TimothyGu/libilbc"
2043 PURPOSE "Support for iLBC codec in RTP player"
2045 set_package_properties(OPUS PROPERTIES
2046 DESCRIPTION "opus decoder"
2047 URL "https://opus-codec.org/"
2048 PURPOSE "Support for opus codec in RTP player"
2050 set_package_properties(LIBXML2 PROPERTIES
2051 DESCRIPTION "XML parsing library"
2052 URL "http://xmlsoft.org/"
2053 PURPOSE "Read XML configuration files in EPL dissector"
2055 set_package_properties(LIBSSH PROPERTIES
2056 DESCRIPTION "Library for implementing SSH clients"
2057 URL "https://www.libssh.org/"
2058 PURPOSE "extcap remote SSH interfaces (sshdump, ciscodump, wifidump, sshdig)"
2060 set_package_properties(LZ4 PROPERTIES
2061 DESCRIPTION "LZ4 is a fast lossless compression algorithm"
2062 URL "http://www.lz4.org"
2063 PURPOSE "LZ4 decompression in CQL and Kafka dissectors, read compressed capture files"
2065 set_package_properties(SNAPPY PROPERTIES
2066 DESCRIPTION "A fast compressor/decompressor from Google"
2067 URL "https://google.github.io/snappy/"
2068 PURPOSE "Snappy decompression in Couchbase, CQL, Kafka and Mongo dissectors"
2070 set_package_properties(ZSTD PROPERTIES
2071 DESCRIPTION "A compressor/decompressor from Facebook providing better compression than Snappy at a cost of speed"
2072 URL "https://facebook.github.io/zstd/"
2073 PURPOSE "Zstd decompression in Kafka dissector, read compressed capture files"
2075 set_package_properties(NGHTTP2 PROPERTIES
2076 DESCRIPTION "HTTP/2 C library and tools"
2077 URL "https://nghttp2.org"
2078 PURPOSE "Header decompression in HTTP2"
2080 set_package_properties(NGHTTP3 PROPERTIES
2081 DESCRIPTION "HTTP/3 C library and tools"
2082 URL "https://nghttp2.org"
2083 PURPOSE "Header decompression in HTTP3"
2085 set_package_properties(CARES PROPERTIES
2086 DESCRIPTION "Library for asynchronous DNS requests"
2087 URL "https://c-ares.org/"
2088 PURPOSE "DNS name resolution for captures"
2090 set_package_properties(Systemd PROPERTIES
2091 URL "https://freedesktop.org/wiki/Software/systemd/"
2092 DESCRIPTION "System and Service Manager (libraries)"
2093 PURPOSE "Support for systemd journal extcap interface (sdjournal)"
2095 set_package_properties(NL PROPERTIES
2096 URL "https://www.infradead.org/~tgr/libnl/"
2097 DESCRIPTION "Libraries for using the Netlink protocol on Linux"
2098 PURPOSE "Support for managing wireless 802.11 interfaces"
2100 set_package_properties(MaxMindDB PROPERTIES
2101 URL "https://github.com/maxmind/libmaxminddb"
2102 DESCRIPTION "C library for the MaxMind DB file format"
2103 PURPOSE "Support for GeoIP lookup"
2105 set_package_properties(SpeexDSP PROPERTIES
2106 URL "https://www.speex.org/"
2107 DESCRIPTION "SpeexDSP is a patent-free, Open Source/Free Software DSP library"
2108 PURPOSE "RTP audio resampling"
2110 set_package_properties(Minizip PROPERTIES
2111 URL "https://github.com/madler/zlib"
2112 DESCRIPTION "Mini zip and unzip based on zlib"
2113 PURPOSE "Support for profiles import/export"
2115 set_package_properties(Minizipng PROPERTIES
2116 URL "https://github.com/zlib-ng/minizip-ng"
2117 DESCRIPTION "A fork of the minizip library - Mini zip and unzip based on zlib"
2118 PURPOSE "Support for profiles import/export"
2120 set_package_properties(SMI PROPERTIES
2121 URL "https://www.ibr.cs.tu-bs.de/projects/libsmi/"
2122 DESCRIPTION "Library to access SMI management information"
2123 PURPOSE "Support MIB and PIB parsing and OID resolution"
2125 set_package_properties(PCRE2 PROPERTIES
2126 URL "https://www.pcre.org"
2127 DESCRIPTION "Regular expression pattern matching using the same syntax and semantics as Perl 5"
2128 PURPOSE "Support for regular expressions"
2130 set_package_properties(Sinsp PROPERTIES
2131 DESCRIPTION "libsinsp and libscap"
2132 URL "https://github.com/falcosecurity/libs/"
2133 PURPOSE "Support for Falco plugins"
2135 set_package_properties(Lua PROPERTIES
2136 DESCRIPTION "Lua is a powerful, efficient, lightweight, embeddable scripting language"
2137 URL "https://www.lua.org/"
2138 PURPOSE "Lua allows writing dissectors and other extensions without a C/C++ compiler"
2141 string(TOUPPER "${CMAKE_BUILD_TYPE}" _build_type)
2142 message(STATUS "C-Flags: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${_build_type}}")
2143 message(STATUS "CXX-Flags: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${_build_type}}")
2144 if(WERROR_COMMON_FLAGS)
2145 message(STATUS "Warnings as errors enabled: ${WERROR_COMMON_FLAGS}")
2147 message(STATUS "Warnings as errors disabled")
2150 feature_summary(WHAT ALL)
2152 # Should this be part of libui?
2155 ui/win32/file_dlg_win32.cpp
2159 ui/macosx/cocoa_bridge.mm
2162 list(APPEND PLATFORM_UI_SRC ui/macosx/sparkle_bridge.m)
2167 ${CMAKE_SOURCE_DIR}/ui/cli/tap-credentials.c
2168 ${CMAKE_SOURCE_DIR}/ui/cli/tap-camelsrt.c
2169 ${CMAKE_SOURCE_DIR}/ui/cli/tap-diameter-avp.c
2170 ${CMAKE_SOURCE_DIR}/ui/cli/tap-expert.c
2171 ${CMAKE_SOURCE_DIR}/ui/cli/tap-exportobject.c
2172 ${CMAKE_SOURCE_DIR}/ui/cli/tap-endpoints.c
2173 ${CMAKE_SOURCE_DIR}/ui/cli/tap-flow.c
2174 ${CMAKE_SOURCE_DIR}/ui/cli/tap-follow.c
2175 ${CMAKE_SOURCE_DIR}/ui/cli/tap-funnel.c
2176 ${CMAKE_SOURCE_DIR}/ui/cli/tap-gsm_astat.c
2177 ${CMAKE_SOURCE_DIR}/ui/cli/tap-hosts.c
2178 ${CMAKE_SOURCE_DIR}/ui/cli/tap-httpstat.c
2179 ${CMAKE_SOURCE_DIR}/ui/cli/tap-icmpstat.c
2180 ${CMAKE_SOURCE_DIR}/ui/cli/tap-icmpv6stat.c
2181 ${CMAKE_SOURCE_DIR}/ui/cli/tap-iostat.c
2182 ${CMAKE_SOURCE_DIR}/ui/cli/tap-iousers.c
2183 ${CMAKE_SOURCE_DIR}/ui/cli/tap-macltestat.c
2184 ${CMAKE_SOURCE_DIR}/ui/cli/tap-oran.c
2185 ${CMAKE_SOURCE_DIR}/ui/cli/tap-protocolinfo.c
2186 ${CMAKE_SOURCE_DIR}/ui/cli/tap-protohierstat.c
2187 ${CMAKE_SOURCE_DIR}/ui/cli/tap-rlcltestat.c
2188 ${CMAKE_SOURCE_DIR}/ui/cli/tap-rpcprogs.c
2189 ${CMAKE_SOURCE_DIR}/ui/cli/tap-rtd.c
2190 ${CMAKE_SOURCE_DIR}/ui/cli/tap-rtp.c
2191 ${CMAKE_SOURCE_DIR}/ui/cli/tap-rtspstat.c
2192 ${CMAKE_SOURCE_DIR}/ui/cli/tap-sctpchunkstat.c
2193 ${CMAKE_SOURCE_DIR}/ui/cli/tap-simple_stattable.c
2194 ${CMAKE_SOURCE_DIR}/ui/cli/tap-sipstat.c
2195 ${CMAKE_SOURCE_DIR}/ui/cli/tap-smbsids.c
2196 ${CMAKE_SOURCE_DIR}/ui/cli/tap-srt.c
2197 ${CMAKE_SOURCE_DIR}/ui/cli/tap-stats_tree.c
2198 ${CMAKE_SOURCE_DIR}/ui/cli/tap-sv.c
2199 ${CMAKE_SOURCE_DIR}/ui/cli/tap-voip.c
2200 ${CMAKE_SOURCE_DIR}/ui/cli/tap-wspstat.c
2201 ${CUSTOM_TSHARK_TAP_SRC}
2205 # Copied into ${DATAFILE_DIR} at build time and ${CMAKE_INSTALL_DATADIR}/wireshark
2208 resources/share/wireshark/profiles
2209 resources/protocols/diameter
2210 resources/protocols/dtds
2211 resources/protocols/radius
2212 resources/protocols/tpncp
2213 resources/protocols/wimaxasncp
2216 # Copied into ${DATAFILE_DIR} at build time and ${CMAKE_INSTALL_DATADIR}/wireshark
2219 resources/share/wireshark/cfilters
2220 resources/share/wireshark/colorfilters
2221 resources/share/wireshark/dmacros
2222 resources/share/wireshark/dfilters
2223 resources/share/wireshark/ipmap.html
2224 resources/share/wireshark/smi_modules
2229 resources/share/doc/wireshark/pdml2html.xsl
2230 doc/README.xml-output
2234 if (BUILD_stratoshark)
2235 set(STRATOSHARK_INSTALL_DIRS
2236 resources/share/stratoshark/profiles
2239 set(STRATOSHARK_INSTALL_FILES
2241 resources/share/stratoshark/colorfilters
2242 resources/share/stratoshark/dfilter_buttons
2246 if (ASCIIDOCTOR_FOUND)
2247 list(APPEND DOC_FILES
2248 ${CMAKE_BINARY_DIR}/doc/man_pages/androiddump.html
2249 ${CMAKE_BINARY_DIR}/doc/man_pages/udpdump.html
2250 ${CMAKE_BINARY_DIR}/doc/man_pages/capinfos.html
2251 ${CMAKE_BINARY_DIR}/doc/man_pages/captype.html
2252 ${CMAKE_BINARY_DIR}/doc/man_pages/ciscodump.html
2253 ${CMAKE_BINARY_DIR}/doc/man_pages/dumpcap.html
2254 ${CMAKE_BINARY_DIR}/doc/man_pages/editcap.html
2255 ${CMAKE_BINARY_DIR}/doc/man_pages/extcap.html
2256 ${CMAKE_BINARY_DIR}/doc/man_pages/mergecap.html
2257 ${CMAKE_BINARY_DIR}/doc/man_pages/randpkt.html
2258 ${CMAKE_BINARY_DIR}/doc/man_pages/randpktdump.html
2259 ${CMAKE_BINARY_DIR}/doc/man_pages/etwdump.html
2260 ${CMAKE_BINARY_DIR}/doc/man_pages/rawshark.html
2261 ${CMAKE_BINARY_DIR}/doc/man_pages/reordercap.html
2262 ${CMAKE_BINARY_DIR}/doc/man_pages/sshdig.html
2263 ${CMAKE_BINARY_DIR}/doc/man_pages/sshdump.html
2264 ${CMAKE_BINARY_DIR}/doc/man_pages/stratoshark.html
2265 ${CMAKE_BINARY_DIR}/doc/man_pages/wifidump.html
2266 ${CMAKE_BINARY_DIR}/doc/man_pages/text2pcap.html
2267 ${CMAKE_BINARY_DIR}/doc/man_pages/tshark.html
2268 ${CMAKE_BINARY_DIR}/doc/man_pages/wireshark.html
2269 ${CMAKE_BINARY_DIR}/doc/man_pages/wireshark-filter.html
2270 "${CMAKE_BINARY_DIR}/doc/Wireshark Release Notes.html"
2271 "${CMAKE_BINARY_DIR}/doc/Stratoshark Release Notes.html"
2274 list(APPEND DOC_FILES ${CMAKE_BINARY_DIR}/doc/man_pages/mmdbresolve.html)
2277 if (BUILD_corbaidl2wrs)
2278 list(APPEND DOC_FILES ${CMAKE_BINARY_DIR}/doc/man_pages/idl2wrs.html)
2281 list(APPEND DOC_FILES
2282 ${CMAKE_BINARY_DIR}/doc/man_pages/asn2deb.html
2283 ${CMAKE_BINARY_DIR}/doc/man_pages/idl2deb.html
2286 if (BUILD_stratoshark)
2287 list(APPEND DOC_FILES
2288 ${CMAKE_BINARY_DIR}/doc/man_pages/falcodump.html
2294 # We do this for Windows further down in the copy_data_files target.
2295 list(APPEND DOC_FILES COPYING)
2299 set(_dll_output_dir "$<TARGET_FILE_DIR:wsutil>")
2300 add_custom_target(copy_cli_dlls)
2301 set_target_properties(copy_cli_dlls PROPERTIES FOLDER "Copy Tasks")
2302 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
2303 COMMAND ${CMAKE_COMMAND} -E make_directory "${_dll_output_dir}"
2306 # XXX Can (and should) we iterate over these similar to the way
2307 # the top-level CMakeLists.txt iterates over the package list?
2309 # Required DLLs and their corresponding PDBs.
2310 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
2311 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2312 "$<IF:$<CONFIG:Debug>,${GLIB2_DLLS_DEBUG},${GLIB2_DLLS_RELEASE}>"
2313 "$<IF:$<CONFIG:Debug>,${GLIB2_PDBS_DEBUG},${GLIB2_PDBS_RELEASE}>"
2314 "${_dll_output_dir}"
2315 WORKING_DIRECTORY $<IF:$<CONFIG:Debug>,${GLIB2_DLL_DIR_DEBUG},${GLIB2_DLL_DIR_RELEASE}>
2316 COMMAND_EXPAND_LISTS
2319 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
2320 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2321 "$<IF:$<CONFIG:Debug>,${PCRE2_DEBUG_DLL},${PCRE2_RELEASE_DLL}>"
2322 "$<IF:$<CONFIG:Debug>,${PCRE2_DEBUG_PDB},${PCRE2_RELEASE_PDB}>"
2323 "${_dll_output_dir}"
2324 WORKING_DIRECTORY $<IF:$<CONFIG:Debug>,${PCRE2_DEBUG_DLL_DIR},${PCRE2_RELEASE_DLL_DIR}>
2325 COMMAND_EXPAND_LISTS
2328 if (MSVC AND VLD_FOUND)
2329 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
2330 COMMAND ${CMAKE_COMMAND} -E "$<IF:$<CONFIG:Debug>,copy_if_different,true>"
2332 "${_dll_output_dir}"
2333 COMMAND_EXPAND_LISTS
2337 # Third party DLLs and PDBs.
2338 set (THIRD_PARTY_DLLS)
2339 set (THIRD_PARTY_PDBS)
2340 list (APPEND THIRD_PARTY_DLLS "${CARES_DLL_DIR}/${CARES_DLL}")
2341 list (APPEND THIRD_PARTY_PDBS "${CARES_DLL_DIR}/${CARES_PDB}")
2342 # vcpkg's libmaxminddb is static-only for now. This can be uncommented when
2343 # https://github.com/maxmind/libmaxminddb/commit/3998f42bdb6678cbaa1a543057e5c81ba1668ac2
2344 # percolates up to vcpkg.
2345 # if (MAXMINDDB_FOUND)
2346 # list (APPEND THIRD_PARTY_DLLS "${MAXMINDDB_DLL_DIR}/${MAXMINDDB_DLL}")
2347 # endif(MAXMINDDB_FOUND)
2349 foreach( _dll ${LIBSSH_DLLS} )
2350 list (APPEND THIRD_PARTY_DLLS "${LIBSSH_DLL_DIR}/${_dll}")
2353 foreach( _dll ${GCRYPT_DLLS} )
2354 list (APPEND THIRD_PARTY_DLLS "${GCRYPT_DLL_DIR}/${_dll}")
2356 foreach( _dll ${GNUTLS_DLLS} )
2357 list (APPEND THIRD_PARTY_DLLS "${GNUTLS_DLL_DIR}/${_dll}")
2359 foreach( _dll ${KERBEROS_DLLS} )
2360 list (APPEND THIRD_PARTY_DLLS "${KERBEROS_DLL_DIR}/${_dll}")
2363 list (APPEND THIRD_PARTY_DLLS "${LUA_DLL_DIR}/${LUA_DLL}")
2366 list (APPEND THIRD_PARTY_DLLS "${LZ4_DLL_DIR}/${LZ4_DLL}")
2367 list (APPEND THIRD_PARTY_PDBS "${LZ4_DLL_DIR}/${LZ4_PDB}")
2370 list (APPEND THIRD_PARTY_DLLS "${MINIZIP_DLL_DIR}/${MINIZIP_DLL}")
2371 list (APPEND THIRD_PARTY_PDBS "${MINIZIP_DLL_DIR}/${MINIZIP_PDB}")
2373 if (MINIZIPNG_FOUND)
2374 foreach( _dll ${MINIZIPNG_DLLS} )
2375 list (APPEND THIRD_PARTY_DLLS "${MINIZIPNG_DLL_DIR}/${_dll}")
2377 foreach( _pdb ${MINIZIPNG_PDBS} )
2378 list (APPEND THIRD_PARTY_PDBS "${MINIZIPNG_DLL_DIR}/${_pdb}")
2382 list (APPEND THIRD_PARTY_DLLS "${NGHTTP2_DLL_DIR}/${NGHTTP2_DLL}")
2383 list (APPEND THIRD_PARTY_PDBS "${NGHTTP2_DLL_DIR}/${NGHTTP2_PDB}")
2384 endif(NGHTTP2_FOUND)
2386 list (APPEND THIRD_PARTY_DLLS "${NGHTTP3_DLL_DIR}/${NGHTTP3_DLL}")
2387 list (APPEND THIRD_PARTY_PDBS "${NGHTTP3_DLL_DIR}/${NGHTTP3_PDB}")
2388 endif(NGHTTP3_FOUND)
2390 list (APPEND THIRD_PARTY_DLLS "${SBC_DLL_DIR}/${SBC_DLL}")
2393 list (APPEND THIRD_PARTY_DLLS "${SPANDSP_DLL_DIR}/${SPANDSP_DLL}")
2394 endif(SPANDSP_FOUND)
2396 list (APPEND THIRD_PARTY_DLLS "${BCG729_DLL_DIR}/${BCG729_DLL}")
2399 list (APPEND THIRD_PARTY_DLLS "${AMRNB_DLL_DIR}/${AMRNB_DLL}")
2402 list (APPEND THIRD_PARTY_DLLS "${ILBC_DLL_DIR}/${ILBC_DLL}")
2405 list (APPEND THIRD_PARTY_DLLS "${OPUS_DLL_DIR}/${OPUS_DLL}")
2408 foreach( _dll ${LIBXML2_DLLS} )
2409 list (APPEND THIRD_PARTY_DLLS "${LIBXML2_DLL_DIR}/${_dll}")
2411 foreach( _pdb ${LIBXML2_PDBS} )
2412 list (APPEND THIRD_PARTY_PDBS "${LIBXML2_DLL_DIR}/${_pdb}")
2414 endif(LIBXML2_FOUND)
2416 list (APPEND THIRD_PARTY_DLLS "${SMI_DLL_DIR}/${SMI_DLL}")
2417 # Wireshark.nsi wants SMI_DIR which is the base SMI directory
2418 get_filename_component(SMI_DIR ${SMI_DLL_DIR} DIRECTORY)
2419 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
2420 COMMAND ${CMAKE_COMMAND} -E make_directory
2421 "${_dll_output_dir}/snmp"
2422 COMMAND ${CMAKE_COMMAND} -E make_directory
2423 "${_dll_output_dir}/snmp/mibs"
2424 COMMAND ${CMAKE_COMMAND} -E copy_directory
2425 "${SMI_SHARE_DIR}/mibs/iana"
2426 "${_dll_output_dir}/snmp/mibs"
2427 COMMAND ${CMAKE_COMMAND} -E copy_directory
2428 "${SMI_SHARE_DIR}/mibs/ietf"
2429 "${_dll_output_dir}/snmp/mibs"
2430 COMMAND ${CMAKE_COMMAND} -E copy_directory
2431 "${SMI_SHARE_DIR}/mibs/irtf"
2432 "${_dll_output_dir}/snmp/mibs"
2433 COMMAND ${CMAKE_COMMAND} -E copy_directory
2434 "${SMI_SHARE_DIR}/mibs/site"
2435 "${_dll_output_dir}/snmp/mibs"
2436 COMMAND ${CMAKE_COMMAND} -E copy_directory
2437 "${SMI_SHARE_DIR}/mibs/tubs"
2438 "${_dll_output_dir}/snmp/mibs"
2439 COMMAND ${CMAKE_COMMAND} -E copy_directory
2440 "${SMI_SHARE_DIR}/pibs"
2441 "${_dll_output_dir}/snmp/mibs"
2442 COMMAND ${CMAKE_COMMAND} -E copy_directory
2443 "${SMI_SHARE_DIR}/yang"
2444 "${_dll_output_dir}/snmp/mibs"
2445 #remove the extra directories copied (shallow copying the above would remove the need for this)
2446 COMMAND ${CMAKE_COMMAND} -E remove_directory
2447 "${_dll_output_dir}/snmp/mibs/iana"
2448 COMMAND ${CMAKE_COMMAND} -E remove_directory
2449 "${_dll_output_dir}/snmp/mibs/ietf"
2450 COMMAND ${CMAKE_COMMAND} -E remove_directory
2451 "${_dll_output_dir}/snmp/mibs/site"
2452 COMMAND ${CMAKE_COMMAND} -E remove_directory
2453 "${_dll_output_dir}/snmp/mibs/tubs"
2457 list (APPEND THIRD_PARTY_DLLS "${SNAPPY_DLL_DIR}/${SNAPPY_DLL}")
2459 if (WINSPARKLE_FOUND)
2460 list (APPEND THIRD_PARTY_DLLS "${WINSPARKLE_DLL_DIR}/${WINSPARKLE_DLL}")
2461 endif(WINSPARKLE_FOUND)
2463 list (APPEND THIRD_PARTY_DLLS "${ZLIB_DLL_DIR}/${ZLIB_DLL}")
2464 list (APPEND THIRD_PARTY_PDBS "${ZLIB_DLL_DIR}/${ZLIB_PDB}")
2467 list (APPEND THIRD_PARTY_DLLS "${ZLIBNG_DLL_DIR}/${ZLIBNG_DLL}")
2468 list (APPEND THIRD_PARTY_PDBS "${ZLIBNG_DLL_DIR}/${ZLIBNG_PDB}")
2471 foreach( _dll ${BROTLI_DLLS} )
2472 list (APPEND THIRD_PARTY_DLLS "${BROTLI_DLL_DIR}/${_dll}")
2476 list (APPEND THIRD_PARTY_DLLS "${SPEEXDSP_DLL_DIR}/${SPEEXDSP_DLL}")
2479 list (APPEND THIRD_PARTY_DLLS "${ZSTD_DLL_DIR}/${ZSTD_DLL}")
2482 # With libs downloaded to c:/wireshark-x64-libs this currently
2483 # (early 2018) expands to about 1900 characters.
2484 if (THIRD_PARTY_DLLS)
2485 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
2486 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2488 "${_dll_output_dir}"
2491 install(FILES ${THIRD_PARTY_DLLS} DESTINATION "${CMAKE_INSTALL_BINDIR}")
2492 endif(THIRD_PARTY_DLLS)
2494 if (THIRD_PARTY_PDBS)
2495 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
2496 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2498 "${_dll_output_dir}"
2501 endif(THIRD_PARTY_PDBS)
2503 add_dependencies(epan copy_cli_dlls)
2505 # We have a lot of choices for creating zip archives:
2506 # - 7z, WinZip, etc., which require a separate download+install.
2507 # - "CMake -E tar cz", which creates a tar file.
2508 # - CPack, which requires a CPack configuration.
2509 # - PowerShell via PSCX or System.IO.Compression.FileSystem.
2510 # - Python via zipfile.
2511 # For now, just look for 7z. It's installed on the Windows builders,
2512 # which might be the only systems that use this target.
2513 find_program(ZIP_EXECUTABLE 7z
2514 PATH "$ENV{PROGRAMFILES}/7-Zip" "$ENV{PROGRAMW6432}/7-Zip"
2515 DOC "Path to the 7z utility."
2518 add_custom_target(pdb_zip_package COMMENT "This packages .PDBs but will not create them.")
2519 set_target_properties(pdb_zip_package PROPERTIES FOLDER "Packaging")
2520 set(_pdb_zip "${CMAKE_BINARY_DIR}/Wireshark-pdb-${PROJECT_VERSION}-${WIRESHARK_TARGET_PLATFORM}.zip")
2521 file(TO_NATIVE_PATH "${_pdb_zip}" _pdb_zip_win)
2522 add_custom_command(TARGET pdb_zip_package POST_BUILD
2523 COMMAND ${CMAKE_COMMAND} -E remove -f "${_pdb_zip}"
2524 COMMAND ${ZIP_EXECUTABLE} a -tzip -mmt=on "${_pdb_zip_win}"
2527 WORKING_DIRECTORY "${_dll_output_dir}"
2532 # List of extra dependencies for the "copy_data_files" target
2533 set(copy_data_files_depends)
2536 foreach(_install_as_txt_file COPYING README.md)
2537 # On Windows, install some files with a .txt extension so that they're
2539 string(REGEX REPLACE ".md$" "" _no_md_file ${_install_as_txt_file})
2540 set(_output_file "${DATAFILE_DIR}/${_no_md_file}.txt")
2541 add_custom_command(OUTPUT ${_output_file}
2542 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2543 ${CMAKE_SOURCE_DIR}/${_install_as_txt_file}
2546 ${CMAKE_SOURCE_DIR}/${_install_as_txt_file}
2548 list(APPEND copy_data_files_depends "${_output_file}")
2552 foreach(_install_file ${INSTALL_FILES} ${DOC_FILES})
2553 get_filename_component(_install_file_src "${_install_file}" ABSOLUTE)
2554 get_filename_component(_install_basename "${_install_file}" NAME)
2555 set(_output_file "${DATAFILE_DIR}/${_install_basename}")
2556 add_custom_command(OUTPUT "${_output_file}"
2557 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2558 "${_install_file_src}"
2564 list(APPEND copy_data_files_depends "${_output_file}")
2567 if (BUILD_stratoshark)
2568 if (ENABLE_APPLICATION_BUNDLE)
2569 foreach(_install_file ${STRATOSHARK_INSTALL_FILES} ${DOC_FILES})
2570 get_filename_component(_install_file_src "${_install_file}" ABSOLUTE)
2571 get_filename_component(_install_basename "${_install_file}" NAME)
2572 set(_output_file "${STRATOSHARK_DATAFILE_DIR}/${_install_basename}")
2573 add_custom_command(OUTPUT "${_output_file}"
2574 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2575 "${_install_file_src}"
2581 list(APPEND copy_data_files_depends "${_output_file}")
2584 # XXX The default profile (colorfilters, dfilters) is at the
2585 # top-level resources directory for both Wireshark and Stratoshark.
2589 set(_protocol_data_dir ${CMAKE_SOURCE_DIR}/resources/protocols)
2590 # Glob patterns relative to the source directory that should be copied to
2591 # ${DATAFILE_DIR} (including directory prefixes)
2592 # TODO shouldn't this use full (relative) paths instead of glob patterns?
2594 ${_protocol_data_dir}/tpncp/tpncp.dat
2595 ${_protocol_data_dir}/wimaxasncp/*.dtd
2596 ${_protocol_data_dir}/wimaxasncp/*.xml
2599 # Copy all paths from the source tree to the data directory. Directories are
2600 # automatically created if missing as the filename is given.
2601 file(GLOB _data_files RELATIVE ${_protocol_data_dir} ${DATA_FILES_SRC})
2602 foreach(_data_file ${_data_files})
2603 add_custom_command(OUTPUT "${DATAFILE_DIR}/${_data_file}"
2604 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2605 ${_protocol_data_dir}/${_data_file}
2606 ${DATAFILE_DIR}/${_data_file}
2608 ${_protocol_data_dir}/${_data_file}
2610 list(APPEND copy_data_files_depends ${DATAFILE_DIR}/${_data_file})
2613 file(GLOB _dtds_src_files RELATIVE ${_protocol_data_dir} ${_protocol_data_dir}/dtds/*.dtd)
2615 set (_dtds_data_files)
2616 set (_dtds_dep_files)
2617 foreach(_data_file ${_dtds_src_files})
2618 list(APPEND _dtds_data_files ${DATAFILE_DIR}/${_data_file})
2619 list(APPEND _dtds_dep_files ${_protocol_data_dir}/${_data_file})
2623 OUTPUT ${_dtds_data_files}
2624 COMMAND ${CMAKE_COMMAND} -E make_directory ${DATAFILE_DIR}/dtds
2625 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2627 ${DATAFILE_DIR}/dtds
2629 DEPENDS ${_dtds_dep_files}
2630 WORKING_DIRECTORY ${_protocol_data_dir}
2633 file(GLOB _diameter_src_files RELATIVE ${_protocol_data_dir}
2634 ${_protocol_data_dir}/diameter/*.dtd
2635 ${_protocol_data_dir}/diameter/*.xml
2638 set (_diameter_data_files)
2639 set (_diameter_dep_files)
2640 foreach(_data_file ${_diameter_src_files})
2641 list(APPEND _diameter_data_files ${DATAFILE_DIR}/${_data_file})
2642 list(APPEND _diameter_dep_files ${_protocol_data_dir}/${_data_file})
2646 OUTPUT ${_diameter_data_files}
2647 COMMAND ${CMAKE_COMMAND} -E make_directory ${DATAFILE_DIR}/diameter
2648 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2649 ${_diameter_src_files}
2650 ${DATAFILE_DIR}/diameter
2652 DEPENDS ${_diameter_dep_files}
2653 WORKING_DIRECTORY ${_protocol_data_dir}
2656 file(GLOB _radius_src_files RELATIVE ${_protocol_data_dir}
2658 ${_protocol_data_dir}/radius/README.radius_dictionary
2659 ${_protocol_data_dir}/radius/custom.includes
2660 ${_protocol_data_dir}/radius/dictionary
2661 ${_protocol_data_dir}/radius/dictionary.*
2664 set (_radius_data_files)
2665 set (_radius_dep_files)
2666 foreach(_data_file ${_radius_src_files})
2667 list(APPEND _radius_data_files ${DATAFILE_DIR}/${_data_file})
2668 list(APPEND _radius_dep_files ${_protocol_data_dir}/${_data_file})
2672 OUTPUT ${_radius_data_files}
2673 COMMAND ${CMAKE_COMMAND} -E make_directory ${DATAFILE_DIR}/radius
2674 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2675 ${_radius_src_files}
2676 ${DATAFILE_DIR}/radius
2678 DEPENDS ${_radius_dep_files}
2679 WORKING_DIRECTORY ${_protocol_data_dir}
2682 file(GLOB _protobuf_src_files RELATIVE ${_protocol_data_dir}
2683 ${_protocol_data_dir}/protobuf/*.proto
2685 set (_protobuf_data_files)
2686 set (_protobuf_dep_files)
2687 foreach(_data_file ${_protobuf_src_files})
2688 list(APPEND _protobuf_data_files ${DATAFILE_DIR}/${_data_file})
2689 list(APPEND _protobuf_dep_files ${_protocol_data_dir}/${_data_file})
2693 OUTPUT ${_protobuf_data_files}
2694 COMMAND ${CMAKE_COMMAND} -E make_directory ${DATAFILE_DIR}/protobuf
2695 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2696 ${_protobuf_src_files}
2697 ${DATAFILE_DIR}/protobuf
2699 DEPENDS ${_protobuf_dep_files}
2700 WORKING_DIRECTORY ${_protocol_data_dir}
2703 set(_profiles_src_dir ${CMAKE_SOURCE_DIR}/resources/share/wireshark)
2704 file(GLOB _profiles_src_files RELATIVE ${_profiles_src_dir} ${_profiles_src_dir}/profiles/*/*)
2705 set (_profiles_data_files)
2706 foreach(_data_file ${_profiles_src_files})
2707 list(APPEND _profiles_data_files "${DATAFILE_DIR}/${_data_file}")
2711 OUTPUT ${_profiles_data_files}
2712 COMMAND ${CMAKE_COMMAND} -E copy_directory
2713 "${CMAKE_SOURCE_DIR}/resources/share/wireshark/profiles" "${DATAFILE_DIR}/profiles"
2716 set (_stratoshark_profiles_data_files)
2717 if (BUILD_stratoshark AND ENABLE_APPLICATION_BUNDLE)
2718 set(_profiles_src_dir ${CMAKE_SOURCE_DIR}/resources/share/stratoshark)
2719 file(GLOB _profiles_src_files RELATIVE ${_profiles_src_dir} ${_profiles_src_dir}/profiles/*/*)
2720 foreach(_data_file ${_profiles_src_files})
2721 list(APPEND _stratoshark_profiles_data_files "${STRATOSHARK_DATAFILE_DIR}/${_data_file}")
2725 OUTPUT ${_stratoshark_profiles_data_files}
2726 COMMAND ${CMAKE_COMMAND} -E copy_directory
2727 "${CMAKE_SOURCE_DIR}/resources/share/stratoshark/profiles" "${STRATOSHARK_DATAFILE_DIR}/profiles"
2731 list(APPEND copy_data_files_depends
2733 ${_diameter_data_files}
2734 ${_radius_data_files}
2735 ${_protobuf_data_files}
2736 ${_profiles_data_files}
2737 ${_stratoshark_profiles_data_files}
2740 # Copy files including ${INSTALL_FILES} and ${INSTALL_DIRS} to ${DATAFILE_DIR}
2741 add_custom_target(copy_data_files ALL DEPENDS ${copy_data_files_depends} )
2742 set_target_properties(copy_data_files PROPERTIES FOLDER "Copy Tasks")
2744 # sources common for wireshark, tshark, rawshark and sharkd
2745 add_library(shark_common OBJECT
2748 file_packet_provider.c
2751 add_library(cli_main OBJECT cli_main.c)
2753 if(BUILD_wireshark AND QT_FOUND)
2761 $<TARGET_OBJECTS:shark_common>
2763 ${PLATFORM_UI_RC_FILES}
2765 set_executable_resources(wireshark "Wireshark" UNIQUE_RC)
2768 if(BUILD_stratoshark AND QT_FOUND)
2775 set(stratoshark_FILES
2776 $<TARGET_OBJECTS:shark_common>
2778 ${PLATFORM_UI_RC_FILES}
2780 set_executable_resources(stratoshark "Stratoshark" UNIQUE_RC)
2783 if(ENABLE_APPLICATION_BUNDLE)
2785 # Add -Wl,-single_module to the LDFLAGS used with shared
2786 # libraries, to fix some error that show up in some cases;
2787 # some Apple documentation recommends it for most shared
2790 set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-single_module ${CMAKE_SHARED_LINKER_FLAGS}" )
2792 # Add -Wl,-headerpad_max_install_names to the LDFLAGS, as
2793 # code-signing issues is running out of padding space.
2795 # Add -Wl,-search_paths_first to make sure that if we search
2796 # directories A and B, in that order, for a given library, a
2797 # non-shared version in directory A, rather than a shared
2798 # version in directory B, is chosen (so we can use
2799 # --with-pcap=/usr/local to force all programs to be linked
2800 # with a static version installed in /usr/local/lib rather than
2801 # the system version in /usr/lib).
2804 set(CMAKE_EXE_LINKER_FLAGS
2805 "-Wl,-headerpad_max_install_names -Wl,-search_paths_first ${CMAKE_EXE_LINKER_FLAGS}"
2808 # Add files to the Wireshark application bundle
2809 # Wireshark.app/Contents
2810 file(WRITE ${CMAKE_BINARY_DIR}/packaging/macosx/wireshark/PkgInfo "APPLWshk\n")
2811 set(WIRESHARK_BUNDLE_CONTENTS_FILES
2812 ${CMAKE_BINARY_DIR}/packaging/macosx/wireshark/PkgInfo
2814 set_source_files_properties(${WIRESHARK_BUNDLE_CONTENTS_FILES} PROPERTIES
2815 MACOSX_PACKAGE_LOCATION .
2818 # Wireshark.app/Contents/Resources
2819 set(WIRESHARK_BUNDLE_RESOURCE_FILES
2820 ${CMAKE_SOURCE_DIR}/packaging/macosx/Wireshark.icns
2821 ${CMAKE_SOURCE_DIR}/packaging/macosx/Wiresharkdoc.icns
2823 set_source_files_properties(${WIRESHARK_BUNDLE_RESOURCE_FILES} PROPERTIES
2824 MACOSX_PACKAGE_LOCATION Resources
2827 # Wireshark.app/Contents/Resources/share/man/man1
2828 set_source_files_properties(${WIRESHARK_BUNDLE_RESOURCE_SHARE_MAN1_FILES} PROPERTIES
2829 MACOSX_PACKAGE_LOCATION Resources/share/man/man1
2833 # Wireshark.app/Contents/Resources/share/man/man4
2834 set_source_files_properties(${WIRESHARK_BUNDLE_RESOURCE_SHARE_MAN4_FILES} PROPERTIES
2835 MACOSX_PACKAGE_LOCATION Resources/share/man/man4
2839 # INSTALL_FILES and INSTALL_DIRS are handled by copy_data_files
2841 set(EXTRA_WIRESHARK_BUNDLE_FILES
2842 ${WIRESHARK_BUNDLE_CONTENTS_FILES}
2843 ${WIRESHARK_BUNDLE_RESOURCE_FILES}
2844 ${WIRESHARK_BUNDLE_RESOURCE_SHARE_MAN1_FILES}
2845 ${WIRESHARK_BUNDLE_RESOURCE_SHARE_MAN4_FILES}
2848 # Add files to the Stratoshark application bundle
2849 # Stratoshark.app/Contents
2850 file(WRITE ${CMAKE_BINARY_DIR}/packaging/macosx/stratoshark/PkgInfo "APPLLgry\n")
2851 set(STRATOSHARK_BUNDLE_CONTENTS_FILES
2852 ${CMAKE_BINARY_DIR}/packaging/macosx/stratoshark/PkgInfo
2854 set_source_files_properties(${STRATOSHARK_BUNDLE_CONTENTS_FILES} PROPERTIES
2855 MACOSX_PACKAGE_LOCATION .
2858 # Stratoshark.app/Contents/Resources
2859 set(STRATOSHARK_BUNDLE_RESOURCE_FILES
2860 ${CMAKE_SOURCE_DIR}/packaging/macosx/Stratoshark.icns
2861 ${CMAKE_SOURCE_DIR}/packaging/macosx/Wiresharkdoc.icns
2863 set_source_files_properties(${STRATOSHARK_BUNDLE_RESOURCE_FILES} PROPERTIES
2864 MACOSX_PACKAGE_LOCATION Resources
2867 # Stratoshark.app/Contents/Resources/share/man/man1
2868 set_source_files_properties(${STRATOSHARK_BUNDLE_RESOURCE_SHARE_MAN1_FILES} PROPERTIES
2869 MACOSX_PACKAGE_LOCATION Resources/share/man/man1
2873 # Stratoshark.app/Contents/Resources/share/man/man4
2874 set_source_files_properties(${STRATOSHARK_BUNDLE_RESOURCE_SHARE_MAN4_FILES} PROPERTIES
2875 MACOSX_PACKAGE_LOCATION Resources/share/man/man4
2879 # INSTALL_FILES and INSTALL_DIRS are handled by copy_data_files
2881 set(EXTRA_STRATOSHARK_BUNDLE_FILES
2882 ${STRATOSHARK_BUNDLE_CONTENTS_FILES}
2883 ${STRATOSHARK_BUNDLE_RESOURCE_FILES}
2884 ${STRATOSHARK_BUNDLE_RESOURCE_SHARE_MAN1_FILES}
2885 ${STRATOSHARK_BUNDLE_RESOURCE_SHARE_MAN4_FILES}
2889 set(EXTRA_WIRESHARK_BUNDLE_FILES)
2890 set(EXTRA_STRATOSHARK_BUNDLE_FILES)
2893 if(BUILD_wireshark AND QT_FOUND)
2904 ${APPLE_APPLICATION_SERVICES_LIBRARY}
2905 ${APPLE_APPKIT_LIBRARY}
2906 ${APPLE_CORE_FOUNDATION_LIBRARY}
2907 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
2908 ${SPARKLE_LIBRARIES}
2909 ${WIN_WS2_32_LIBRARY}
2910 ${WIN_VERSION_LIBRARY}
2911 ${WINSPARKLE_LIBRARIES}
2912 $<$<BOOL:${WIN32}>:uxtheme.lib>
2913 ${SPEEXDSP_LIBRARIES}
2916 ${MINIZIP_LIBRARIES}
2917 ${MINIZIPNG_LIBRARIES}
2920 add_executable(wireshark WIN32 MACOSX_BUNDLE ${wireshark_FILES} ${EXTRA_WIRESHARK_BUNDLE_FILES})
2922 set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT wireshark)
2924 set(PROGLIST ${PROGLIST} wireshark)
2925 set_target_properties(wireshark PROPERTIES
2926 LINK_FLAGS "${WS_LINK_FLAGS}"
2927 FOLDER "Executables"
2928 INSTALL_RPATH "${EXECUTABLE_INSTALL_RPATH}"
2934 set_target_properties(wireshark PROPERTIES LINK_FLAGS_DEBUG "${WS_MSVC_DEBUG_LINK_FLAGS}")
2937 set_target_properties(wireshark PROPERTIES OUTPUT_NAME wireshark)
2938 elseif(ENABLE_APPLICATION_BUNDLE OR WIN32)
2939 set_target_properties(wireshark PROPERTIES OUTPUT_NAME Wireshark)
2942 if(ENABLE_APPLICATION_BUNDLE)
2943 if(ASCIIDOCTOR_FOUND)
2944 # Make sure to generate files referenced by
2945 # WIRESHARK_BUNDLE_RESOURCE_SHARE_MAN1_FILES
2946 add_dependencies(wireshark manpages)
2948 set_target_properties(
2949 wireshark PROPERTIES
2950 MACOSX_BUNDLE_INFO_PLIST ${CMAKE_BINARY_DIR}/packaging/macosx/WiresharkInfo.plist
2952 if(CMAKE_CFG_INTDIR STREQUAL ".")
2953 # Add a wrapper script which opens the bundle. This is more convenient
2954 # and lets Sparkle find our CFBundleIdentifier, but means that you have
2955 # to pass the full path to run/Wireshark.app/Contents/MacOS/Wireshark
2957 # It is not created if using Xcode
2958 file(REMOVE ${CMAKE_BINARY_DIR}/run/wireshark)
2959 file(WRITE ${CMAKE_BINARY_DIR}/run/wireshark "#!/bin/sh\n")
2960 file(APPEND ${CMAKE_BINARY_DIR}/run/wireshark "# Generated by ${CMAKE_CURRENT_LIST_FILE}\n")
2961 file(APPEND ${CMAKE_BINARY_DIR}/run/wireshark "# Wrapper script which ensures that we're properly activated via Launch Services\n")
2962 file(APPEND ${CMAKE_BINARY_DIR}/run/wireshark "exec \"${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/MacOS/Wireshark\" \"\$\@\"\n")
2963 execute_process(COMMAND chmod a+x ${CMAKE_BINARY_DIR}/run/wireshark)
2967 target_link_libraries(wireshark ${wireshark_LIBS})
2968 target_include_directories(wireshark SYSTEM PRIVATE ${SPARKLE_INCLUDE_DIRS})
2972 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
2973 BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
2976 if(QT_WINDEPLOYQT_EXECUTABLE)
2977 add_custom_target(copy_qt_dlls ALL)
2978 set_target_properties(copy_qt_dlls PROPERTIES FOLDER "Copy Tasks")
2979 # Will we ever need to use --debug? Windeployqt seems to
2980 # be smart enough to copy debug DLLs when needed.
2981 if (USE_MSYSTEM AND Qt${qtver}Widgets_VERSION VERSION_EQUAL 6.5.0)
2982 # windeployqt released with Qt 6.5.0 is broken.
2983 # https://bugreports.qt.io/browse/QTBUG-112204
2984 message(WARNING "Qt Deploy Tool 6.5.0 is broken, please upgrade to a later version.")
2985 # lconvert will fail
2987 add_custom_command(TARGET copy_qt_dlls
2989 COMMAND set "PATH=${QT_BIN_PATH};%PATH%"
2990 COMMAND "${QT_WINDEPLOYQT_EXECUTABLE}"
2991 ${QT_WINDEPLOYQT_EXTRA_ARGS}
2992 --no-compiler-runtime
2994 $<$<BOOL:${MSVC}>:--pdb>
2995 "$<TARGET_FILE:wireshark>"
2997 add_dependencies(copy_qt_dlls wireshark)
2999 install(CODE "execute_process(COMMAND
3000 \"${QT_WINDEPLOYQT_EXECUTABLE}\"
3001 --no-compiler-runtime
3002 \"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/Wireshark.exe\")"
3005 endif(QT_WINDEPLOYQT_EXECUTABLE)
3008 if(BUILD_stratoshark AND QT_FOUND)
3009 set(stratoshark_LIBS
3019 ${APPLE_APPLICATION_SERVICES_LIBRARY}
3020 ${APPLE_APPKIT_LIBRARY}
3021 ${APPLE_CORE_FOUNDATION_LIBRARY}
3022 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
3023 ${SPARKLE_LIBRARIES}
3024 ${WIN_WS2_32_LIBRARY}
3025 ${WIN_VERSION_LIBRARY}
3026 ${WINSPARKLE_LIBRARIES}
3027 $<$<BOOL:${WIN32}>:uxtheme.lib>
3028 ${SPEEXDSP_LIBRARIES}
3031 ${MINIZIP_LIBRARIES}
3032 ${MINIZIPNG_LIBRARIES}
3035 add_executable(stratoshark WIN32 MACOSX_BUNDLE ${stratoshark_FILES} ${EXTRA_STRATOSHARK_BUNDLE_FILES})
3036 if(WIN32 AND NOT BUILD_wireshark)
3037 set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT stratoshark)
3039 set(PROGLIST ${PROGLIST} stratoshark)
3040 set_target_properties(stratoshark PROPERTIES
3041 LINK_FLAGS "${WS_LINK_FLAGS}"
3042 FOLDER "Executables"
3043 INSTALL_RPATH "${EXECUTABLE_INSTALL_RPATH}"
3049 set_target_properties(stratoshark PROPERTIES LINK_FLAGS_DEBUG "${WS_MSVC_DEBUG_LINK_FLAGS}")
3051 if(ENABLE_APPLICATION_BUNDLE OR WIN32)
3052 set_target_properties(stratoshark PROPERTIES OUTPUT_NAME Stratoshark)
3055 if(ENABLE_APPLICATION_BUNDLE)
3056 if(ASCIIDOCTOR_FOUND)
3057 # Make sure to generate files referenced by
3058 # STRATOSHARK_BUNDLE_RESOURCE_SHARE_MAN1_FILES
3059 add_dependencies(stratoshark manpages)
3061 set_target_properties(
3062 stratoshark PROPERTIES
3063 MACOSX_BUNDLE_INFO_PLIST ${CMAKE_BINARY_DIR}/packaging/macosx/StratosharkInfo.plist
3065 if(CMAKE_CFG_INTDIR STREQUAL ".")
3066 # Add a wrapper script which opens the bundle. This is more convenient
3067 # and lets Sparkle find our CFBundleIdentifier, but means that you have
3068 # to pass the full path to run/Wireshark.app/Contents/MacOS/Stratoshark
3070 # It is not created if using Xcode
3071 file(REMOVE ${CMAKE_BINARY_DIR}/run/stratoshark)
3072 file(WRITE ${CMAKE_BINARY_DIR}/run/stratoshark "#!/bin/sh\n")
3073 file(APPEND ${CMAKE_BINARY_DIR}/run/stratoshark "# Generated by ${CMAKE_CURRENT_LIST_FILE}\n")
3074 file(APPEND ${CMAKE_BINARY_DIR}/run/stratoshark "# Wrapper script which ensures that we're properly activated via Launch Services\n")
3075 file(APPEND ${CMAKE_BINARY_DIR}/run/stratoshark "exec \"${CMAKE_BINARY_DIR}/run/Stratoshark.app/Contents/MacOS/Stratoshark\" \"\$\@\"\n")
3076 execute_process(COMMAND chmod a+x ${CMAKE_BINARY_DIR}/run/stratoshark)
3080 target_link_libraries(stratoshark ${stratoshark_LIBS})
3081 target_include_directories(stratoshark SYSTEM PRIVATE ${SPARKLE_INCLUDE_DIRS})
3085 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
3086 BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
3089 # The build can fail if the copy_stratoshark_qt_dlls target is run at
3090 # the same time as the copy_qt_dlls target, so just assume that
3091 # copy_qt_dlls will provide everything we need for now.
3092 if(QT_WINDEPLOYQT_EXECUTABLE AND NOT BUILD_wireshark)
3093 add_custom_target(copy_stratoshark_qt_dlls ALL)
3094 set_target_properties(copy_stratoshark_qt_dlls PROPERTIES FOLDER "Copy Tasks")
3095 # Will we ever need to use --debug? Windeployqt seems to
3096 # be smart enough to copy debug DLLs when needed.
3097 add_custom_command(TARGET copy_stratoshark_qt_dlls
3099 COMMAND set "PATH=${QT_BIN_PATH};%PATH%"
3100 COMMAND "${QT_WINDEPLOYQT_EXECUTABLE}"
3101 --no-compiler-runtime
3103 $<$<BOOL:${MSVC}>:--pdb>
3104 "$<TARGET_FILE:stratoshark>"
3106 add_dependencies(copy_stratoshark_qt_dlls stratoshark)
3108 install(CODE "execute_process(COMMAND
3109 \"${QT_WINDEPLOYQT_EXECUTABLE}\"
3110 --no-compiler-runtime
3111 \"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/Stratoshark.exe\")"
3114 endif(QT_WINDEPLOYQT_EXECUTABLE AND NOT BUILD_wireshark)
3117 if (BUILD_stratoshark AND FALCO_PLUGINS)
3118 add_custom_target(copy_falco_plugins)
3119 add_custom_command(TARGET copy_falco_plugins POST_BUILD
3120 # XXX Falco plugins should probably be installed in a path that reflects
3121 # the Falco version or its plugin API version.
3122 COMMAND ${CMAKE_COMMAND} -E make_directory ${STRATOSHARK_PLUGIN_DIR}/../falco
3123 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FALCO_PLUGINS} ${STRATOSHARK_PLUGIN_DIR}/../falco
3126 add_dependencies(stratoshark copy_falco_plugins)
3129 # Common properties for CLI executables
3130 macro(set_extra_executable_properties _executable _folder)
3131 set_target_properties(${_executable} PROPERTIES
3132 LINK_FLAGS "${WILDCARD_OBJ} ${WS_LINK_FLAGS}"
3134 INSTALL_RPATH "${EXECUTABLE_INSTALL_RPATH}"
3137 set_target_properties(${_executable} PROPERTIES LINK_FLAGS_DEBUG "${WS_MSVC_DEBUG_LINK_FLAGS}")
3140 set(PROGLIST ${PROGLIST} ${_executable})
3142 if(ENABLE_APPLICATION_BUNDLE)
3143 if(NOT CMAKE_CFG_INTDIR STREQUAL ".")
3145 set_target_properties(${_executable} PROPERTIES
3146 RUNTIME_OUTPUT_DIRECTORY run/$<CONFIG>/Wireshark.app/Contents/MacOS
3149 set_target_properties(${_executable} PROPERTIES
3150 RUNTIME_OUTPUT_DIRECTORY run/Wireshark.app/Contents/MacOS
3152 # Create a convenience link from run/<name> to its respective
3153 # target in the application bundle.
3154 add_custom_target(${_executable}-symlink
3156 Wireshark.app/Contents/MacOS/${_executable}
3157 ${CMAKE_BINARY_DIR}/run/${_executable}
3159 add_dependencies(${_executable} ${_executable}-symlink)
3164 macro(executable_link_mingw_unicode _target)
3165 # target_link_options() requires CMake >= 3.13
3167 target_link_options(${_target} PRIVATE "-municode")
3171 register_tap_files(tshark-tap-register.c
3184 ${APPLE_CORE_FOUNDATION_LIBRARY}
3185 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
3186 ${WIN_WS2_32_LIBRARY}
3189 $<TARGET_OBJECTS:cli_main>
3190 $<TARGET_OBJECTS:shark_common>
3191 tshark-tap-register.c
3197 set_executable_resources(tshark "TShark" UNIQUE_RC)
3198 add_executable(tshark ${tshark_FILES})
3199 set_extra_executable_properties(tshark "Executables")
3200 target_link_libraries(tshark ${tshark_LIBS})
3201 executable_link_mingw_unicode(tshark)
3202 install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3211 ${APPLE_CORE_FOUNDATION_LIBRARY}
3212 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
3215 $<TARGET_OBJECTS:cli_main>
3216 $<TARGET_OBJECTS:shark_common>
3220 set_executable_resources(tfshark "TFShark")
3221 add_executable(tfshark ${tfshark_FILES})
3222 set_extra_executable_properties(tfshark "Executables")
3223 target_link_libraries(tfshark ${tfshark_LIBS})
3224 install(TARGETS tfshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3227 if(BUILD_rawshark AND PCAP_FOUND)
3233 ${APPLE_CORE_FOUNDATION_LIBRARY}
3234 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
3235 ${WIN_WS2_32_LIBRARY}
3238 $<TARGET_OBJECTS:cli_main>
3239 $<TARGET_OBJECTS:shark_common>
3242 set_executable_resources(rawshark "Rawshark")
3243 add_executable(rawshark ${rawshark_FILES})
3244 set_extra_executable_properties(rawshark "Executables")
3245 target_link_libraries(rawshark ${rawshark_LIBS})
3246 executable_link_mingw_unicode(rawshark)
3247 install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3255 ${APPLE_CORE_FOUNDATION_LIBRARY}
3256 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
3257 ${WIN_WS2_32_LIBRARY}
3258 ${SPEEXDSP_LIBRARIES}
3263 # XXX - currently doesn't work on Windows if it uses
3264 # $<TARGET_OBJECTS:cli_main> and has real_main().
3266 $<TARGET_OBJECTS:shark_common>
3267 ui/cli/simple_dialog.c
3273 set_executable_resources(sharkd "SharkD")
3274 add_executable(sharkd ${sharkd_FILES})
3275 set_extra_executable_properties(sharkd "Executables")
3276 target_link_libraries(sharkd ${sharkd_LIBS})
3277 target_include_directories(sharkd SYSTEM PUBLIC ${SPEEXDSP_INCLUDE_DIRS})
3279 install(TARGETS sharkd RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3291 set_executable_resources(dftest "Dftest")
3292 add_executable(dftest ${dftest_FILES})
3293 set_extra_executable_properties(dftest "Tests")
3294 target_link_libraries(dftest ${dftest_LIBS})
3296 install(TARGETS dftest RUNTIME
3297 DESTINATION ${CMAKE_INSTALL_BINDIR}
3298 COMPONENT "Development"
3311 $<TARGET_OBJECTS:cli_main>
3314 set_executable_resources(randpkt "Randpkt"
3315 COPYRIGHT_INFO "Copyright (C) 1999 by Gilbert Ramirez <gram@alumni.rice.edu>")
3316 add_executable(randpkt ${randpkt_FILES})
3317 set_extra_executable_properties(randpkt "Executables")
3318 target_link_libraries(randpkt ${randpkt_LIBS})
3319 executable_link_mingw_unicode(randpkt)
3320 install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3323 if(BUILD_fuzzshark OR ENABLE_FUZZER OR OSS_FUZZ)
3324 add_subdirectory(fuzz)
3337 $<TARGET_OBJECTS:cli_main>
3340 set_executable_resources(text2pcap "Text2pcap"
3341 COPYRIGHT_INFO "2001 Ashok Narayanan <ashokn@cisco.com>")
3342 add_executable(text2pcap ${text2pcap_FILES})
3343 set_extra_executable_properties(text2pcap "Executables")
3344 target_link_libraries(text2pcap ${text2pcap_LIBS})
3345 executable_link_mingw_unicode(text2pcap)
3346 install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3358 $<TARGET_OBJECTS:cli_main>
3361 set_executable_resources(mergecap "Mergecap")
3362 add_executable(mergecap ${mergecap_FILES})
3363 set_extra_executable_properties(mergecap "Executables")
3364 target_link_libraries(mergecap ${mergecap_LIBS})
3365 executable_link_mingw_unicode(mergecap)
3366 install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3369 if(BUILD_reordercap)
3377 set(reordercap_FILES
3378 $<TARGET_OBJECTS:cli_main>
3381 set_executable_resources(reordercap "Reordercap")
3382 add_executable(reordercap ${reordercap_FILES})
3383 set_extra_executable_properties(reordercap "Executables")
3384 target_link_libraries(reordercap ${reordercap_LIBS})
3385 executable_link_mingw_unicode(reordercap)
3386 install(TARGETS reordercap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3400 $<TARGET_OBJECTS:cli_main>
3403 set_executable_resources(capinfos "Capinfos")
3404 add_executable(capinfos ${capinfos_FILES})
3405 set_extra_executable_properties(capinfos "Executables")
3406 target_link_libraries(capinfos ${capinfos_LIBS})
3407 target_include_directories(capinfos SYSTEM PRIVATE ${GCRYPT_INCLUDE_DIRS})
3408 executable_link_mingw_unicode(capinfos)
3409 install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3422 $<TARGET_OBJECTS:cli_main>
3425 set_executable_resources(captype "Captype")
3426 add_executable(captype ${captype_FILES})
3427 set_extra_executable_properties(captype "Executables")
3428 target_link_libraries(captype ${captype_LIBS})
3429 executable_link_mingw_unicode(captype)
3430 install(TARGETS captype RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3443 $<TARGET_OBJECTS:cli_main>
3446 set_executable_resources(editcap "Editcap")
3447 add_executable(editcap ${editcap_FILES})
3448 set_extra_executable_properties(editcap "Executables")
3449 target_link_libraries(editcap ${editcap_LIBS})
3450 target_include_directories(editcap SYSTEM PRIVATE ${GCRYPT_INCLUDE_DIRS})
3451 executable_link_mingw_unicode(editcap)
3452 install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3455 if(BUILD_dumpcap AND PCAP_FOUND)
3462 ${APPLE_CORE_FOUNDATION_LIBRARY}
3463 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
3464 ${WIN_WS2_32_LIBRARY}
3467 list(APPEND CAPUTILS_SRC
3468 capture/capture-pcap-util-unix.c)
3471 list(APPEND CAPUTILS_SRC
3472 capture/capture_win_ifnames.c
3473 capture/capture-wpcap.c
3476 list(APPEND CAPUTILS_SRC
3477 capture/capture-pcap-util.c
3480 # We don't link with libiface_monitor or libui because those
3481 # are built to be linked against libwsutil as a shared library,
3482 # and dumpcap is deliberately not linked against any of
3483 # Wireshark's shared libraries, to reduce the amount of code
3484 # it uses, and linking against the non-shared libiface_monitor
3485 # or libui libraries will fail on Windows.
3487 # Instead, we just include source files for the relevant code
3488 # to be built as part of dumpcap, so that they're built with
3489 # ENABLE_STATIC defined, and will be able to be built with
3490 # the static version of libwsutil.
3497 capture/iface_monitor.c
3498 capture/ws80211_utils.c
3502 set_executable_resources(dumpcap "Dumpcap" UNIQUE_RC)
3503 add_executable(dumpcap ${dumpcap_FILES})
3504 set_extra_executable_properties(dumpcap "Executables")
3505 target_link_libraries(dumpcap ${dumpcap_LIBS})
3506 target_include_directories(dumpcap SYSTEM PRIVATE ${NL_INCLUDE_DIRS})
3507 target_compile_definitions(dumpcap PRIVATE ENABLE_STATIC)
3508 executable_link_mingw_unicode(dumpcap)
3509 install(TARGETS dumpcap
3510 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
3511 PERMISSIONS ${DUMPCAP_SETUID}
3512 OWNER_READ OWNER_WRITE OWNER_EXECUTE
3513 GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
3515 if(ENABLE_DUMPCAP_GROUP)
3516 install(CODE "execute_process(COMMAND chgrp ${DUMPCAP_INSTALL_GROUP} ${CMAKE_INSTALL_FULL_BINDIR}/dumpcap)")
3517 install(CODE "execute_process(COMMAND chmod o-x ${CMAKE_INSTALL_FULL_BINDIR}/dumpcap)")
3519 if(DUMPCAP_INSTALL_OPTION STREQUAL "capabilities")
3520 install( CODE "execute_process(
3522 ${SETCAP_EXECUTABLE}
3523 cap_net_raw,cap_net_admin+ep
3524 ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/dumpcap${CMAKE_EXECUTABLE_SUFFIX}
3528 if( _SETCAP_RESULT )
3529 message( WARNING \"setcap failed (${_SETCAP_RESULT}).\")
3533 if(BUILD_stratoshark AND ENABLE_APPLICATION_BUNDLE)
3534 add_custom_command(TARGET dumpcap POST_BUILD
3535 COMMAND ${CMAKE_COMMAND} -E copy_if_different
3536 $<TARGET_FILE:dumpcap> run/Stratoshark.app/Contents/MacOS/dumpcap
3539 elseif(BUILD_dumpcap AND ENABLE_PCAP)
3540 message(WARNING "Dumpcap was requested but libpcap dependency is not available. "
3541 "Wireshark will be built without packet capture capability.")
3544 # We have two idl2wrs utilities: this and the CORBA version in tools.
3545 # We probably shouldn't do that.
3546 if(BUILD_dcerpcidl2wrs)
3551 epan/dissectors/dcerpc/idl2wrs.c
3554 add_executable(idl2wrs ${idl2wrs_FILES})
3555 set_target_properties(idl2wrs PROPERTIES FOLDER "Executables")
3556 set_extra_executable_properties(idl2wrs "Executables")
3557 target_link_libraries(idl2wrs ${idl2wrs_LIBS})
3558 install(TARGETS idl2wrs RUNTIME
3559 DESTINATION ${CMAKE_INSTALL_BINDIR}
3560 COMPONENT "Development"
3566 find_package( MSVC_REDIST )
3568 # Must come after executable targets are defined.
3569 find_package( NSIS )
3571 if(MAKENSIS_EXECUTABLE)
3572 add_subdirectory( packaging/nsis EXCLUDE_FROM_ALL )
3573 ADD_NSIS_PACKAGE_TARGETS()
3578 if(WIX_CANDLE_EXECUTABLE)
3579 add_subdirectory( packaging/wix EXCLUDE_FROM_ALL )
3580 ADD_WIX_PACKAGE_TARGET()
3583 find_package( PortableApps )
3584 if(PORTABLEAPPS_LAUNCHER_GENERATOR_EXECUTABLE AND PORTABLEAPPS_INSTALLER_EXECUTABLE)
3585 add_subdirectory( packaging/portableapps EXCLUDE_FROM_ALL )
3586 ADD_PORTABLEAPPS_PACKAGE_TARGET()
3590 if (MAXMINDDB_FOUND)
3591 set(mmdbresolve_LIBS
3592 # Note: libmaxminddb is not GPL-2 compatible.
3593 ${MAXMINDDB_LIBRARY}
3594 # Needed for CMake-built libmaxminddb.lib <= 1.43.
3595 ${WIN_WS2_32_LIBRARY}
3597 set(mmdbresolve_FILES
3600 set_executable_resources(mmdbresolve "Mmdbresolve")
3601 add_executable(mmdbresolve ${mmdbresolve_FILES})
3602 set_extra_executable_properties(mmdbresolve "Executables")
3603 target_link_libraries(mmdbresolve ${mmdbresolve_LIBS})
3604 target_include_directories(mmdbresolve PUBLIC ${MAXMINDDB_INCLUDE_DIRS})
3605 target_compile_definitions(mmdbresolve PUBLIC ${MAXMINDDB_DEFINITIONS})
3606 install(TARGETS mmdbresolve RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3609 if(ENABLE_APPLICATION_BUNDLE AND ASCIIDOCTOR_FOUND AND (BUILD_wireshark OR BUILD_stratoshark))
3610 set(_wireshark_foundation_donate "packaging/macosx/Donate to the Wireshark Foundation.html")
3611 ASCIIDOCTOR2HTML("packaging/macosx/Donate_to_the_Wireshark_Foundation.adoc"
3612 OUTPUT ${_wireshark_foundation_donate}
3617 if(ENABLE_APPLICATION_BUNDLE AND BUILD_wireshark)
3618 file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}/Wireshark.app/Contents/Resources/Extras")
3620 # --preserve-xattr is undocumented but ensures that we install
3621 # a signed ChmodBPF script.
3622 set (_chmodbpf_version 1.2)
3623 set (install_chmodbpf_component_pkg "${CMAKE_BINARY_DIR}/install.ChmodBPF.pkg")
3624 add_custom_command(OUTPUT "${install_chmodbpf_component_pkg}"
3626 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/root"
3628 -exec chmod 755 "{}" +
3630 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/root/Library/LaunchDaemons/org.wireshark.ChmodBPF.plist"
3632 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/root/Library/Application Support/Wireshark/ChmodBPF/ChmodBPF"
3633 COMMAND "${CMAKE_SOURCE_DIR}/packaging/macosx/osx-extras.sh"
3635 --identifier org.wireshark.ChmodBPF.pkg
3636 --version ${_chmodbpf_version}
3638 --root "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/root"
3639 --scripts "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/install-scripts"
3640 ${install_chmodbpf_component_pkg}
3642 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/root/Library/Application Support/Wireshark/ChmodBPF/ChmodBPF"
3643 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/root/Library/LaunchDaemons/org.wireshark.ChmodBPF.plist"
3644 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/install-scripts/postinstall"
3646 set (install_chmodbpf_pkg "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/Extras/Install ChmodBPF.pkg")
3647 add_custom_command(OUTPUT "${install_chmodbpf_pkg}"
3648 COMMAND productbuild
3649 --identifier org.wireshark.install.ChmodBPF.product
3650 --version ${_chmodbpf_version}
3651 --distribution "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/install-distribution.xml"
3652 --package-path "${CMAKE_BINARY_DIR}"
3653 ${install_chmodbpf_pkg}
3655 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/install-distribution.xml"
3656 ${install_chmodbpf_component_pkg}
3659 set (uninstall_chmodbpf_component_pkg "${CMAKE_BINARY_DIR}/uninstall.ChmodBPF.pkg")
3660 add_custom_command(OUTPUT "${uninstall_chmodbpf_component_pkg}"
3662 --identifier org.wireshark.uninstall.ChmodBPF.pkg
3663 --version ${_chmodbpf_version}
3665 --scripts "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/uninstall-scripts"
3666 ${uninstall_chmodbpf_component_pkg}
3668 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/uninstall-scripts/postinstall"
3670 set (uninstall_chmodbpf_pkg "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/Extras/Uninstall ChmodBPF.pkg")
3671 add_custom_command(OUTPUT "${uninstall_chmodbpf_pkg}"
3672 COMMAND productbuild
3673 --identifier org.wireshark.uninstall.ChmodBPF.product
3674 --version ${_chmodbpf_version}
3675 --distribution "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/uninstall-distribution.xml"
3676 --package-path "${CMAKE_BINARY_DIR}"
3677 ${uninstall_chmodbpf_pkg}
3679 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/uninstall-distribution.xml"
3680 ${uninstall_chmodbpf_component_pkg}
3683 add_custom_target(chmodbpf DEPENDS ${install_chmodbpf_pkg} ${uninstall_chmodbpf_pkg})
3685 set (_path_helper_version 1.1)
3686 set (install_path_helper_component_pkg "${CMAKE_BINARY_DIR}/install.path_helper.pkg")
3687 add_custom_command(OUTPUT "${install_path_helper_component_pkg}"
3689 "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/root"
3691 -exec chmod 755 "{}" +
3693 "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/root"
3695 -exec chmod 644 "{}" +
3697 --identifier org.wireshark.path_helper.pkg
3698 --version ${_path_helper_version}
3699 --root "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/root/etc"
3700 --install-location /private/etc
3701 ${install_path_helper_component_pkg}
3703 "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/root/etc/paths.d/Wireshark"
3704 "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/root/etc/manpaths.d/Wireshark"
3706 set (install_path_helper_pkg "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/Extras/Add Wireshark to the system path.pkg")
3707 add_custom_command(OUTPUT "${install_path_helper_pkg}"
3708 COMMAND productbuild
3709 --identifier org.wireshark.install.path_helper.product
3710 --version ${_path_helper_version}
3711 --distribution "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/install-distribution.xml"
3712 --package-path "${CMAKE_BINARY_DIR}"
3713 ${install_path_helper_pkg}
3715 "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/install-distribution.xml"
3716 ${install_path_helper_component_pkg}
3719 set (uninstall_path_helper_component_pkg "${CMAKE_BINARY_DIR}/uninstall.path_helper.pkg")
3720 add_custom_command(OUTPUT "${uninstall_path_helper_component_pkg}"
3722 --identifier org.wireshark.uninstall.path_helper.pkg
3723 --version ${_path_helper_version}
3725 --scripts "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/uninstall-scripts"
3726 ${uninstall_path_helper_component_pkg}
3728 "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/uninstall-scripts/postinstall"
3730 set (uninstall_path_helper_pkg "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/Extras/Remove Wireshark from the system path.pkg")
3731 add_custom_command(OUTPUT "${uninstall_path_helper_pkg}"
3732 COMMAND productbuild
3733 --identifier org.wireshark.uninstall.path_helper.product
3734 --version ${_path_helper_version}
3735 --distribution "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/uninstall-distribution.xml"
3736 --package-path "${CMAKE_BINARY_DIR}"
3737 ${uninstall_path_helper_pkg}
3739 ${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/uninstall-distribution.xml
3740 ${uninstall_path_helper_component_pkg}
3743 add_custom_target(path_helper DEPENDS ${install_path_helper_pkg} ${uninstall_path_helper_pkg})
3745 add_custom_target(wireshark_app_bundle)
3746 set_target_properties(wireshark_app_bundle PROPERTIES FOLDER "Copy Tasks")
3747 add_custom_command(TARGET wireshark_app_bundle
3749 COMMAND "${CMAKE_BINARY_DIR}/packaging/macosx/osx-app.sh"
3750 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/run"
3752 add_dependencies(wireshark_app_bundle ${PROGLIST} chmodbpf path_helper)
3754 add_custom_target(wireshark_dmg_prep DEPENDS wireshark_app_bundle)
3756 if (ASCIIDOCTOR_FOUND)
3757 set(_wireshark_read_me_first "packaging/macosx/wireshark/Read me first.html")
3758 ASCIIDOCTOR2HTML("packaging/macosx/Wireshark_read_me_first.adoc"
3759 OUTPUT ${_wireshark_read_me_first}
3763 set(_wireshark_dsym_installation "packaging/macosx/wireshark/Debugging symbols installation.html")
3764 ASCIIDOCTOR2HTML("packaging/macosx/Wireshark_dsym_installation.adoc"
3765 OUTPUT ${_wireshark_dsym_installation}
3769 add_custom_target(wireshark_dmg_readmes DEPENDS ${_wireshark_read_me_first} ${_wireshark_foundation_donate} ${_wireshark_dsym_installation})
3770 add_dependencies(wireshark_dmg_prep wireshark_dmg_readmes)
3773 ADD_CUSTOM_TARGET( wireshark_dmg
3774 COMMAND bash -x ${CMAKE_BINARY_DIR}/packaging/macosx/osx-dmg.sh
3775 # Unlike wireshark_nsis_prep + wireshark_nsis, we can add a direct
3777 DEPENDS wireshark_dmg_prep
3778 # We create Wireshark.app in "run". Do our work there.
3779 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/run
3784 if(ENABLE_APPLICATION_BUNDLE AND BUILD_stratoshark)
3785 add_custom_target(stratoshark_app_bundle)
3786 set_target_properties(stratoshark_app_bundle PROPERTIES FOLDER "Copy Tasks")
3787 add_custom_command(TARGET stratoshark_app_bundle
3789 COMMAND "${CMAKE_BINARY_DIR}/packaging/macosx/osx-app.sh" --bundle Stratoshark.app
3790 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/run"
3793 add_custom_target(stratoshark_dmg_prep DEPENDS stratoshark_app_bundle)
3795 if (ASCIIDOCTOR_FOUND)
3796 set(_stratoshark_read_me_first "packaging/macosx/stratoshark/Read me first.html")
3797 ASCIIDOCTOR2HTML("packaging/macosx/Stratoshark_read_me_first.adoc"
3798 OUTPUT ${_stratoshark_read_me_first}
3802 set(_stratoshark_dsym_installation "packaging/macosx/stratoshark/Debugging symbols installation.html")
3803 ASCIIDOCTOR2HTML("packaging/macosx/Stratoshark_dsym_installation.adoc"
3804 OUTPUT ${_stratoshark_dsym_installation}
3808 add_custom_target(stratoshark_dmg_readmes DEPENDS ${_stratoshark_read_me_first} ${_wireshark_foundation_donate} ${_stratoshark_dsym_installation})
3809 add_dependencies(stratoshark_dmg_prep stratoshark_dmg_readmes)
3812 ADD_CUSTOM_TARGET( stratoshark_dmg
3813 COMMAND bash -x ${CMAKE_BINARY_DIR}/packaging/macosx/osx-dmg.sh --app-name Stratoshark
3814 # Unlike wireshark_nsis_prep + wireshark_nsis, we can add a direct
3816 DEPENDS stratoshark_dmg_prep
3817 # We create Wireshark.app in "run". Do our work there.
3818 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/run
3823 if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
3824 find_program(RPMBUILD_EXECUTABLE rpmbuild)
3825 find_program(GIT_EXECUTABLE git)
3826 # Should we add appimaged's monitored directories
3828 # https://github.com/AppImage/appimaged
3829 find_program(LINUXDEPLOY_EXECUTABLE NAMES linuxdeploy-x86_64.AppImage linuxdeploy)
3830 find_program(_linuxdeploy_plugin_qt NAMES linuxdeploy-plugin-qt-x86_64.AppImage linuxdeploy-plugin-qt)
3831 find_program(APPIMAGETOOL_EXECUTABLE NAMES appimagetool-x86_64.AppImage
3836 string(REPLACE "-" "_" RPM_VERSION "${PROJECT_VERSION}")
3837 configure_file(packaging/rpm/wireshark.spec.in ${CMAKE_BINARY_DIR}/packaging/rpm/SPECS/wireshark.spec)
3838 if(RPMBUILD_EXECUTABLE)
3839 foreach(_rpm_dir BUILD RPMS SOURCES SPECS SRPMS)
3840 file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/packaging/rpm/${_rpm_dir}")
3843 set(_rpmbuild_with_args)
3847 # At least some versions of rpmbuild define the cmake_build
3848 # macro to run "cmake --build" with the "--verbose" option,
3849 # with no obvious way to easily override that, so, if you
3850 # are doing a build with lots of source files, and with
3851 # lots of compiler options (for example, a log of -W flags),
3852 # you can get a lot of output from rpmbuild.
3854 # Wireshark is a program with lots of source files and
3855 # lots of compiler options.
3857 # GitLab's shared builders have a limit of 4MB on logs
3860 # Wireshark uses the shared builders, and can produce
3861 # more than 4MB with the Fedora RPM build; this causes
3862 # the builds to fail.
3864 # Forcibly overriding the cmake_build macro with a
3865 # version that lacks the --version file should
3866 # prevent ninja from being run with the -v flag,
3867 # so that it prints the compact output rather
3868 # than the raw command.
3870 # We don't do that by default; if the build has the
3871 # FORCE_CMAKE_NINJA_QUIET environment variable set,
3874 if(DEFINED ENV{FORCE_CMAKE_NINJA_NON_VERBOSE})
3876 # Get the output of a pipeline running
3877 # "rpmbuild --showrc", to find the settings
3878 # of all macros, piped to an awk script
3879 # to extract the value of the cmake_build
3883 COMMAND rpmbuild --showrc
3884 COMMAND awk "/: cmake_build/ { getline; print \$0; exit }"
3885 OUTPUT_VARIABLE CMAKE_BUILD_VALUE
3886 OUTPUT_STRIP_TRAILING_WHITESPACE)
3887 if (CMAKE_BUILD_VALUE MATCHES ".*--verbose.*")
3889 # OK, the setting contains "--verbose".
3892 string(REPLACE "--verbose" ""
3893 NON_VERBOSE_CMAKE_BUILD_VALUE
3894 ${CMAKE_BUILD_VALUE})
3895 list(APPEND _rpmbuild_with_args --define "cmake_build ${NON_VERBOSE_CMAKE_BUILD_VALUE}")
3898 if(CMAKE_VERBOSE_MAKEFILE)
3899 list(APPEND _rpmbuild_with_args -v)
3902 if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
3903 list(APPEND _rpmbuild_with_args --with toolchain_clang)
3905 if(CMAKE_GENERATOR STREQUAL "Ninja")
3906 list(APPEND _rpmbuild_with_args --with ninja)
3908 if(CCACHE_EXECUTABLE)
3909 list(APPEND _rpmbuild_with_args --with ccache)
3911 if(NOT BUILD_wireshark)
3912 list(APPEND _rpmbuild_with_args --without qt5 --without qt6)
3914 list(APPEND _rpmbuild_with_args --without qt5 --with qt6)
3916 list(APPEND _rpmbuild_with_args --with qt5 --without qt6)
3918 if (MAXMINDDB_FOUND)
3919 list(APPEND _rpmbuild_with_args --with mmdbresolve)
3922 list(APPEND _rpmbuild_with_args --with lua)
3924 if (LZ4_FOUND AND SNAPPY_FOUND)
3925 list(APPEND _rpmbuild_with_args --with lz4_and_snappy)
3928 list(APPEND _rpmbuild_with_args --with spandsp)
3931 list(APPEND _rpmbuild_with_args --with bcg729)
3934 list(APPEND _rpmbuild_with_args --with amrnb)
3937 list(APPEND _rpmbuild_with_args --with ilbc)
3940 list(APPEND _rpmbuild_with_args --with opus)
3943 list(APPEND _rpmbuild_with_args --with libxml2)
3946 list(APPEND _rpmbuild_with_args --with nghttp2)
3949 list(APPEND _rpmbuild_with_args --with nghttp3)
3952 list(APPEND _rpmbuild_with_args --with sdjournal)
3955 list(APPEND _rpmbuild_with_args --with brotli)
3957 if(ASCIIDOCTOR_FOUND AND XSLTPROC_EXECUTABLE)
3958 list(APPEND _rpmbuild_with_args --with guides)
3962 COMMAND ${Python3_EXECUTABLE}
3963 ${CMAKE_SOURCE_DIR}/tools/make-version.py
3967 add_custom_target(copy-dist
3968 COMMAND cp ${CMAKE_BINARY_DIR}/wireshark*tar* ${CMAKE_BINARY_DIR}/packaging/rpm/SOURCES/
3971 add_custom_target(wireshark_rpm
3972 COMMAND ${RPMBUILD_EXECUTABLE}
3973 --define "_topdir ${CMAKE_BINARY_DIR}/packaging/rpm"
3974 --define "_prefix ${CMAKE_INSTALL_PREFIX}"
3975 ${_rpmbuild_with_args}
3976 -ba SPECS/wireshark.spec
3978 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/packaging/rpm"
3979 COMMENT "Create a rpm from the current git commit."
3983 if(BUILD_wireshark AND QT_FOUND AND LINUXDEPLOY_EXECUTABLE AND _linuxdeploy_plugin_qt AND APPIMAGETOOL_EXECUTABLE)
3984 configure_file(packaging/appimage/Wireshark-AppRun.in ${CMAKE_BINARY_DIR}/packaging/appimage/Wireshark-AppRun @ONLY)
3985 # Require production builds (/usr + Release).
3986 if (CMAKE_BUILD_TYPE STREQUAL "Release" AND CMAKE_INSTALL_PREFIX STREQUAL "/usr" )
3987 add_custom_target(wireshark_appimage_prerequisites)
3988 add_dependencies(wireshark_appimage_prerequisites ${PROGLIST})
3990 add_custom_target(wireshark_appimage_prerequisites
3991 COMMAND echo "CMAKE_BUILD_TYPE isn't Release or CMAKE_INSTALL_PREFIX isn't /usr."
3995 set (_wireshark_ai_appdir ${CMAKE_BINARY_DIR}/packaging/appimage/wireshark.appdir)
3996 add_custom_target(wireshark_appimage_appdir
3997 COMMAND ${CMAKE_COMMAND} -E make_directory ${_wireshark_ai_appdir}
3998 COMMAND env DESTDIR=${_wireshark_ai_appdir}
3999 ${CMAKE_COMMAND} --build . --target install
4000 DEPENDS wireshark_appimage_prerequisites
4002 set(_wireshark_appimage_exe_args)
4003 foreach(_prog ${PROGLIST})
4004 # XXX This needs to be more robust.
4005 if (${_prog} STREQUAL "dftest" OR ${_prog} STREQUAL "stratoshark")
4008 list(APPEND _wireshark_appimage_exe_args --executable=${_wireshark_ai_appdir}/usr/bin/${_prog})
4010 # It looks like linuxdeploy can't handle executables in nonstandard
4011 # locations, so use it to prep our staging directory here and use
4012 # appimagetool to to build the appimage.
4013 add_custom_target(wireshark_appimage_prep
4014 COMMAND env LD_LIBRARY_PATH=${_wireshark_ai_appdir}/${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} ${LINUXDEPLOY_EXECUTABLE}
4015 --appdir=${_wireshark_ai_appdir}
4016 ${_wireshark_appimage_exe_args}
4017 --desktop-file=${_wireshark_ai_appdir}/usr/share/applications/org.wireshark.Wireshark.desktop
4018 --icon-file=${CMAKE_SOURCE_DIR}/resources/icons/wsicon256.png
4019 --custom-apprun=${CMAKE_BINARY_DIR}/packaging/appimage/Wireshark-AppRun
4021 DEPENDS wireshark_appimage_appdir
4023 add_custom_target(wireshark_appimage
4024 COMMAND env VERSION=${PROJECT_VERSION} ${APPIMAGETOOL_EXECUTABLE} ${_wireshark_ai_appdir}
4025 DEPENDS wireshark_appimage_prep
4029 if(BUILD_stratoshark AND QT_FOUND AND LINUXDEPLOY_EXECUTABLE AND _linuxdeploy_plugin_qt AND APPIMAGETOOL_EXECUTABLE)
4030 configure_file(packaging/appimage/Stratoshark-AppRun.in ${CMAKE_BINARY_DIR}/packaging/appimage/Stratoshark-AppRun @ONLY)
4031 # Require production builds (/usr + Release).
4032 if (CMAKE_BUILD_TYPE STREQUAL "Release" AND CMAKE_INSTALL_PREFIX STREQUAL "/usr" )
4033 add_custom_target(stratoshark_appimage_prerequisites)
4034 add_dependencies(stratoshark_appimage_prerequisites ${PROGLIST})
4036 add_custom_target(stratoshark_appimage_prerequisites
4037 COMMAND echo "CMAKE_BUILD_TYPE isn't Release or CMAKE_INSTALL_PREFIX isn't /usr."
4041 set (_stratoshark_ai_appdir ${CMAKE_BINARY_DIR}/packaging/appimage/stratoshark.appdir)
4042 add_custom_target(stratoshark_appimage_appdir
4043 COMMAND ${CMAKE_COMMAND} -E make_directory ${_stratoshark_ai_appdir}
4044 COMMAND env DESTDIR=${_stratoshark_ai_appdir}
4045 ${CMAKE_COMMAND} --build . --target install
4046 DEPENDS stratoshark_appimage_prerequisites
4048 set(_stratoshark_appimage_exe_args)
4049 foreach(_prog ${PROGLIST})
4050 # XXX This needs to be more robust.
4051 if (${_prog} STREQUAL "dftest" OR ${_prog} STREQUAL "stratoshark")
4054 list(APPEND _stratoshark_appimage_exe_args --executable=${_stratoshark_ai_appdir}/usr/bin/${_prog})
4056 # It looks like linuxdeploy can't handle executables in nonstandard
4057 # locations, so use it to prep our staging directory here and use
4058 # appimagetool to to build the appimage.
4059 add_custom_target(stratoshark_appimage_prep
4060 COMMAND env LD_LIBRARY_PATH=${_stratoshark_ai_appdir}/${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} ${LINUXDEPLOY_EXECUTABLE}
4061 --appdir=${_stratoshark_ai_appdir}
4062 ${_stratoshark_appimage_exe_args}
4063 --desktop-file=${_stratoshark_ai_appdir}/usr/share/applications/org.wireshark.Stratoshark.desktop
4064 --icon-file=${CMAKE_SOURCE_DIR}/resources/icons/ssicon256.png
4065 --custom-apprun=${CMAKE_BINARY_DIR}/packaging/appimage/Stratoshark-AppRun
4067 DEPENDS stratoshark_appimage_appdir
4069 add_custom_target(stratoshark_appimage
4070 COMMAND env VERSION=${STRATOSHARK_VERSION} ${APPIMAGETOOL_EXECUTABLE} ${_stratoshark_ai_appdir}
4071 DEPENDS stratoshark_appimage_prep
4078 ${stratoshark_FILES}
4084 ${randpktdump_FILES}
4094 ${mmdbresolve_FILES}
4099 # Make sure we don't pass /WX to rc.exe. Rc doesn't have a /WX flag,
4100 # but it does have /W (warn about invalid code pages) and /X (ignore
4101 # the INCLUDE environment variable).
4102 # This should apparently be handled for us via CMAKE_RC_FLAG_REGEX
4103 # in CMakeRCInformation.cmake but that doesn't appear to work.
4105 list(FILTER CLEAN_C_FILES EXCLUDE REGEX ".*\\.rc")
4108 # XXX This also contains object files ($<TARGET_OBJECTS:...>), is that an issue?
4109 set_source_files_properties(
4112 COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
4116 # CMake 3.31 and later warn, if normalization changes a path (CMP0177).
4117 # As we want to normalize without the warning, we do it explicitly.
4118 cmake_path(SET TMP_DST_PATH NORMALIZE "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}")
4123 OWNER_WRITE OWNER_READ
4130 if (BUILD_stratoshark)
4131 cmake_path(SET TMP_DST_PATH NORMALIZE "${CMAKE_INSTALL_DATADIR}/${STRATOSHARK_NAME}")
4134 ${STRATOSHARK_INSTALL_FILES}
4136 OWNER_WRITE OWNER_READ
4148 ${CMAKE_INSTALL_DOCDIR}
4151 if(ASCIIDOCTOR_FOUND AND XSLTPROC_EXECUTABLE)
4153 DIRECTORY "${CMAKE_BINARY_DIR}/doc/wsug_html_chunked"
4154 DESTINATION "${CMAKE_INSTALL_DOCDIR}"
4155 COMPONENT "UserGuide"
4159 DIRECTORY "${CMAKE_BINARY_DIR}/doc/wsdg_html_chunked"
4160 DESTINATION "${CMAKE_INSTALL_DOCDIR}"
4161 COMPONENT "DeveloperGuide"
4166 set(SHARK_PUBLIC_HEADERS
4170 include/ws_attributes.h
4171 include/ws_codepoints.h
4172 include/ws_compiler_tests.h
4173 include/ws_diag_control.h
4174 include/ws_exit_codes.h
4175 include/ws_log_defs.h
4176 include/ws_posix_compat.h
4177 include/ws_symbol_export.h
4179 ${CMAKE_BINARY_DIR}/ws_version.h
4182 install(FILES ${SHARK_PUBLIC_HEADERS}
4183 DESTINATION ${PROJECT_INSTALL_INCLUDEDIR}
4184 COMPONENT "Development"
4188 # Install icons and other desktop files for Freedesktop.org-compliant desktops.
4189 if(BUILD_wireshark AND QT_FOUND AND NOT APPLE AND (NOT WIN32 OR USE_MSYSTEM))
4190 install(FILES resources/freedesktop/org.wireshark.Wireshark-mime.xml
4191 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/mime/packages"
4192 RENAME org.wireshark.Wireshark.xml
4194 install(FILES resources/freedesktop/org.wireshark.Wireshark.metainfo.xml
4195 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo"
4197 if(BUILD_wireshark AND QT_FOUND)
4198 install(FILES resources/freedesktop/org.wireshark.Wireshark.desktop
4199 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
4201 foreach(size 16 24 32 48 64 128 256)
4202 install(FILES resources/icons/wsicon${size}.png
4203 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${size}x${size}/apps"
4204 RENAME org.wireshark.Wireshark.png)
4205 install(FILES resources/icons/WiresharkDoc-${size}.png
4206 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${size}x${size}/mimetypes"
4207 RENAME org.wireshark.Wireshark-mimetype.png)
4211 if(BUILD_stratoshark AND QT_FOUND AND NOT APPLE AND (NOT WIN32 OR USE_MSYSTEM))
4212 install(FILES resources/freedesktop/org.wireshark.Stratoshark-mime.xml
4213 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/mime/packages"
4214 RENAME org.wireshark.Stratoshark.xml
4216 install(FILES resources/freedesktop/org.wireshark.Stratoshark.metainfo.xml
4217 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo"
4219 if(BUILD_wireshark AND QT_FOUND)
4220 install(FILES resources/freedesktop/org.wireshark.Stratoshark.desktop
4221 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
4223 foreach(size 16 32 48 64 128 256)
4224 install(FILES resources/icons/ssicon${size}.png
4225 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${size}x${size}/apps"
4226 RENAME org.wireshark.Stratoshark.png)
4227 install(FILES resources/icons/WiresharkDoc-${size}.png
4228 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${size}x${size}/mimetypes"
4229 RENAME org.wireshark.Stratoshark-mimetype.png)
4231 install(FILES resources/icons/ssicon.svg
4232 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps"
4233 RENAME org.wireshark.Stratoshark.svg)
4236 cmake_path(SET TMP_DST_PATH NORMALIZE "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
4237 install(FILES "${CMAKE_BINARY_DIR}/resources/wireshark.pc"
4238 DESTINATION ${TMP_DST_PATH}
4239 COMPONENT "Development"
4243 cmake_path(SET TMP_DST_PATH NORMALIZE "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}")
4250 OWNER_WRITE OWNER_READ
4253 DIRECTORY_PERMISSIONS
4254 OWNER_EXECUTE OWNER_WRITE OWNER_READ
4255 GROUP_EXECUTE GROUP_READ
4256 WORLD_EXECUTE WORLD_READ
4257 PATTERN ".git" EXCLUDE
4258 PATTERN ".svn" EXCLUDE
4259 PATTERN "Makefile.*" EXCLUDE
4263 if (BUILD_stratoshark)
4264 cmake_path(SET TMP_DST_PATH NORMALIZE "${CMAKE_INSTALL_DATADIR}/${STRATOSHARK_NAME}")
4267 ${STRATOSHARK_INSTALL_DIRS}
4271 OWNER_WRITE OWNER_READ
4274 DIRECTORY_PERMISSIONS
4275 OWNER_EXECUTE OWNER_WRITE OWNER_READ
4276 GROUP_EXECUTE GROUP_READ
4277 WORLD_EXECUTE WORLD_READ
4278 PATTERN ".git" EXCLUDE
4279 PATTERN ".svn" EXCLUDE
4280 PATTERN "Makefile.*" EXCLUDE
4284 if(WIN32 AND NOT USE_MSYSTEM)
4285 # Note: CMake export mechanism misbehaves with a '.' in the
4286 # path (incorrect relative path computation).
4287 set(WIRESHARK_INSTALL_CMAKEDIR "cmake")
4289 set(WIRESHARK_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
4292 include(CMakePackageConfigHelpers)
4294 configure_package_config_file(WiresharkConfig.cmake.in
4295 ${CMAKE_BINARY_DIR}/WiresharkConfig.cmake
4296 INSTALL_DESTINATION ${WIRESHARK_INSTALL_CMAKEDIR}
4298 CMAKE_INSTALL_LIBDIR
4299 CMAKE_INSTALL_INCLUDEDIR
4300 PLUGIN_INSTALL_VERSION_LIBDIR
4301 EXTCAP_INSTALL_LIBDIR
4304 write_basic_package_version_file(
4305 ${CMAKE_BINARY_DIR}/WiresharkConfigVersion.cmake
4306 COMPATIBILITY AnyNewerVersion
4311 ${CMAKE_BINARY_DIR}/WiresharkConfig.cmake
4312 ${CMAKE_BINARY_DIR}/WiresharkConfigVersion.cmake
4314 ${WIRESHARK_INSTALL_CMAKEDIR}
4320 install(EXPORT WiresharkTargets
4321 DESTINATION ${WIRESHARK_INSTALL_CMAKEDIR}
4322 COMPONENT "Development"
4326 # This isn't strictly needed but it makes working around debhelper's
4327 # cleverness a lot easier.
4328 add_custom_target(install-headers
4329 COMMAND ${CMAKE_COMMAND} -DCOMPONENT=Development -P cmake_install.cmake
4332 if (DOXYGEN_EXECUTABLE)
4334 # We don't have a good way of tracking dependencies, so we simply
4335 # recreate the whole thing from scratch each time.
4336 add_custom_target(wsar_html
4337 COMMAND ${CMAKE_COMMAND} -E remove_directory wsar_html
4338 COMMAND ${DOXYGEN_EXECUTABLE} doxygen.cfg
4341 if(WIN32 AND NOT USE_MSYSTEM)
4342 add_custom_target(wsar_html_perms DEPENDS wsar_html)
4344 add_custom_target(wsar_html_perms
4345 COMMAND find wsar_html
4347 -exec chmod 755 "{}" +
4348 COMMAND find wsar_html
4350 -exec chmod 644 "{}" +
4354 add_custom_target(wsar_html_zip
4355 COMMAND ${CMAKE_COMMAND} -E tar "cfv" "wsar_html.zip" --format=zip wsar_html
4356 DEPENDS wsar_html_perms
4358 set_target_properties(wsar_html wsar_html_zip PROPERTIES
4359 FOLDER "Documentation"
4360 EXCLUDE_FROM_DEFAULT_BUILD True
4362 endif(DOXYGEN_EXECUTABLE)
4364 add_custom_target(test-programs
4366 fifo_string_cache_test
4374 COMMENT "Building unit test programs and wrapper"
4376 set_target_properties(test-programs PROPERTIES
4378 EXCLUDE_FROM_DEFAULT_BUILD True
4381 # Add target to enable capturing from the build directory. Requires Linux capabilities
4382 # and running with sudo.
4383 if(TARGET dumpcap AND SETCAP_EXECUTABLE)
4384 add_custom_target(test-capture
4385 COMMAND ${SETCAP_EXECUTABLE} cap_net_raw,cap_net_admin+ep $<TARGET_FILE:dumpcap>
4389 add_custom_target(test
4390 COMMAND ${CMAKE_COMMAND} -E env PYTHONIOENCODING=UTF-8
4391 ${Python3_EXECUTABLE} -m pytest
4393 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
4394 DEPENDS test-programs
4398 # Make it possible to run pytest without passing the full path as argument.
4399 if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
4400 file(READ "${CMAKE_CURRENT_SOURCE_DIR}/pytest.ini" pytest_ini)
4401 string(REGEX REPLACE "\naddopts = ([^\n]+)"
4402 "\naddopts = ${CMAKE_CURRENT_SOURCE_DIR}/test \\1"
4403 pytest_ini "${pytest_ini}")
4404 file(WRITE "${CMAKE_BINARY_DIR}/pytest.ini" "${pytest_ini}")
4408 # Update AUTHORS file with entries from git shortlog
4411 COMMAND ${Python3_EXECUTABLE} tools/generate_authors.py AUTHORS
4412 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
4414 else (GIT_EXECUTABLE)
4415 add_custom_target( gen-authors COMMAND ${CMAKE_COMMAND} -E echo "Git not found." )
4416 endif (GIT_EXECUTABLE)
4417 set_target_properties(gen-authors PROPERTIES FOLDER "Documentation")
4419 if(WIN32 AND NOT USE_MSYSTEM)
4420 file (TO_NATIVE_PATH ${CMAKE_SOURCE_DIR}/tools/Get-HardenFlags.ps1 _win_harden_flags)
4421 add_custom_target(hardening-check
4422 COMMAND ${POWERSHELL_COMMAND} "${_win_harden_flags}" "${_dll_output_dir_win}"
4424 COMMENT "Checking binaries for security features"
4426 set_target_properties(hardening-check PROPERTIES FOLDER "Tests")
4428 find_program(HARDENING_CHECK_EXECUTABLE hardening-check
4429 DOC "Path to the hardening-check utility."
4431 if(HARDENING_CHECK_EXECUTABLE)
4432 foreach(_prog ${PROGLIST})
4433 get_target_property(_prog_dir ${_prog} RUNTIME_OUTPUT_DIRECTORY)
4435 set(_prog_dir "${CMAKE_BINARY_DIR}/run")
4437 set(_prog_paths ${_prog_paths} "${_prog_dir}/${_prog}")
4439 add_custom_target(hardening-check
4440 COMMAND ${HARDENING_CHECK_EXECUTABLE} ${_prog_paths}
4442 COMMENT "Checking binaries for security features"
4456 find_program(SHELLCHECK_EXECUTABLE shellcheck
4457 DOC "Path to the shellcheck utility."
4459 if(SHELLCHECK_EXECUTABLE)
4460 add_custom_target(shellcheck)
4461 set_target_properties(shellcheck PROPERTIES FOLDER "Tests")
4462 # --external-sources requires 0.4.0 or later.
4463 # ChmodBPF uses "shellcheck shell=bash". Not sure which version
4464 # added support for that.
4465 add_custom_command(TARGET shellcheck POST_BUILD
4466 COMMAND shellcheck --external-sources
4467 resources/stock_icons/svg-to-png.sh
4468 resources/stock_icons/layouts-to-png.sh
4469 packaging/appimage/Stratoshark-AppRun.in
4470 packaging/appimage/Wireshark-AppRun.in
4471 "packaging/macosx/ChmodBPF/root/Library/Application Support/Wireshark/ChmodBPF/ChmodBPF"
4472 packaging/macosx/osx-app.sh.in
4473 packaging/macosx/osx-dmg.sh.in
4474 packaging/source/git-export-release.sh.in
4477 tools/debian-setup.sh
4480 tools/macos-setup-brew.sh
4482 tools/randpkt-test.sh
4483 tools/release-update-debian-soversions.sh
4485 tools/test-captures.sh
4487 tools/valgrind-wireshark.sh
4488 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
4494 "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
4495 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
4498 add_custom_target(uninstall
4499 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
4501 # Break on programmer errors when debugging in Visual Studio
4503 get_property(_targets DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS)
4504 foreach(_target ${_targets})
4505 set_target_properties(${_target} PROPERTIES VS_DEBUGGER_ENVIRONMENT "G_DEBUG=fatal-criticals")
4509 # -----------------------------------------------------------------------------
4511 # -----------------------------------------------------------------------------
4512 include(ConfigCPack.cmake)
4515 # Editor modelines - https://www.wireshark.org/tools/modelines.html
4520 # indent-tabs-mode: t
4523 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
4524 # :indentSize=8:tabSize=8:noTabs=false: