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(_log_project_name Stratoshark)
28 set(_project_name wireshark)
29 set(_log_project_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(LOG_PROJECT_NAME ${_log_project_name})
65 set(LOG_PROJECT_MAJOR_VERSION 0)
66 set(LOG_PROJECT_MINOR_VERSION 9)
67 set(LOG_PROJECT_PATCH_VERSION 0)
68 set(LOG_PROJECT_VERSION "${LOG_PROJECT_MAJOR_VERSION}.${LOG_PROJECT_MINOR_VERSION}.${LOG_PROJECT_PATCH_VERSION}${PROJECT_VERSION_EXTENSION}")
70 include( CMakeOptions.txt )
72 # We require minimum C11
73 set(CMAKE_C_STANDARD 11)
74 set(CMAKE_C_STANDARD_REQUIRED ON)
76 # We require minimum C++11
77 set(CMAKE_CXX_STANDARD 11)
78 set(CMAKE_CXX_STANDARD_REQUIRED ON)
79 set(CMAKE_CXX_EXTENSIONS OFF)
81 message(STATUS "Generating build using CMake ${CMAKE_VERSION}")
84 # Prevent FindPython3.cmake from using the Python path in the registry,
85 # only use the $PATH environment variable (which is set up for MSYS2).
86 set(Python3_FIND_REGISTRY NEVER)
88 find_package(Python3 3.6 REQUIRED)
90 # Set a default build type if none was specified
91 set(_default_build_type "RelWithDebInfo")
92 if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
93 set(CMAKE_BUILD_TYPE "${_default_build_type}" CACHE STRING "Choose the type of build." FORCE)
94 # Set the possible values of build type for cmake-gui
95 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
98 # Build type is ignored by multi-config generators.
99 if (NOT CMAKE_CONFIGURATION_TYPES)
100 message(STATUS "Using \"${CMAKE_GENERATOR}\" generator and build type \"${CMAKE_BUILD_TYPE}\"")
102 message(STATUS "Using \"${CMAKE_GENERATOR}\" generator (multi-config)")
105 #Where to find local cmake scripts
106 set(WS_CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
107 set(CMAKE_MODULE_PATH ${WS_CMAKE_MODULE_PATH})
109 # CMake >= 3.9.0 supports LTO/IPO.
111 include(CheckIPOSupported)
112 check_ipo_supported(RESULT lto_supported OUTPUT lto_output)
114 set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
115 message(STATUS "LTO/IPO is enabled for Release configuration")
117 message(STATUS "LTO/IPO requested but it is not supported by the compiler: ${lto_output}")
120 message(STATUS "LTO/IPO is not enabled")
123 # If our target platform is enforced by our generator, set
124 # WIRESHARK_TARGET_PLATFORM accordingly. Otherwise use
125 # %WIRESHARK_TARGET_PLATFORM%.
128 if(DEFINED ENV{WIRESHARK_TARGET_PLATFORM})
129 string(TOLOWER $ENV{WIRESHARK_TARGET_PLATFORM} _target_platform)
130 set(WIRESHARK_TARGET_PLATFORM ${_target_platform})
131 elseif(USE_MSYSTEM MATCHES "MINGW64|CLANG64|UCRT64")
132 # https://www.msys2.org/docs/environments
133 # MSYS2 comes with different environments/subsystems and
134 # the first thing you have to decide is which one to use.
135 # The differences among the environments are mainly environment
136 # variables, default compilers/linkers, architecture,
137 # system libraries used etc. If you are unsure, go with UCRT64.
138 set(WIRESHARK_TARGET_PLATFORM x64)
140 if($ENV{MSYSTEM_CARCH} MATCHES "x86_64")
141 set(WIRESHARK_TARGET_PLATFORM x64)
142 elseif($ENV{MSYSTEM_CARCH} MATCHES "i686")
143 set(WIRESHARK_TARGET_PLATFORM win32)
144 elseif($ENV{MSYSTEM_CARCH} MATCHES "aarch64")
145 set(WIRESHARK_TARGET_PLATFORM "arm64")
147 set(WIRESHARK_TARGET_PLATFORM "$ENV{MSYSTEM_CARCH}")
149 elseif($ENV{Platform} MATCHES arm64 OR CMAKE_GENERATOR_PLATFORM MATCHES arm64)
150 set(WIRESHARK_TARGET_PLATFORM arm64)
151 elseif(CMAKE_CL_64 OR CMAKE_GENERATOR MATCHES x64)
152 set(WIRESHARK_TARGET_PLATFORM x64)
154 message(WARNING "Assuming \"x64\" target platform")
155 set(WIRESHARK_TARGET_PLATFORM x64)
158 if(WIRESHARK_TARGET_PLATFORM MATCHES "win32")
159 message(FATAL_ERROR "Deprecated target platform ${WIRESHARK_TARGET_PLATFORM}. See https://gitlab.com/wireshark/wireshark/-/issues/17779 for details.")
160 elseif(NOT (WIRESHARK_TARGET_PLATFORM MATCHES "x64" OR WIRESHARK_TARGET_PLATFORM MATCHES "arm64"))
161 message(FATAL_ERROR "Invalid target platform: ${WIRESHARK_TARGET_PLATFORM}")
165 if(MSVC AND DEFINED ENV{PLATFORM})
166 string(TOLOWER $ENV{PLATFORM} _vs_platform)
168 (_vs_platform STREQUAL "x64" AND NOT WIRESHARK_TARGET_PLATFORM STREQUAL "x64")
170 (_vs_platform STREQUAL "arm64" AND NOT WIRESHARK_TARGET_PLATFORM STREQUAL "arm64")
172 message(FATAL_ERROR "The PLATFORM environment variable (${_vs_platform})"
173 " doesn't match the generator platform (${WIRESHARK_TARGET_PLATFORM})")
178 "Building for ${WIRESHARK_TARGET_PLATFORM}"
181 if(NOT CMAKE_CROSSCOMPILING)
182 find_package(PowerShell REQUIRED)
185 # Determine where the 3rd party libraries will be
187 if( DEFINED ENV{WIRESHARK_LIB_DIR} )
188 # The buildbots set WIRESHARK_LIB_DIR but not WIRESHARK_BASE_DIR.
189 file( TO_CMAKE_PATH "$ENV{WIRESHARK_LIB_DIR}" _PROJECT_LIB_DIR )
190 elseif( DEFINED ENV{WIRESHARK_BASE_DIR} )
191 file( TO_CMAKE_PATH "$ENV{WIRESHARK_BASE_DIR}" _WS_BASE_DIR )
192 set( _PROJECT_LIB_DIR "${_WS_BASE_DIR}/wireshark-${WIRESHARK_TARGET_PLATFORM}-libs" )
194 # Don't know what to do
195 message(FATAL_ERROR "Neither WIRESHARK_BASE_DIR or WIRESHARK_LIB_DIR are defined")
198 # Download third-party libraries
199 file (TO_NATIVE_PATH ${CMAKE_SOURCE_DIR}/tools/win-setup.ps1 _win_setup)
200 file (TO_NATIVE_PATH ${_PROJECT_LIB_DIR} _ws_lib_dir)
201 file (TO_NATIVE_PATH ${CMAKE_COMMAND} _win_cmake_command)
203 # Is it possible to have a one-time, non-cached option in CMake? If
204 # so, we could add a "-DFORCE_WIN_SETUP" which passes -Force to
207 COMMAND ${POWERSHELL_COMMAND} "\"${_win_setup}\"" -Destination "${_ws_lib_dir}" -Platform ${WIRESHARK_TARGET_PLATFORM} -CMakeExecutable "\"${_win_cmake_command}\""
208 RESULT_VARIABLE _win_setup_failed
209 ERROR_VARIABLE _win_setup_error_output
211 if(_win_setup_failed)
212 message(FATAL_ERROR "Windows setup (win-setup.ps1) failed: ${_win_setup_error_output}.")
215 set(EXTRA_INSTALLER_DIR ${_ws_lib_dir})
217 # XXX Add a dependency on ${_ws_lib_dir}/current_tag.txt?
219 set(EXTRA_INSTALLER_DIR ${CMAKE_BINARY_DIR}/packaging/nsis)
222 include(FetchContent)
223 set(LIBS_URL "https://dev-libs.wireshark.org/windows/packages")
224 file(TO_CMAKE_PATH ${EXTRA_INSTALLER_DIR} _file_download_dir)
226 # Download Npcap required by the Windows installer
227 set(NPCAP_VERSION "1.80")
228 set(NPCAP_SHA256 "ac4f26d7d9f994d6f04141b2266f02682def51af63c09c96a7268552c94a6535")
229 set(NPCAP_FILENAME "npcap-${NPCAP_VERSION}.exe")
230 set(NPCAP_URL "${LIBS_URL}/Npcap/${NPCAP_FILENAME}")
231 FetchContent_Declare(Npcap
233 DOWNLOAD_DIR ${_file_download_dir}
234 URL_HASH SHA256=${NPCAP_SHA256}
235 DOWNLOAD_NO_EXTRACT True
238 # Download USBPcap required by the Windows installer
239 set(USBPCAP_VERSION "1.5.4.0")
240 set(USBPCAP_SHA256 "87a7edf9bbbcf07b5f4373d9a192a6770d2ff3add7aa1e276e82e38582ccb622")
241 set(USBPCAP_FILENAME "USBPcapSetup-${USBPCAP_VERSION}.exe")
242 set(USBPCAP_URL "${LIBS_URL}/USBPcap/${USBPCAP_FILENAME}")
243 FetchContent_Declare(USBPcap
245 DOWNLOAD_DIR ${_file_download_dir}
246 URL_HASH SHA256=${USBPCAP_SHA256}
247 DOWNLOAD_NO_EXTRACT True
251 include(UseCustomIncludes)
252 ADD_CUSTOM_CMAKE_INCLUDE()
254 # Ensure that all executables and libraries end up in the same directory. Actual
255 # files might end up in a configuration subdirectory, e.g. run/Debug or
256 # run/Release. We try to set DATAFILE_DIR to actual location below.
257 if(NOT ARCHIVE_OUTPUT_PATH)
258 set(ARCHIVE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/run CACHE INTERNAL
259 "Single output directory for building all archives.")
261 if(NOT EXECUTABLE_OUTPUT_PATH)
262 set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/run CACHE INTERNAL
263 "Single output directory for building all executables.")
265 if(NOT LIBRARY_OUTPUT_PATH)
266 set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/run CACHE INTERNAL
267 "Single output directory for building all libraries.")
271 # The release mode (CMAKE_BUILD_TYPE=release) defines NDEBUG for
272 # the Unix Makefile generator.
275 # Defines CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_DATADIR, etc ...
276 if(WIN32 AND NOT USE_MSYSTEM)
277 # Override some values on Windows, to match the existing
278 # convention of installing everything to a single root folder.
279 set(CMAKE_INSTALL_BINDIR ".")
280 set(CMAKE_INSTALL_LIBDIR ".")
281 set(CMAKE_INSTALL_INCLUDEDIR "include")
282 set(CMAKE_INSTALL_DATADIR ".")
283 set(CMAKE_INSTALL_DOCDIR ".")
285 include(GNUInstallDirs)
287 set(PROJECT_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}")
289 # Make sure our executables can load our libraries if we install into
290 # a non-default directory on Unix-like systems other than macOS.
291 # https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
292 set(LIBRARY_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}")
293 set(EXECUTABLE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}")
294 set(EXTCAP_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}")
295 if(NOT (WIN32 OR APPLE OR USE_STATIC))
296 # Try to set a RPATH for installed binaries if the library directory is
297 # not already included in the default search list.
298 list(FIND CMAKE_C_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_FULL_LIBDIR}" IS_SYSTEM_DIR)
299 if(IS_SYSTEM_DIR EQUAL -1)
300 # Some systems support $ORIGIN in RPATH to enable relocatable
301 # binaries. In other cases, only absolute paths can be used.
302 # https://www.lekensteyn.nl/rpath.html
304 # Also note that some systems (notably those using GNU libc)
305 # silently ignore $ORIGIN in RPATH for binaries that are
306 # setuid root or use privileged capabilities.
308 if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|SunOS|FreeBSD)$")
309 set(_enable_rpath_origin TRUE)
311 set(_enable_rpath_origin FALSE)
314 # Provide a knob to optionally force absolute rpaths,
315 # to support old/buggy systems and as a user preference
317 # XXX Should this be a CMake option?
318 set(ENABLE_RPATH_ORIGIN ${_enable_rpath_origin} CACHE BOOL
319 "Use $ORIGIN with INSTALL_RPATH")
320 mark_as_advanced(ENABLE_RPATH_ORIGIN)
322 if(ENABLE_RPATH_ORIGIN)
323 set(LIBRARY_INSTALL_RPATH "$ORIGIN")
324 set(EXECUTABLE_INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
325 set(EXTCAP_INSTALL_RPATH "$ORIGIN/../..")
327 set(LIBRARY_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
328 set(EXECUTABLE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
329 set(EXTCAP_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
331 # Include non-standard external libraries by default in RPATH.
332 if(NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH)
333 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
338 # Ensure that executables in the build directory always have the same RPATH.
339 # This ensures relocatable binaries and reproducible builds (invariant of the
340 # build directory location). (Requires CMake 3.14)
341 set(CMAKE_BUILD_RPATH_USE_ORIGIN ON)
344 # Linking with wsetargv.obj enables "wildcard expansion" of
345 # command-line arguments.
346 set(WILDCARD_OBJ wsetargv.obj)
349 include(CheckSymbolExists)
352 # Large file support on UN*X, a/k/a LFS.
354 # On Windows, we require _fseeki64() and _ftelli64(). Visual
355 # Studio has had supported them since Visual Studio 2005/MSVCR80,
356 # and we require newer versions, so we know we have them.
362 # Add the required #defines.
364 add_definitions(${LFS_DEFINITIONS})
368 # Check for fseeko as well.
375 # Add the required #defines.
377 add_definitions(${FSEEKO_DEFINITIONS})
381 # Banner shown at top right of Qt welcome screen.
382 if(DEFINED ENV{WIRESHARK_VERSION_FLAVOR})
383 set(VERSION_FLAVOR "$ENV{WIRESHARK_VERSION_FLAVOR}")
385 set(VERSION_FLAVOR "Development Build")
388 # Used in .rc files and manifests
389 set(MANIFEST_PROCESSOR_ARCHITECTURE ${WIRESHARK_TARGET_PLATFORM})
390 if (MANIFEST_PROCESSOR_ARCHITECTURE MATCHES "x64")
391 set(MANIFEST_PROCESSOR_ARCHITECTURE "amd64")
393 set(RC_VERSION ${PROJECT_MAJOR_VERSION},${PROJECT_MINOR_VERSION},${PROJECT_PATCH_VERSION},${PROJECT_BUILD_VERSION})
394 set(LOG_RC_VERSION ${LOG_PROJECT_MAJOR_VERSION},${LOG_PROJECT_MINOR_VERSION},${PROJECT_PATCH_VERSION},${PROJECT_BUILD_VERSION})
396 message(STATUS "V: ${PROJECT_VERSION}, MaV: ${PROJECT_MAJOR_VERSION}, MiV: ${PROJECT_MINOR_VERSION}, PL: ${PROJECT_PATCH_VERSION}, EV: ${PROJECT_VERSION_EXTENSION}.")
399 include(UseMakePluginReg)
401 include(UseExecutableResources)
404 # The following snippet has been taken from
405 # https://github.com/USESystemEngineeringBV/cmake-eclipse-helper/wiki/HowToWorkaroundIndexer
406 # The eclipse indexer otherwise assumes __cplusplus=199711L which will lead to broken
407 # lookup tables for the epan libraries
408 # Check if CXX flags have been set to c++11 -> Setup Eclipse Indexer correctly!
409 # Also setup the project slightly different
410 if(CMAKE_EXTRA_GENERATOR MATCHES "Eclipse CDT4")
412 LIST(LENGTH CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS LIST_LEN)
413 if(LIST_LEN GREATER 0)
417 LIST(LENGTH CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS LIST_LEN)
418 if(LIST_LEN GREATER 0)
421 if(C_ENABLED EQUAL 1 AND CXX_ENABLED EQUAL 1)
422 # Combined project (C and CXX). This will confuse the indexer. For that reason
423 # we unsert set the __cplusplus variable for the indexer
424 list(FIND CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS "__cplusplus" GEN_MACRO_INDEX)
425 if(GEN_MACRO_INDEX GREATER -1)
426 list(REMOVE_AT CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${GEN_MACRO_INDEX})
427 list(REMOVE_AT CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${GEN_MACRO_INDEX})
429 SET(CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS} CACHE INTERNAL "")
430 elseif((CXX_ENABLED EQUAL 1) AND (CMAKE_CXX_FLAGS MATCHES ".*-std=c\\+\\+11.*"))
431 #add_definitions (-D__cplusplus=201103L)
432 # CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS
433 list(FIND CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS "199711L" GEN_MACRO_INDEX)
434 if(GEN_MACRO_INDEX GREATER -1)
435 list(REMOVE_AT CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${GEN_MACRO_INDEX})
436 list(INSERT CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${GEN_MACRO_INDEX} "201103L")
437 SET(CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS} CACHE INTERNAL "")
445 ${CMAKE_SOURCE_DIR}/include
448 if( DUMPCAP_INSTALL_OPTION STREQUAL "suid" )
449 set( DUMPCAP_SETUID "SETUID" )
451 set( DUMPCAP_SETUID )
453 if( NOT CMAKE_SYSTEM_NAME STREQUAL "Linux" AND
454 DUMPCAP_INSTALL_OPTION STREQUAL "capabilities" )
455 message( WARNING "Capabilities are only supported on Linux" )
456 set( DUMPCAP_INSTALL_OPTION )
459 set(OSS_FUZZ OFF CACHE BOOL "Whether building for oss-fuzz")
460 mark_as_advanced(OSS_FUZZ)
463 # In oss-fuzz mode, the fuzzing engine can be afl or libFuzzer.
464 message(FATAL_ERROR "Cannot force libFuzzer when using oss-fuzz")
466 # Must not depend on external dependencies so statically link all libs.
471 set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
475 # Linking can consume a lot of memory, especially when built with ASAN and
476 # static libraries (like oss-fuzz) or Debug mode. With Ninja, the number of
477 # parallel linker processes is constrained by job parallelism (-j), but this can
478 # be reduced further by setting "job pools" to a lower number.
480 if(CMAKE_MAKE_PROGRAM MATCHES "ninja" AND OSS_FUZZ)
481 # Assume oss-fuzz linker jobs do not require more than 1.2G per task
482 set(per_job_memory_mb 1200)
483 cmake_host_system_information(RESULT total_memory_mb QUERY TOTAL_PHYSICAL_MEMORY)
484 math(EXPR parallel_link_jobs "${total_memory_mb} / ${per_job_memory_mb}")
485 if(parallel_link_jobs LESS 1)
486 set(parallel_link_jobs 1)
488 set_property(GLOBAL APPEND PROPERTY JOB_POOLS link_job_pool=${parallel_link_jobs})
489 set(CMAKE_JOB_POOL_LINK link_job_pool)
490 message(STATUS "Ninja job pool size: ${parallel_link_jobs}")
493 # Always enable position-independent code when compiling, even for
494 # executables, so you can build position-independent executables.
495 # -pie is added below for non-MSVC, but requires objects to be built with
496 # -fPIC/-fPIE (so set CMAKE_POSITION_INDEPENDENT_CODE to enable that).
497 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
499 # Preprocessor definitions common to all compilers
500 set_property(DIRECTORY
501 PROPERTY COMPILE_DEFINITIONS
502 "G_DISABLE_DEPRECATED"
503 "G_DISABLE_SINGLE_INCLUDES"
504 $<$<OR:$<BOOL:${ENABLE_DEBUG}>,$<CONFIG:Debug>>:WS_DEBUG>
505 $<$<OR:$<AND:$<BOOL:${ENABLE_DEBUG}>,$<BOOL:${ENABLE_DEBUG_UTF_8}>>,$<CONFIG:Debug>>:WS_DEBUG_UTF_8>
506 $<$<BOOL:${ENABLE_ASSERT}>:ENABLE_ASSERT>
511 # NOTE: Because of the way Qt moc is including "config.h" (not as the
512 # first header) this *MUST* be defined on the command line to precede
513 # every included header and not trigger symbol redefinition errors.
516 -DWIN32_LEAN_AND_MEAN
518 # Use Unicode in Windows runtime functions.
523 # NOMINMAX keeps windows.h from defining "min" and "max" via windef.h.
524 # This avoids conflicts with the C++ standard library.
533 # Enable POSIX APIs. This will switch stdio to ANSI C functions and
534 # enable C99 conformant vsnprintf() among other things.
538 list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_POSIX)
541 if( CMAKE_C_COMPILER_ID MATCHES "MSVC")
542 if (MSVC_VERSION LESS "1928")
543 message(FATAL_ERROR "Microsoft Visual Studio 2019 version 16.8 or later is required")
545 if (MSVC_VERSION GREATER_EQUAL "2000")
546 message(FATAL_ERROR "You are using an unsupported version of MSVC")
550 /D_CRT_SECURE_NO_DEPRECATE
551 # -DPSAPI_VERSION=1 Programs that must run on earlier versions of Windows as well as Windows 7 and later
552 # versions should always call this function as GetProcessMemoryInfo. To ensure correct
553 # resolution of symbols, add Psapi.lib to the TARGETLIBS macro and compile the program
554 # with -DPSAPI_VERSION=1.To use run-time dynamic linking, load Psapi.dll.
555 # https://docs.microsoft.com/en-us/windows/win32/api/psapi/nf-psapi-getprocessmemoryinfo
556 # -D_ALLOW_KEYWORD_MACROS For VS2012 onwards the, C++ STL does not permit macro redefinitions of keywords
557 # (see https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/bb531344(v=vs.110))
558 # This definition prevents the complaint about the redefinition of inline by WinPCap
559 # in pcap-stdinc.h when compiling C++ files, e.g. the Qt UI
561 /D_ALLOW_KEYWORD_MACROS
562 # Disable deprecation of POSIX function names.
563 # https://stackoverflow.com/questions/37845163/what-is-the-purpose-of-microsofts-underscore-c-functions
564 /D_CRT_NONSTDC_NO_WARNINGS
567 if(NOT WIRESHARK_TARGET_PLATFORM STREQUAL "x64")
568 add_definitions("/D_BIND_TO_CURRENT_CRT_VERSION=1")
571 # TODO: Re-enable /W3. It was disabled for a year and some warnings crept
572 # in that will fail with /Wx.
578 set(WS_LINK_FLAGS "/LARGEADDRESSAWARE /MANIFEST:NO /INCREMENTAL:NO /RELEASE")
580 # To do: Add /external:... See https://devblogs.microsoft.com/cppblog/broken-warnings-theory/
582 # /diagnostics:caret Place a caret under compilation issues similar to
584 # /Zo Enhanced debugging of optimised code
585 # /utf-8 Set Source and Executable character sets to UTF-8
586 # VS2015(MSVC14): On by default when /Zi or /Z7 used.
587 # /guard:cf Control Flow Guard (compile and link).
588 # See https://docs.microsoft.com/en-us/windows/win32/secbp/control-flow-guard
589 # Note: This requires CMake 3.9.0 or newer.
590 # https://gitlab.kitware.com/cmake/cmake/commit/f973d49ab9d4c59b93f6dac812a94bb130200836
591 # /Qspectre Speculative execution attack mitigation
592 # See https://devblogs.microsoft.com/cppblog/spectre-mitigations-in-msvc/
593 list(APPEND LOCAL_CFLAGS /diagnostics:caret /Zo /utf-8 /guard:cf)
594 set(WS_LINK_FLAGS "${WS_LINK_FLAGS} /guard:cf")
595 set(WS_LINK_FLAGS "${WS_LINK_FLAGS} /STACK:0x800000")
596 # /Qspectre depends on the optional "Microsoft.VisualStudio.Component...Spectre" components,
597 # so we need to test for its availability.
598 set(WIRESHARK_COMMON_FLAGS /Qspectre)
600 if(ENABLE_CODE_ANALYSIS)
601 # We should probably add a code_analysis.props file and use it to set
602 # CAExcludePath, otherwise we trigger on Qt's headers:
603 # https://stackoverflow.com/questions/59669026/how-to-add-property-to-affect-code-analysis-in-cmake
604 # https://gitlab.kitware.com/cmake/cmake/-/issues/19682
605 # For now, we set CAExcludePath=C:\Qt;%include% in the Visual Studio
606 # Code Analys builder's environment.
607 list(APPEND LOCAL_CFLAGS
609 /analyze:log:format:sarif
613 # Additional compiler warnings to be treated as "Level 3"
614 # when compiling Wireshark sources. (Selected from "level 4" warnings).
615 ## 4295: array is too small to include a terminating null character
616 ## 4100: unreferenced formal parameter
617 ## 4189: local variable is initialized but not referenced
618 # Disable warnings about use of flexible array members:
619 ## 4200: nonstandard extension used : zero-sized array in struct/union
620 list(APPEND LOCAL_CFLAGS /w34295 /w34100 /w34189 /wd4200)
622 # MSVC 14.28 + C11 enables C5105, but older Windows SDKs aren't completely compatible.
623 # Windows SDK 10.0.17763.0 generates syntax errors with C11 enabled.
624 # The variable CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION does not work with the Ninja generator. Presumably it requires a VS generator.
625 if (CMAKE_GENERATOR MATCHES "Visual Studio")
626 if (CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION VERSION_LESS 10.0.18362.0)
627 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.")
629 # Windows SDK 10.0.18362.0 to 10.0.19041.685 generate warning C5105 with C11 enabled.
630 if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION VERSION_LESS 10.0.20348.0)
631 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.")
632 ## 5105: macro expansion producing 'defined' has undefined behavior
633 list(APPEND LOCAL_CFLAGS /wd5105)
637 # We've matched these to specific compiler versions using the
638 # checks above. There's no need to pass them to check_c_compiler_flag
639 # or check_cxx_compiler_flag, which can be slow.
640 string(REPLACE ";" " " _flags "${LOCAL_CFLAGS}")
641 set(CMAKE_C_FLAGS "${_flags} ${CMAKE_C_FLAGS}")
642 set(CMAKE_CXX_FLAGS "${_flags} ${CMAKE_CXX_FLAGS}")
646 # MIN_MACOS_VERSION is used to set LSMinimumSystemVersion
647 # in Info.plist, so start with something low.
648 set(MIN_MACOS_VERSION 10.13)
649 if(CMAKE_OSX_DEPLOYMENT_TARGET)
650 if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS MIN_MACOS_VERSION)
651 message(FATAL_ERROR "We don't support building for macOS < ${MIN_MACOS_VERSION}")
653 set(MIN_MACOS_VERSION ${CMAKE_OSX_DEPLOYMENT_TARGET})
658 # NOTE: Adding new warnings is a policy decision that can have far-reaching
659 # implications for the project and each developers workflow. Modern
660 # C compilers are on a race to add new warnings, not always sensibly.
661 # They are opt-in so take a moment to fully consider the implications
662 # of enabling the latest shiny new warning.
663 # If in doubt ask on the Wireshark developer list (recommended).
665 list(APPEND WIRESHARK_COMMON_FLAGS
667 ### Flags common to C and C++ ###
669 # -O<X> and -g get set by the CMAKE_BUILD_TYPE
674 -Wtrampolines # Enable warnings about trampolines that require executable stacks
678 -fexcess-precision=fast # GCC-only
681 -Wpragmas # Clang-only
682 -Wheader-guard # Clang-only
684 -Wshorten-64-to-32 # Clang-only
686 -Wunreachable-code # Clang-only
687 -Wdocumentation # Clang-only
688 -Wlogical-op # GCC-only
690 # Run-time protections mechanisms
691 -fstrict-flex-arrays=3 # Consider a trailing array in a struct as a flexible array if declared as []
692 -fstack-clash-protection # Increased reliability of stack overflow detection
693 -fcf-protection=full # Enable control flow protection to counter Return Oriented Programming (ROP) and Jump Oriented Programming (JOP) attacks on many x86 architectures
694 -mbranch-protection=standard # Enable branch protection to counter Return Oriented Programming (ROP) and Jump Oriented Programming (JOP) attacks on AArch64
695 -D_GLIBCXX_ASSERTIONS # Precondition checks for C++ standard library calls. Can impact performance.
696 -fstack-protector-strong # Stack smashing protector
697 -fno-delete-null-pointer-checks # Force retention of null pointer checks
698 # The above used to fail on macOS El Capitan clang (see below in PEDANTIC) Does it work now?
699 -fno-strict-overflow # Defines signed overflow as wrapping on gcc and clang, prevents optimizations that assume overflow never happens
700 -fno-strict-aliasing # Do not assume strict aliasing
701 -ftrivial-auto-var-init # Perform trivial auto variable initialization
702 -fexceptions # Enable exception propagation to harden multi-threaded C code
705 # Disable errors unconditionally for some static analysis warnings
706 # that are dormant at lower optimizations levels or active only in
707 # bleeding edge versions of a compiler and possibly also
708 # prone to false positives and compiler bugs. This is
709 # a big nuisance because the warning is dormant and a low
710 # priority target for action. That is very disruptive
711 # with -Werror enabled (the default on the master branch).
713 #-Wno-error=stringop-overflow=
715 # XXX Now that we have a CI job with Release build type (using
716 # -O3 optimization level) the dormancy issue should be ameliorated
717 # so comment out these exceptions to re-evaluate the impact.
718 #-Wno-error=maybe-uninitialized
719 #-Wno-error=alloc-size-larger-than=
721 # Updating external dependencies can introduce new deprecations.
722 # Also fixing new internal deprecations takes time.
723 # We want to be able to build with -Werror in that case. New
724 # code should not introduce new deprecations in any case.
726 #-Wno-error=deprecated-declarations
729 if (CMAKE_C_COMPILER_ID MATCHES "Clang")
730 # Avoid "argument unused during compilation" warnings for
731 # -fstack-clash-protection and -mbranch-protection=standard
732 list(APPEND WIRESHARK_COMMON_FLAGS -Qunused-arguments)
735 if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
736 # _FORTIFY_SOURCE requires -O1 or higher, and the Debug
737 # build type has no optimization
738 if((CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "12.0") OR
739 (CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "9.0"))
740 # On some gcc < 12.0, test_compiler_flag will report that
741 # -D_FORTIFY_SOURCE=3 is valid, but actually trying to compile
742 # with it will give a warning that it has the same effect as
743 # -D_FORTIFY_SOURCE=2
744 list(APPEND WIRESHARK_COMMON_FLAGS
745 -U_FORTIFY_SOURCE # Run-time buffer overflow detection. For dist like Ubuntu, U_FORTIFY_SOURCE must be input before D_FORTIFY_SOURCE
746 -D_FORTIFY_SOURCE=3 # Fortify sources with compile- and run-time checks for unsafe libc usage and buffer overflows. Requires -O1 or higher
751 # test_compiler_flag doesn't seem to test that a flag is supported on
752 # a cross-compiled target, only for the native architecture. (Thus
753 # conversely it does work to verify that -mbranch-protection=standard
754 # doesn't work on x64 when compiling natively.)
755 # TODO: Check that this approach works.
756 #if(NOT CMAKE_CROSSCOMPILING)
757 # list(APPEND WIRESHARK_COMMON_FLAGS
758 # -fhardened # Enable pre-determined set of hardening options in GCC. Currently, -fhardened is only supported on GNU/Linux targets
762 if((NOT ENABLE_ASAN) AND (NOT ENABLE_TSAN) AND (NOT ENABLE_UBSAN) AND (NOT DISABLE_FRAME_LARGER_THAN_WARNING))
764 # Only do this if none of ASan, TSan, and UBSan are
765 # enabled; the instrumentation they add increases
766 # the stack usage - we only care about stack
767 # usage in normal operation.
769 list(APPEND WIRESHARK_COMMON_FLAGS
770 -Wframe-larger-than=32768
774 list(APPEND WIRESHARK_C_ONLY_FLAGS
776 ### Flags for C only ###
779 # XXX - some versions of GCC, including the one in at
780 # least some Xcode versions that come with Mac OS X
781 # 10.5, complain about variables in function and
782 # function pointer *declarations* shadowing other
783 # variables. The autoconf script checked for that; we
786 -Wold-style-definition
788 -Wincompatible-pointer-types
793 # The universal zero initializer (in C: struct s x = { 0 };) for
794 # structures with multiple members is perfectly legal, but some older
795 # compilers warn about it. Silence those older compilers.
797 if((CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "5.1") OR
798 (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "6.0") OR
799 (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "12.0"))
800 if(NOT CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_VERSION VERSION_LESS "5.0")
801 list(APPEND WIRESHARK_C_ONLY_FLAGS -Wno-missing-field-initializers)
803 # Silence warnings for initialization of nested structs like
804 # struct { struct { int a, b; } s; int c; } v = { 0 };
805 list(APPEND WIRESHARK_C_ONLY_FLAGS -Wno-missing-braces)
808 list(APPEND WIRESHARK_CXX_ONLY_FLAGS
810 ### Flags for C++ only ###
812 -Wextra-semi # Clang-only
816 # Not all warnings are the same. They fall on a spectrum from "critical"
817 # to "pedantic nonsense". These are warnings that realistically are worth
819 # TODO https://gitlab.com/wireshark/wireshark/-/issues/19995
821 if(ENABLE_TODO_WARNINGS)
822 list(APPEND WIRESHARK_COMMON_FLAGS
824 # All the registration functions block these for now.
827 -Wmissing-declarations
832 # A bunch of "that might not work on SPARC" code blocks
833 # this one for now; some of it is code that *will* work
834 # on SPARC, such as casts of "struct sockaddr *" to
835 # "struct sockaddr_in *", which are required by some
836 # APIs such as getifaddrs().
841 list(APPEND WIRESHARK_COMMON_FLAGS
843 # Converting from g_printf() and g_snprintf() to stdio.h turns
844 # up many of these warnings. They will have to be handled later.
845 # It can be a lot of work to fix properly and none of them
846 # seem to flag very interesting issues.
848 -Wno-format-truncation # Enabled with -Wall
850 -Wno-format-nonliteral # Enabled with -Wformat=2
852 list(APPEND WIRESHARK_C_ONLY_FLAGS
853 -Wno-pointer-sign # Enabled with -Wall
858 # These are not enabled by default, because the warnings they
859 # produce are very hard or impossible to eliminate.
861 if(ENABLE_PEDANTIC_COMPILER_WARNINGS)
862 list(APPEND WIRESHARK_COMMON_FLAGS
863 # The following are for C and C++
865 -Wno-overlength-strings
868 # As we use variadic macros, we don't want warnings
869 # about them, even with -Wpedantic.
873 # Various code blocks this one.
876 -fstrict-overflow -Wstrict-overflow=4
878 # Due to various places where APIs we don't control
879 # require us to cast away constness, we can probably
880 # never enable this one with -Werror.
884 # Doesn't warn of interesting issues. Usually the
885 # duplicated branches are protocol constants that
886 # happen to be equal and are relevant for documentation
887 # and readability and are trivially optimized by the
890 -Wduplicated-branches # GCC-only
892 # No longer supported by El Capitan clang on C++
893 # XXX - is this one of those where CMake's check
894 # doesn't fail, so it won't reject this?
896 -fno-delete-null-pointer-checks
900 # Some loops are safe, but it's hard to convince the compiler of
901 # that. Always disable the warning on GCC 7 due to a bug that
902 # cause lots of false positives.
903 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81408
905 if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION MATCHES "^7\\.")
906 list(APPEND WIRESHARK_COMMON_FLAGS -Wunsafe-loop-optimizations)
909 list(APPEND WIRESHARK_C_ONLY_FLAGS
910 # The following are C only, not C++
912 # Due to various places where APIs we don't control
913 # require us to cast away constness, we can probably
914 # never enable this one with -Werror.
919 list(APPEND WIRESHARK_CXX_ONLY_FLAGS
923 if(ENABLE_COMPILER_COLOR_DIAGNOSTICS)
924 if(CMAKE_C_COMPILER_ID MATCHES "Clang")
925 set(WIRESHARK_COMMON_FLAGS ${WIRESHARK_COMMON_FLAGS}
928 elseif(CMAKE_C_COMPILER_ID MATCHES "GNU")
929 set(WIRESHARK_COMMON_FLAGS ${WIRESHARK_COMMON_FLAGS}
930 -fdiagnostics-color=always
935 set(WIRESHARK_LD_FLAGS
936 # See also CheckCLinkerFlag.cmake
944 # Counterhack to work around some cache magic in CHECK_C_SOURCE_COMPILES
945 include(CheckCCompilerFlag)
946 include(CheckCXXCompilerFlag)
949 set(BUILD_SHARED_LIBS 0)
951 set(BUILD_SHARED_LIBS 1)
954 function(test_compiler_flag _lang _this_flag _valid_flags_var)
955 string(MAKE_C_IDENTIFIER "${_lang}${_this_flag}_VALID" _flag_var)
956 set(_test_flags "${${_valid_flags_var}} ${_this_flag}")
957 if(_lang STREQUAL "C")
958 check_c_compiler_flag("${_test_flags}" ${_flag_var})
959 elseif(_lang STREQUAL "CXX")
960 check_cxx_compiler_flag("${_test_flags}" ${_flag_var})
962 message(FATAL_ERROR "Language must be C or CXX")
965 set(${_valid_flags_var} "${_test_flags}" PARENT_SCOPE)
969 foreach(THIS_FLAG ${WIRESHARK_COMMON_FLAGS} ${WIRESHARK_C_ONLY_FLAGS})
970 test_compiler_flag(C ${THIS_FLAG} ADDED_CMAKE_C_FLAGS)
972 set(CMAKE_C_FLAGS "${ADDED_CMAKE_C_FLAGS} ${CMAKE_C_FLAGS}")
974 foreach(THIS_FLAG ${WIRESHARK_COMMON_FLAGS} ${WIRESHARK_CXX_ONLY_FLAGS})
975 test_compiler_flag(CXX ${THIS_FLAG} ADDED_CMAKE_CXX_FLAGS)
977 set(CMAKE_CXX_FLAGS "${ADDED_CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
979 # Strips the source and build directory prefix from the __FILE__ macro to ensure
980 # reproducible builds. Supported since GCC 8, Clang support is pending.
981 if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
982 # If the build dir is within the source dir, CMake will use something
983 # like ../epan/dfilter/semcheck.c. Map these relative paths in addition
984 # to CMAKE_BINARY_DIR since compile_commands.json uses absolute paths.
985 file(RELATIVE_PATH _relative_source_dir "${CMAKE_BINARY_DIR}" "${CMAKE_SOURCE_DIR}")
986 string(REGEX REPLACE "/$" "" _relative_source_dir "${_relative_source_dir}")
988 check_c_compiler_flag(-fmacro-prefix-map=old=new C_fmacro_prefix_map_old_new_VALID)
989 check_cxx_compiler_flag(-fmacro-prefix-map=old=new CXX_fmacro_prefix_map_old_new_VALID)
991 if(${_lang}_fmacro_prefix_map_old_new_VALID)
992 set(_flags CMAKE_${_lang}_FLAGS)
993 set(${_flags} "${${_flags}} -fmacro-prefix-map=\"${CMAKE_SOURCE_DIR}/\"=")
994 set(${_flags} "${${_flags}} -fmacro-prefix-map=\"${CMAKE_BINARY_DIR}/\"=")
995 if(_relative_source_dir MATCHES "\\.\\.$")
996 set(${_flags} "${${_flags}} -fmacro-prefix-map=\"${_relative_source_dir}/\"=")
1002 include(CMakePushCheckState)
1005 # Available since MSVC 2019 version 16.9 (https://gitlab.com/wireshark/wireshark/-/merge_requests/14912 for more details)
1006 cmake_push_check_state()
1007 set(ASAN_FLAG "-fsanitize=address")
1008 set(CMAKE_REQUIRED_FLAGS ${ASAN_FLAG})
1010 message(NOTICE "ENABLE_ASAN was requested. Checking if ASAN is supported requires SPECTRE-mitigation to be disabled globally impacting all build types.")
1011 message(NOTICE "If ASAN is supported, then it is re-enabled selectively depending on the build types.")
1012 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Qspectre-")
1013 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Qspectre-")
1015 check_c_compiler_flag(${ASAN_FLAG} C__fsanitize_address_VALID)
1016 check_cxx_compiler_flag(${ASAN_FLAG} CXX__fsanitize_address_VALID)
1017 cmake_pop_check_state()
1018 if(NOT C__fsanitize_address_VALID OR NOT CXX__fsanitize_address_VALID)
1019 message(FATAL_ERROR "ENABLE_ASAN was requested, but not supported!")
1022 message(NOTICE "ASAN is supported.")
1023 if(ENABLE_ASAN_WITH_SPECTRE)
1024 message(NOTICE "ENABLE_ASAN_WITH_SPECTRE was requested.")
1025 message(NOTICE "For Debug and RelWithDebInfo, SPECTRE-mitigation has been re-enabled and ASAN has been enabled too.")
1026 add_compile_options("$<$<CONFIG:Debug>:/Qspectre>" "$<$<CONFIG:Debug>:${ASAN_FLAG}>")
1027 add_compile_options("$<$<CONFIG:RelWithDebInfo>:/Qspectre>" "$<$<CONFIG:RelWithDebInfo>:${ASAN_FLAG}>")
1028 set(CPU ${WIRESHARK_TARGET_PLATFORM})
1029 if (${CPU} MATCHES "win32")
1032 add_link_options("$<$<CONFIG:Debug>:/libpath:$ENV{VCToolsInstallDir}lib\\spectre\\${CPU}>" "$<$<CONFIG:Debug>:/libpath:$ENV{VCToolsInstallDir}lib\\${CPU}>")
1033 add_link_options("$<$<CONFIG:RelWithDebInfo>:/libpath:$ENV{VCToolsInstallDir}lib\\spectre\\${CPU}>" "$<$<CONFIG:RelWithDebInfo>:/libpath:$ENV{VCToolsInstallDir}lib\\${CPU}>")
1035 message(NOTICE "ENABLE_ASAN_WITH_SPECTRE was not requested")
1036 message(NOTICE "For Debug and RelWithDebInfo, SPECTRE-mitigation stays disabled and ASAN has been enabled.")
1037 add_compile_options("$<$<CONFIG:Debug>:${ASAN_FLAG}>")
1038 add_compile_options("$<$<CONFIG:RelWithDebInfo>:${ASAN_FLAG}>")
1040 message(NOTICE "For Release and MinSizeRel, SPECTRE-mitigation has been re-enabled and ASAN has been skipped.")
1041 add_compile_options("$<$<CONFIG:Release>:/Qspectre>")
1042 add_compile_options("$<$<CONFIG:MinSizeRel>:/Qspectre>")
1044 add_compile_options(${ASAN_FLAG})
1047 # Using ASAN makes some of our code require object files with
1048 # a 32-bit index to the section table instead of 16-bit.
1049 # This makes the .obj files slightly larger (~2%) and makes
1050 # it so that Microsoft linkers prior to MSVC 2005 can't read
1051 # the files, but those are too old anyway.
1052 add_compile_options(/bigobj)
1053 # The Microsoft LINK linker doesn't recognize or need the
1054 # ASAN flag, and will give a LNK4044 warning.
1056 # Clang/gcc need the flag added to the linker
1057 # add_link_options since CMake 3.13 (our minimum)
1058 add_link_options(${ASAN_FLAG})
1063 if(NOT ENABLE_ASAN AND ENABLE_ASAN_WITH_SPECTRE)
1064 message(FATAL_ERROR "ENABLE_ASAN_WITH_SPECTRE was requested, but without ENABLE_ASAN!")
1069 # Available since Clang >= 3.2 and GCC >= 4.8
1070 cmake_push_check_state()
1071 set(CMAKE_REQUIRED_LIBRARIES "-fsanitize=thread")
1072 check_c_compiler_flag(-fsanitize=thread C__fsanitize_thread_VALID)
1073 check_cxx_compiler_flag(-fsanitize=thread CXX__fsanitize_thread_VALID)
1074 cmake_pop_check_state()
1075 if(NOT C__fsanitize_thread_VALID OR NOT CXX__fsanitize_thread_VALID)
1076 message(FATAL_ERROR "ENABLE_TSAN was requested, but not supported!")
1078 set(CMAKE_C_FLAGS "-fsanitize=thread ${CMAKE_C_FLAGS}")
1079 set(CMAKE_CXX_FLAGS "-fsanitize=thread ${CMAKE_CXX_FLAGS}")
1080 set(WS_LINK_FLAGS "-fsanitize=thread ${WS_LINK_FLAGS}")
1084 # Available since Clang >= 3.3 and GCC >= 4.9
1085 cmake_push_check_state()
1086 set(CMAKE_REQUIRED_LIBRARIES "-fsanitize=undefined")
1087 check_c_compiler_flag(-fsanitize=undefined C__fsanitize_undefined_VALID)
1088 check_cxx_compiler_flag(-fsanitize=undefined CXX__fsanitize_undefined_VALID)
1089 cmake_pop_check_state()
1090 if(NOT C__fsanitize_undefined_VALID OR NOT CXX__fsanitize_undefined_VALID)
1091 message(FATAL_ERROR "ENABLE_UBSAN was requested, but not supported!")
1093 set(CMAKE_C_FLAGS "-fsanitize=undefined ${CMAKE_C_FLAGS}")
1094 set(CMAKE_CXX_FLAGS "-fsanitize=undefined ${CMAKE_CXX_FLAGS}")
1098 # Available since Clang >= 3.4 and GCC >= 4.9
1099 cmake_push_check_state()
1100 set(CMAKE_REQUIRED_LIBRARIES "-fsanitize=leak")
1101 check_c_compiler_flag(-fsanitize=leak C__fsanitize_leak_VALID)
1102 check_cxx_compiler_flag(-fsanitize=leak CXX__fsanitize_leak_VALID)
1103 cmake_pop_check_state()
1104 if(NOT C__fsanitize_leak_VALID OR NOT CXX__fsanitize_leak_VALID)
1105 message(FATAL_ERROR "ENABLE_LSAN was requested, but not supported!")
1107 set(CMAKE_C_FLAGS "-fsanitize=leak ${CMAKE_C_FLAGS}")
1108 set(CMAKE_CXX_FLAGS "-fsanitize=leak ${CMAKE_CXX_FLAGS}")
1112 # Available since Clang >= 6
1113 # Will enable coverage flags which can be used by the fuzzshark target.
1114 cmake_push_check_state()
1115 set(CMAKE_REQUIRED_LIBRARIES "-fsanitize=fuzzer-no-link")
1116 check_c_compiler_flag(-fsanitize=fuzzer C__fsanitize_fuzzer_no_link_VALID)
1117 check_cxx_compiler_flag(-fsanitize=fuzzer CXX__fsanitize_fuzzer_no_link_VALID)
1118 cmake_pop_check_state()
1119 if(NOT C__fsanitize_fuzzer_no_link_VALID OR NOT CXX__fsanitize_fuzzer_no_link_VALID)
1120 message(FATAL_ERROR "ENABLE_FUZZER was requested, but not supported!")
1122 set(CMAKE_C_FLAGS "-fsanitize=fuzzer-no-link ${CMAKE_C_FLAGS}")
1123 set(CMAKE_CXX_FLAGS "-fsanitize=fuzzer-no-link ${CMAKE_CXX_FLAGS}")
1127 # Disable sanitizers for build-time tools, e.g. lemon
1128 check_c_compiler_flag(-fno-sanitize=all C__fno_sanitize_all_VALID)
1129 if(C__fno_sanitize_all_VALID)
1130 set(NO_SANITIZE_CFLAGS "-fno-sanitize=all")
1131 set(NO_SANITIZE_LDFLAGS "-fno-sanitize=all")
1139 message(FATAL_ERROR "ENABLE_VLD was requested, but not found!")
1141 message(STATUS "Enabling Visual Leak Detector in Debug configuration")
1142 set(WS_MSVC_DEBUG_LINK_FLAGS ${VLD_LINK_FLAGS})
1146 set(WERROR_COMMON_FLAGS "")
1148 if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
1149 set(WERROR_COMMON_FLAGS "/WX")
1152 # If a warning has been enabled by -Wall or -W,
1153 # and have specified -Werror, there appears to be
1154 # no way, in Apple's llvm-gcc, to prevent that
1155 # particular warning from giving an error - not
1156 # with a pragma, not with -Wno-{warning}, and not
1157 # with -Wno-error={warning}.
1159 # Therefore, with that compiler, we just disable
1162 if ((NOT APPLE) OR CMAKE_C_COMPILER_ID MATCHES "Clang")
1163 check_c_compiler_flag(-Werror WERROR)
1165 set(WERROR_COMMON_FLAGS "-Werror")
1172 # Try to have the compiler default to hiding symbols, so that only
1173 # symbols explicitly exported with WS_DLL_PUBLIC will be visible
1174 # outside (shared) libraries; that way, more UN*X builds will catch
1175 # failures to export symbols, rather than having that fail only on
1178 # We don't need that with MSVC, as that's the default.
1180 if( NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
1182 # Try the GCC-and-compatible -fvisibility-hidden first.
1184 check_c_compiler_flag(-fvisibility=hidden FVHIDDEN)
1186 set(CMAKE_C_FLAGS "-fvisibility=hidden ${CMAKE_C_FLAGS}")
1189 # OK, try the Sun^WOracle C -xldscope=hidden
1191 check_c_compiler_flag(-xldscope=hidden XLDSCOPEHIDDEN)
1193 set(CMAKE_C_FLAGS "-xldscope=hidden ${CMAKE_C_FLAGS}")
1197 # If there is anything else, we might want to
1198 # make a list of options to try, and try them
1201 message(WARNING "Hiding shared library symbols is not supported by the compiler."
1202 " All shared library symbols will be exported.")
1207 include(CheckCLinkerFlag)
1209 if(NOT CMAKE_C_COMPILER_ID MATCHES "MSVC" AND NOT OSS_FUZZ)
1211 # The -pie linker option produces a position-independent executable.
1212 # Some Linux distributions have this enabled by default in the compiler,
1213 # so setting it here will be superfluous though.
1215 # Note that linking with static libraries that are not position
1216 # independent may fail, the user can set CMAKE_EXE_LINKER_FLAGS=-no-pie
1219 if(CMAKE_VERSION VERSION_LESS "3.14")
1220 check_c_linker_flag(-pie LINK_pie_VALID)
1222 set(CMAKE_EXE_LINKER_FLAGS "-pie ${CMAKE_EXE_LINKER_FLAGS}")
1225 include(CheckPIESupported)
1226 check_pie_supported()
1230 foreach(THIS_FLAG ${WIRESHARK_LD_FLAGS})
1231 string(MAKE_C_IDENTIFIER "LINK${THIS_FLAG}_VALID" _flag_var)
1232 check_c_linker_flag(${THIS_FLAG} ${_flag_var})
1234 set(WS_LINK_FLAGS "${WS_LINK_FLAGS} ${THIS_FLAG}")
1237 message(STATUS "Linker flags: ${WS_LINK_FLAGS}")
1239 if(APPLE AND EXISTS /usr/local/opt/gettext)
1240 # GLib on macOS requires libintl. Homebrew installs gettext (and
1241 # libintl) in /usr/local/opt/gettext
1242 include_directories(SYSTEM /usr/local/opt/gettext/include)
1243 link_directories(/usr/local/opt/gettext/lib)
1246 # Resets cache variables if the <PackageName>_LIBRARY has become invalid.
1247 # Call it before a find_package(<PackageName> ...) invocation that uses
1248 # find_library(<PackageName>_LIBRARY ...).
1250 # Usage: reset_find_package(<PackageName> [<extra variables to clear>])
1251 function(reset_find_package _package_name)
1253 # find_library / find_package
1254 ${_package_name}_LIBRARY
1255 ${_package_name}_INCLUDE_DIR
1257 ${_package_name}_LIBRARIES
1258 ${_package_name}_INCLUDE_DIRS
1260 ${_package_name}_DLL_DIR
1261 ${_package_name}_DLLS
1262 ${_package_name}_DLL
1263 ${_package_name}_PDB
1266 if(NOT ${_package_name}_LIBRARY OR EXISTS ${${_package_name}_LIBRARY})
1267 # Cache variable is already missing or cache entry is valid.
1270 message(STATUS "Package ${_package_name} has changed, clearing cache.")
1271 foreach(_var IN LISTS variables)
1272 unset(${_var} CACHE)
1276 # ws_find_package(<PackageName>
1277 # <CMakeOptions.txt boolean variable>
1278 # <cmakeconfig.h.in macro definition>
1279 # [remaining find_package() arguments])
1280 macro(ws_find_package _package_name _enable_package _package_cmakedefine)
1281 if(${_enable_package})
1282 # Clear outdated cache variables if not already.
1283 reset_find_package(${_package_name})
1284 find_package(${_package_name} ${ARGN})
1285 if(${_package_name}_FOUND)
1286 set(${_package_cmakedefine} 1)
1291 # The minimum package list
1293 reset_find_package(GLIB2 GLIB2_MAIN_INCLUDE_DIR GLIB2_INTERNAL_INCLUDE_DIR)
1294 find_package(GLIB2 "2.54.0" REQUIRED)
1295 include_directories(SYSTEM ${GLIB2_INCLUDE_DIRS})
1296 reset_find_package(GMODULE2)
1297 find_package(GMODULE2)
1298 reset_find_package(GTHREAD2)
1299 find_package(GTHREAD2 REQUIRED)
1300 reset_find_package(GCRYPT GCRYPT_ERROR_LIBRARY)
1301 find_package(GCRYPT "1.8.0" REQUIRED)
1302 # C Asynchronous resolver
1303 reset_find_package(CARES)
1304 find_package(CARES "1.13.0" REQUIRED)
1305 if (CARES_VERSION VERSION_GREATER_EQUAL "1.28.0")
1306 # Suppress deprecation warnings.
1307 add_compile_definitions(CARES_NO_DEPRECATED)
1309 find_package(LEX REQUIRED)
1311 reset_find_package(PCRE2 PCRE2_DEBUG_LIBRARY)
1312 find_package(PCRE2 REQUIRED)
1315 find_package(Gettext)
1316 find_package(M REQUIRED)
1319 if(BUILD_sshdump OR BUILD_ciscodump OR BUILD_wifidump OR BUILD_sshdig)
1320 set(ENABLE_LIBSSH ON)
1322 set(ENABLE_LIBSSH OFF)
1324 ws_find_package(LIBSSH ENABLE_LIBSSH HAVE_LIBSSH "0.8.5")
1326 ws_find_package(PCAP ENABLE_PCAP HAVE_LIBPCAP)
1327 ws_find_package(Systemd BUILD_sdjournal HAVE_SYSTEMD)
1329 # Build one of the Qt GUIs?
1330 if(BUILD_wireshark OR BUILD_stratoshark)
1333 if(DEFINED ENV{WIRESHARK_QT6_PREFIX_PATH})
1334 list(APPEND CMAKE_PREFIX_PATH $ENV{WIRESHARK_QT6_PREFIX_PATH})
1337 set(CMAKE_CXX_STANDARD 17)
1338 # Setting CMAKE_CXX_STANDARD is not sufficient with MSVC, see
1339 # https://gitlab.kitware.com/cmake/cmake/-/issues/18837
1340 # The below test can be found in Qt6, lib/cmake/Qt6/QtFeature.cmake
1341 if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND MSVC_VERSION GREATER_EQUAL 1913)
1342 # Cannot use add_definitions() here because rc.exe does not understand this flag.
1343 # https://cmake.org/pipermail/cmake/2009-August/031672.html
1344 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Zc:__cplusplus")
1347 find_package(Qt6 REQUIRED
1361 if (WIN32 AND Qt6Widgets_VERSION VERSION_LESS 6.5.3)
1362 message(WARNING "Qt 6.5.3 or later is required.")
1364 if (APPLE AND Qt6Widgets_VERSION VERSION_LESS 6.5.3)
1365 message(WARNING "Qt 6.5.3 or later is required.")
1369 if(DEFINED ENV{WIRESHARK_QT5_PREFIX_PATH})
1370 list(APPEND CMAKE_PREFIX_PATH $ENV{WIRESHARK_QT5_PREFIX_PATH})
1372 if(APPLE AND EXISTS /usr/local/opt/qt5)
1373 # Homebrew installs Qt5 (up to at least 5.11.0) in
1374 # /usr/local/qt5. Ensure that it can be found by CMake
1375 # since it is not in the default /usr/local prefix.
1376 # Add it to PATHS so that it doesn't override the
1377 # CMAKE_PREFIX_PATH environment variable.
1378 # QT_FIND_PACKAGE_OPTIONS should be passed to find_package,
1379 # e.g. find_package(Qt5Core ${QT_FIND_PACKAGE_OPTIONS})
1380 list(APPEND QT5_FIND_PACKAGE_OPTIONS PATHS /usr/local/opt/qt5)
1391 set(QT5_OPTIONAL_PACKAGELIST
1395 list(APPEND QT5_PACKAGELIST Qt5WinExtras)
1397 if(NOT WIN32 AND NOT APPLE)
1398 # DBus is a core component of Qt6, but was an add-on in Qt5.
1399 list(APPEND QT5_OPTIONAL_PACKAGELIST Qt5DBus)
1401 foreach(_qt5_package IN LISTS QT5_PACKAGELIST)
1402 find_package(${_qt5_package} REQUIRED ${QT5_FIND_PACKAGE_OPTIONS})
1403 list(APPEND QT5_LIBRARIES ${${_qt5_package}_LIBRARIES})
1404 list(APPEND QT5_INCLUDE_DIRS ${${_qt5_package}_INCLUDE_DIRS})
1405 list(APPEND QT5_COMPILE_DEFINITIONS ${${_qt5_package}_COMPILE_DEFINITIONS})
1407 foreach(_qt5_package IN LISTS QT5_OPTIONAL_PACKAGELIST)
1408 find_package(${_qt5_package} ${QT5_FIND_PACKAGE_OPTIONS})
1409 list(APPEND QT5_LIBRARIES ${${_qt5_package}_LIBRARIES})
1410 list(APPEND QT5_INCLUDE_DIRS ${${_qt5_package}_INCLUDE_DIRS})
1411 list(APPEND QT5_COMPILE_DEFINITIONS ${${_qt5_package}_COMPILE_DEFINITIONS})
1414 if (Qt5Widgets_VERSION VERSION_LESS 5.15)
1415 message(FATAL_ERROR "Qt 5.15 or later is required. Qt 6 is recommended.")
1418 if(APPLE AND "/usr/local/opt/qt5/lib/QtCore.framework" IN_LIST Qt5Core_INCLUDE_DIRS)
1419 # When qt@6 and qt@5 are both installed via Homebrew,
1420 # /usr/local/include/QtCore/qvariant.h points to Qt 6 headers.
1421 # Normally the Headers from `-iframework /usr/local/opt/qt5/lib`
1422 # should be used, but `-isystem /usr/local/include` (via
1423 # Libgcrypt and others) seems to prioritized, resulting in use
1424 # of the Qt6 headers. Resolve this by explicit including Qt5.
1425 list(APPEND QT5_INCLUDE_DIRS /usr/local/opt/qt5/include)
1431 ws_find_package(Sparkle ENABLE_SPARKLE HAVE_SOFTWARE_UPDATE 2)
1433 if(Qt6Multimedia_FOUND OR Qt5Multimedia_FOUND)
1434 set(QT_MULTIMEDIA_LIB 1)
1436 if(Qt6DBus_FOUND OR Qt5DBus_FOUND)
1439 if(NOT DEFINED MOC_OPTIONS)
1440 # Squelch moc verbose "nothing to do" output
1441 set(MOC_OPTIONS -nn)
1445 # MaxMind DB address resolution
1446 reset_find_package(MAXMINDDB)
1447 ws_find_package(MaxMindDB BUILD_mmdbresolve HAVE_MAXMINDDB)
1450 reset_find_package(SMI SMI_SHARE_DIR)
1451 ws_find_package(SMI ENABLE_SMI HAVE_LIBSMI)
1453 # Support for TLS decryption using RSA private keys.
1454 ws_find_package(GNUTLS ENABLE_GNUTLS HAVE_LIBGNUTLS "3.5.8")
1457 ws_find_package(KERBEROS ENABLE_KERBEROS HAVE_KERBEROS)
1459 # Zlib-ng compression
1460 ws_find_package(ZLIBNG ENABLE_ZLIBNG HAVE_ZLIBNG)
1462 #if(NOT ZLIBNG_FOUND)
1464 ws_find_package(ZLIB ENABLE_ZLIB HAVE_ZLIB)
1467 # Minizip-ng compression
1468 ws_find_package(Minizipng ENABLE_MINIZIPNG HAVE_MINIZIPNG)
1470 if(NOT MINIZIPNG_FOUND)
1471 # Minizip compression
1472 ws_find_package(Minizip ENABLE_MINIZIP HAVE_MINIZIP)
1475 # Brotli compression
1476 ws_find_package(BROTLI ENABLE_BROTLI HAVE_BROTLI)
1479 ws_find_package(LZ4 ENABLE_LZ4 HAVE_LZ4)
1481 # Snappy compression
1482 ws_find_package(SNAPPY ENABLE_SNAPPY HAVE_SNAPPY)
1485 ws_find_package(ZSTD ENABLE_ZSTD HAVE_ZSTD "1.0.0")
1487 # Enhanced HTTP/2 dissection
1488 ws_find_package(NGHTTP2 ENABLE_NGHTTP2 HAVE_NGHTTP2 "1.11.0")
1490 # Enhanced HTTP/3 dissection
1491 ws_find_package(NGHTTP3 ENABLE_NGHTTP3 HAVE_NGHTTP3)
1493 # Embedded Lua interpreter
1495 # Download and build lua
1496 include(${CMAKE_SOURCE_DIR}/cmake/external/lua54/Lua54.cmake)
1498 set(LUA_FIND_VERSIONS "5.4;5.3" CACHE STRING "Lua versions valid for the build (as a list)")
1499 ws_find_package(Lua ENABLE_LUA HAVE_LUA)
1502 ws_find_package(NL ENABLE_NETLINK HAVE_LIBNL)
1504 ws_find_package(SBC ENABLE_SBC HAVE_SBC)
1507 ws_find_package(SPANDSP ENABLE_SPANDSP HAVE_SPANDSP)
1509 ws_find_package(BCG729 ENABLE_BCG729 HAVE_BCG729)
1511 ws_find_package(AMRNB ENABLE_AMRNB HAVE_AMRNB)
1513 ws_find_package(ILBC ENABLE_ILBC HAVE_ILBC)
1515 ws_find_package(OPUS ENABLE_OPUS HAVE_OPUS)
1517 if (BUILD_stratoshark)
1518 # libsinsp+libscap, required for falco-bridge
1519 ws_find_package(Sinsp ENABLE_SINSP HAVE_SINSP "0.17.1")
1522 # CMake 3.9 and below used 'LIBXML2_LIBRARIES' as the name of the cache entry
1523 # storing the find_library result. Transfer it to the new cache variable such
1524 # that reset_find_package can detect and clear outdated cache variables.
1525 if(DEFINED LIBXML2_LIBRARIES AND NOT DEFINED LIBXML2_LIBRARY)
1526 set(LIBXML2_LIBRARY ${LIBXML2_LIBRARIES} CACHE FILEPATH "")
1528 # Call reset_find_package explicitly since variables are in upper case.
1529 reset_find_package(LIBXML2)
1530 ws_find_package(LibXml2 ENABLE_LIBXML2 HAVE_LIBXML2)
1531 if(NOT LIBXML2_FOUND)
1532 # CMake 3.9 and below used LIBXML2_LIBRARIES as the name of
1533 # the cache entry storing the find_library result.
1534 # Current CMake (3.13) and below sets LIBXML2_LIBRARIES and LIBXML2_INCLUDE_DIRS
1535 # to a non-empty value, be sure to clear it when not found.
1536 set(LIBXML2_LIBRARIES "")
1537 set(LIBXML2_INCLUDE_DIRS "")
1540 # Capabilities to run dumpcap as non-root user.
1541 if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
1542 ws_find_package(CAP ENABLE_CAP HAVE_LIBCAP)
1543 find_package(SETCAP)
1546 # Windows version updates
1547 ws_find_package(WinSparkle ENABLE_WINSPARKLE HAVE_SOFTWARE_UPDATE)
1549 find_package( Asciidoctor 1.5 )
1550 find_package( XSLTPROC )
1552 find_package(DOXYGEN)
1554 # The SpeexDSP resampler is required iff building wireshark or sharkd.
1555 if(BUILD_wireshark OR BUILD_stratoshark OR BUILD_sharkd)
1556 find_package(SpeexDSP REQUIRED)
1559 # Generate the distribution tarball.
1560 add_custom_target(dist
1561 COMMAND ${CMAKE_BINARY_DIR}/packaging/source/git-export-release.sh -d "${CMAKE_BINARY_DIR}"
1562 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
1566 # Calculating public keys from PKCS #11 private keys requires GnuTLS
1569 # Check that the support is present in case GnuTLS was compiled
1570 # --without-p11-kit as macos-setup.sh did until December 2020.
1571 cmake_push_check_state()
1572 if(WIN32 AND NOT MINGW)
1573 set(CMAKE_REQUIRED_DEFINITIONS -Dssize_t=int)
1575 set(CMAKE_REQUIRED_INCLUDES ${GNUTLS_INCLUDE_DIRS})
1576 set(CMAKE_REQUIRED_LIBRARIES ${GNUTLS_LIBRARIES})
1577 check_symbol_exists(gnutls_pkcs11_obj_list_import_url4 gnutls/pkcs11.h HAVE_GNUTLS_PKCS11)
1578 cmake_pop_check_state()
1582 # CMake uses qmake to find Qt4. It relies on Qt's CMake modules
1583 # to find Qt5. This means that we can't assume that the qmake
1584 # in our PATH is the correct one. We can fetch qmake's location
1585 # from Qt5::qmake, which is defined in Qt5CoreConfigExtras.cmake.
1586 get_target_property(QT_QMAKE_EXECUTABLE Qt${qtver}::qmake IMPORTED_LOCATION)
1587 get_filename_component(_qt_bin_path "${QT_QMAKE_EXECUTABLE}" DIRECTORY)
1588 set(QT_BIN_PATH "${_qt_bin_path}" CACHE INTERNAL
1589 "Path to qmake, macdeployqt, windeployqt, and other Qt utilities."
1591 # Use qmake to find windeployqt and macdeployqt. Ideally one of
1592 # the modules in ${QTDIR}/lib/cmake would do this for us.
1594 if (USE_qt6 AND USE_MSYSTEM)
1595 set(_windeployqt_name "windeployqt-qt6")
1597 set(_windeployqt_name "windeployqt")
1599 find_program(QT_WINDEPLOYQT_EXECUTABLE ${_windeployqt_name}
1600 HINTS "${QT_BIN_PATH}"
1601 DOC "Path to the windeployqt utility."
1603 # As of Qt 6.5.0, the official Qt "MSVC 2019 ARM64 (TP)" libraries don't ship
1604 # with native Arm64 executables. Instead, you get x64 executables installed in
1605 # msvc2019_x64. Look for the path to "qmake.bat", which has to be passed to
1606 # windeployqt so that it can install the proper DLLs.
1607 # https://bugreports.qt.io/browse/QTBUG-100070
1608 set(QT_WINDEPLOYQT_EXTRA_ARGS)
1609 find_program(_qt_qmake_bat qmake.bat
1610 HINTS ENV CMAKE_PREFIX_PATH
1612 DOC "Path to qmake.bat."
1615 set (QT_WINDEPLOYQT_EXTRA_ARGS "--qmake \"${_qt_qmake_bat}\"")
1618 find_program(QT_MACDEPLOYQT_EXECUTABLE macdeployqt
1619 HINTS "${QT_BIN_PATH}"
1620 DOC "Path to the macdeployqt utility."
1622 find_program(DMGBUILD_EXECUTABLE dmgbuild
1623 DOC "Path to the dmgbuild utility"
1625 # https://doc.qt.io/qt-5/supported-platforms.html
1626 # https://doc.qt.io/qt-5.11/supported-platforms-and-configurations.html
1627 # https://doc.qt.io/qt-5.15/supported-platforms.html
1628 # https://doc-snapshots.qt.io/qt6-dev/supported-platforms.html
1629 if(Qt${qtver}Widgets_VERSION VERSION_GREATER_EQUAL "6.5.0" AND MIN_MACOS_VERSION VERSION_LESS "11.0")
1630 set(MIN_MACOS_VERSION 11.0)
1631 elseif(Qt${qtver}Widgets_VERSION VERSION_GREATER_EQUAL "6.0.0" AND MIN_MACOS_VERSION VERSION_LESS "10.14")
1632 set(MIN_MACOS_VERSION 10.14)
1634 if(CMAKE_OSX_DEPLOYMENT_TARGET AND CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS MIN_MACOS_VERSION)
1635 message(FATAL_ERROR "Qt version ${Qt${qtver}Widgets_VERSION} requires CMAKE_OSX_DEPLOYMENT_TARGET (${CMAKE_OSX_DEPLOYMENT_TARGET}) >= ${MIN_MACOS_VERSION}")
1639 # Qt requires MSVC /permissive- option since 6.3 release
1640 if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND Qt${qtver}Widgets_VERSION VERSION_GREATER_EQUAL "6.3.0")
1641 add_compile_options("/permissive-")
1645 if(ENABLE_CHECKHF_CONFLICT)
1646 set(ENABLE_CHECK_FILTER 1)
1650 # Platform-specific additional libraries.
1653 set(WIN_COMCTL32_LIBRARY comctl32.lib)
1654 set(WIN_IPHLPAPI_LIBRARY iphlpapi.lib)
1655 set(WIN_PSAPI_LIBRARY psapi.lib)
1656 set(WIN_VERSION_LIBRARY version.lib)
1657 set(WIN_WS2_32_LIBRARY ws2_32.lib)
1662 # We assume that APPLE means macOS so that we have the macOS
1665 set(HAVE_MACOS_FRAMEWORKS 1)
1666 FIND_LIBRARY (APPLE_APPLICATION_SERVICES_LIBRARY ApplicationServices)
1667 FIND_LIBRARY (APPLE_APPKIT_LIBRARY AppKit)
1668 FIND_LIBRARY (APPLE_CORE_FOUNDATION_LIBRARY CoreFoundation)
1669 FIND_LIBRARY (APPLE_SYSTEM_CONFIGURATION_LIBRARY SystemConfiguration)
1671 message(STATUS "Building for Mac OS X/OS X/macOS ${MIN_MACOS_VERSION} using SDK ${CMAKE_OSX_SYSROOT}")
1674 include(ConfigureChecks.cmake)
1677 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1680 if(NOT (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang"))
1681 # https://ccache.dev/platform-compiler-language-support.html
1682 message(WARNING "Ccache is enabled, but your compiler is ${CMAKE_C_COMPILER_ID}."
1683 " We wish you the best of luck.")
1685 find_program(CCACHE_EXECUTABLE ccache)
1686 if(CCACHE_EXECUTABLE)
1687 set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}")
1688 set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}")
1689 set(CMAKE_C_LINKER_LAUNCHER "${CCACHE_EXECUTABLE}")
1690 set(CMAKE_CXX_LINKER_LAUNCHER "${CCACHE_EXECUTABLE}")
1694 # The top level checkAPIs target, add before subdirectory calls so it's available to all
1695 add_custom_target(checkAPI)
1696 set_target_properties(checkAPI
1699 EXCLUDE_FROM_ALL True
1700 EXCLUDE_FROM_DEFAULT_BUILD True
1703 include( UseCheckAPI )
1705 # Target platform locations
1706 # UN*X in general, including macOS if not building an app bundle:
1707 # $DESTDIR/lib/wireshark/extcap
1708 # Windows: $DESTDIR/extcap
1709 # macOS app bundle: Wireshark.app/Contents/Resources/share/wireshark/extcap
1710 # If you change the nesting level be sure to check also the INSTALL_RPATH
1712 if(WIN32 AND NOT USE_MSYSTEM)
1713 set(EXTCAP_INSTALL_LIBDIR "extcap/${PROJECT_NAME}" CACHE INTERNAL "The Wireshark extcap dir")
1714 if (BUILD_stratoshark)
1715 set(LOG_EXTCAP_INSTALL_LIBDIR "extcap/${LOG_PROJECT_NAME}" CACHE INTERNAL "The Stratoshark extcap dir")
1718 set(EXTCAP_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/extcap" CACHE INTERNAL "The Wireshark extcap dir")
1719 if (BUILD_stratoshark)
1720 set(LOG_EXTCAP_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${LOG_PROJECT_NAME}/extcap" CACHE INTERNAL "The Stratoshark extcap dir")
1726 # As https://developer.apple.com/library/archive/technotes/tn2206/_index.html
1729 # "Note that a location where code is expected to reside cannot generally
1730 # contain directories full of nested code, because those directories tend
1731 # to be interpreted as bundles. So this occasional practice is not
1732 # recommended and not officially supported. If you do do this, do not use
1733 # periods in the directory names. The code signing machinery interprets
1734 # directories with periods in their names as code bundles and will reject
1735 # them if they don't conform to the expected code bundle layout."
1737 set(PLUGIN_PATH_ID "${PROJECT_MAJOR_VERSION}-${PROJECT_MINOR_VERSION}")
1739 set(PLUGIN_PATH_ID "${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}")
1742 # Directory where plugins and Lua dissectors can be found.
1743 if(WIN32 AND NOT USE_MSYSTEM)
1744 set(PLUGIN_INSTALL_LIBDIR "plugins" CACHE INTERNAL "The plugin dir")
1746 set(PLUGIN_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/plugins" CACHE INTERNAL "The plugin dir")
1748 set(PLUGIN_INSTALL_FULL_LIBDIR "${CMAKE_INSTALL_PREFIX}/${PLUGIN_INSTALL_LIBDIR}")
1749 set(PLUGIN_INSTALL_VERSION_LIBDIR "${PLUGIN_INSTALL_LIBDIR}/${PLUGIN_PATH_ID}")
1750 set(PLUGIN_VERSION_DIR "plugins/${PLUGIN_PATH_ID}")
1752 add_subdirectory( capture )
1753 add_subdirectory( epan )
1754 add_subdirectory( extcap )
1755 add_subdirectory( randpkt_core )
1756 if(NOT LEMON_EXECUTABLE)
1757 add_subdirectory( tools/lemon )
1760 add_subdirectory( tools/radiotap-gen )
1762 add_subdirectory( ui )
1763 add_subdirectory( wiretap )
1764 add_subdirectory( writecap )
1766 # Location of our data files. This should be set to a value that allows
1767 # running from the build directory on Windows, on macOS when building an
1768 # application bundle, and on UNIX in general if
1769 # WIRESHARK_RUN_FROM_BUILD_DIRECTORY is set.
1770 if(ENABLE_APPLICATION_BUNDLE)
1771 if(CMAKE_CFG_INTDIR STREQUAL ".")
1772 set(_datafile_dir "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/share/wireshark")
1775 set(_datafile_dir "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}/Wireshark.app/Contents/Resources/share/wireshark")
1777 elseif(NOT CMAKE_CFG_INTDIR STREQUAL ".")
1778 # Visual Studio, Xcode, etc.
1779 set(_datafile_dir "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}")
1781 # Makefile, Ninja, etc.
1782 set(_datafile_dir "${CMAKE_BINARY_DIR}/run")
1785 set(DATAFILE_DIR ${_datafile_dir} CACHE INTERNAL "Build time data file location.")
1787 if(ENABLE_APPLICATION_BUNDLE)
1788 if(CMAKE_CFG_INTDIR STREQUAL ".")
1789 set(_log_datafile_dir "${CMAKE_BINARY_DIR}/run/Stratoshark.app/Contents/Resources/share/stratoshark")
1792 set(_log_datafile_dir "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}/Stratoshark.app/Contents/Resources/share/stratoshark")
1794 set(LOG_DATAFILE_DIR ${_log_datafile_dir} CACHE INTERNAL "Build time log analysis data file location.")
1795 # XXX We need to update wsutil/filesystem.c and packaging/nsis/*stratoshark* to match.
1796 # elseif(NOT CMAKE_CFG_INTDIR STREQUAL ".")
1797 # # Visual Studio, Xcode, etc.
1798 # set(_log_datafile_dir "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}/share/stratoshark")
1800 # # Makefile, Ninja, etc.
1801 # set(_log_datafile_dir "${CMAKE_BINARY_DIR}/run/share/stratoshark")
1804 # wsutil must be added after DATAFILE_DIR is set such that filesystem.c can
1805 # learn about the directory location.
1806 add_subdirectory( wsutil )
1808 # doc/ must be added after DATAFILE_DIR is set so that the guides can be
1809 # copied there for running from the build directory
1810 add_subdirectory( doc )
1812 if(BUILD_wireshark AND QT_FOUND)
1813 add_subdirectory( ui/qt )
1814 elseif(BUILD_wireshark AND USE_qt6)
1815 message(VERBOSE "To use Qt5 instead of Qt6 use CMake option USE_qt6=OFF.")
1818 if(BUILD_stratoshark AND QT_FOUND)
1819 add_subdirectory( ui/stratoshark )
1822 # Location of our plugins. PLUGIN_DIR should allow running
1823 # from the build directory similar to DATAFILE_DIR above.
1825 # Target platform locations
1826 # UN*X in general, including macOS if not building an app bundle:
1827 # $DESTDIR/lib/wireshark/plugins/$VERSION
1828 # Windows: $DESTDIR/wireshark/plugins/$VERSION
1829 # macOS app bundle: Wireshark.app/Contents/PlugIns/wireshark
1831 add_custom_target(plugins)
1832 set_target_properties(plugins PROPERTIES FOLDER "Plugins")
1834 plugins/epan/ethercat
1835 plugins/epan/gryphon
1839 plugins/epan/profinet
1840 plugins/epan/stats_tree
1841 plugins/epan/transum
1842 plugins/epan/unistim
1844 plugins/epan/wimaxasncp
1845 plugins/epan/wimaxmacphy
1846 plugins/epan/dfilter/ipaddr
1847 plugins/wiretap/usbdump
1849 plugins/codecs/l16_mono
1850 ${CUSTOM_PLUGIN_SRC_DIR}
1852 set(STRATOSHARK_PLUGIN_SRC_DIRS)
1854 list(APPEND STRATOSHARK_PLUGIN_SRC_DIRS
1855 plugins/epan/falco_bridge
1859 list(APPEND PLUGIN_SRC_DIRS
1865 list(APPEND PLUGIN_SRC_DIRS
1870 list(APPEND PLUGIN_SRC_DIRS
1871 plugins/codecs/amrnb
1875 list(APPEND PLUGIN_SRC_DIRS
1880 list(APPEND PLUGIN_SRC_DIRS
1881 plugins/codecs/opus_dec
1885 list(APPEND PLUGIN_SRC_DIRS
1890 # Build demo plugin, only if asked explicitly
1891 if(ENABLE_PLUGIN_IFDEMO)
1892 list(APPEND PLUGIN_SRC_DIRS
1893 plugins/epan/pluginifdemo
1898 set(PLUGIN_SRC_DIRS )
1899 set(STRATOSHARK_PLUGIN_SRC_DIRS )
1902 if(ENABLE_APPLICATION_BUNDLE)
1903 if(CMAKE_CFG_INTDIR STREQUAL ".")
1904 set(_plugin_dir "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/PlugIns/wireshark/${PLUGIN_PATH_ID}")
1907 set(_plugin_dir "${CMAKE_BINARY_DIR}/run/$<CONFIG>/Wireshark.app/Contents/PlugIns/wireshark/${PLUGIN_PATH_ID}")
1909 if(CMAKE_CFG_INTDIR STREQUAL ".")
1910 set(_stratoshark_plugin_dir "${CMAKE_BINARY_DIR}/run/Stratoshark.app/Contents/PlugIns/stratoshark/${PLUGIN_PATH_ID}")
1913 set(_stratoshark_plugin_dir "${CMAKE_BINARY_DIR}/run/$<CONFIG>/Stratoshark.app/Contents/PlugIns/stratoshark/${PLUGIN_PATH_ID}")
1915 elseif(MSVC AND NOT CMAKE_CFG_INTDIR STREQUAL ".")
1916 set(_plugin_dir "${CMAKE_BINARY_DIR}/run/$<CONFIG>/${PLUGIN_VERSION_DIR}")
1917 set(_stratoshark_plugin_dir ${_plugin_dir})
1919 set(_plugin_dir "${DATAFILE_DIR}/${PLUGIN_VERSION_DIR}")
1920 set(_stratoshark_plugin_dir ${_plugin_dir})
1922 set (PLUGIN_DIR ${_plugin_dir} CACHE INTERNAL "Build time plugin location.")
1923 set (STRATOSHARK_PLUGIN_DIR ${_stratoshark_plugin_dir} CACHE INTERNAL "Build time Stratoshark plugin location.")
1925 foreach(_plugin_src_dir ${PLUGIN_SRC_DIRS} ${STRATOSHARK_PLUGIN_SRC_DIRS})
1926 add_subdirectory( ${_plugin_src_dir} )
1929 if(VCSVERSION_OVERRIDE)
1930 # Allow distributors to override detection of the Git tag and version.
1931 string(CONFIGURE "#define VCSVERSION \"@VCSVERSION_OVERRIDE@\"\n"
1932 _version_h_contents ESCAPE_QUOTES)
1933 file(WRITE "${CMAKE_BINARY_DIR}/vcs_version.h" "${_version_h_contents}")
1934 message(STATUS "VCSVERSION_OVERRIDE: ${VCSVERSION_OVERRIDE}")
1936 add_custom_target(vcs_version
1937 BYPRODUCTS vcs_version.h
1938 COMMAND ${Python3_EXECUTABLE}
1939 ${CMAKE_SOURCE_DIR}/tools/make-version.py
1942 set_target_properties(vcs_version PROPERTIES FOLDER "Auxiliary")
1945 set( configure_input "Built with CMake ${CMAKE_VERSION}" )
1946 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
1948 configure_file(${CMAKE_SOURCE_DIR}/ws_version.h.in ${CMAKE_BINARY_DIR}/ws_version.h)
1951 file(GLOB TOP_LEVEL_SOURCE_LIST *.c *.cpp *.h)
1952 string (REPLACE ";" " " DOXYGEN_TOP_LEVEL_SOURCES "${TOP_LEVEL_SOURCE_LIST}")
1953 set(DOXYGEN_INPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
1954 set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
1958 packaging/macosx/osx-app.sh
1959 packaging/macosx/osx-dmg.sh
1960 packaging/macosx/wireshark-app.dmgbuild
1961 packaging/macosx/wireshark-dsym.dmgbuild
1962 packaging/macosx/WiresharkInfo.plist
1963 packaging/source/git-export-release.sh
1964 resources/dumpcap.rc
1965 resources/libwireshark.rc
1966 resources/libwiretap.rc
1967 resources/libwsutil.rc
1968 resources/wireshark.exe.manifest
1969 resources/wireshark.pc
1970 resources/wireshark.rc
1973 if(BUILD_stratoshark)
1974 list(APPEND CFG_OUT_FILES
1975 packaging/macosx/StratosharkInfo.plist
1976 packaging/macosx/stratoshark-app.dmgbuild
1977 packaging/macosx/stratoshark-dsym.dmgbuild
1978 resources/stratoshark.exe.manifest
1982 foreach( _cfg_file ${CFG_OUT_FILES} )
1983 configure_file( ${CMAKE_SOURCE_DIR}/${_cfg_file}.in ${CMAKE_BINARY_DIR}/${_cfg_file} @ONLY )
1986 include(FeatureSummary)
1987 set_package_properties(CAP PROPERTIES
1988 DESCRIPTION "The Libcap package implements the user-space interfaces to the POSIX 1003.1e capabilities available in Linux kernels"
1989 URL "https://sites.google.com/site/fullycapable/"
1990 PURPOSE "Allow packet captures without running as root"
1992 set_package_properties(SBC PROPERTIES
1993 DESCRIPTION "Bluetooth low-complexity, subband codec (SBC) decoder"
1994 URL "https://git.kernel.org/pub/scm/bluetooth/sbc.git"
1995 PURPOSE "Support for playing SBC codec in RTP player"
1997 set_package_properties(SPANDSP PROPERTIES
1998 DESCRIPTION "a library of many DSP functions for telephony"
1999 URL "https://www.soft-switch.org"
2000 PURPOSE "Support for G.722 and G.726 codecs in RTP player"
2002 set_package_properties(BCG729 PROPERTIES
2003 DESCRIPTION "G.729 decoder"
2004 URL "https://www.linphone.org/technical-corner/bcg729"
2005 PURPOSE "Support for G.729 codec in RTP player"
2007 set_package_properties(AMRNB PROPERTIES
2008 DESCRIPTION "AMRNB decoder"
2009 URL "https://sourceforge.net/p/opencore-amr"
2010 PURPOSE "Support for AMRNB codec in RTP player"
2012 set_package_properties(ILBC PROPERTIES
2013 DESCRIPTION "iLBC decoder"
2014 URL "https://github.com/TimothyGu/libilbc"
2015 PURPOSE "Support for iLBC codec in RTP player"
2017 set_package_properties(OPUS PROPERTIES
2018 DESCRIPTION "opus decoder"
2019 URL "https://opus-codec.org/"
2020 PURPOSE "Support for opus codec in RTP player"
2022 set_package_properties(LIBXML2 PROPERTIES
2023 DESCRIPTION "XML parsing library"
2024 URL "http://xmlsoft.org/"
2025 PURPOSE "Read XML configuration files in EPL dissector"
2027 set_package_properties(LIBSSH PROPERTIES
2028 DESCRIPTION "Library for implementing SSH clients"
2029 URL "https://www.libssh.org/"
2030 PURPOSE "extcap remote SSH interfaces (sshdump, ciscodump, wifidump, sshdig)"
2032 set_package_properties(LZ4 PROPERTIES
2033 DESCRIPTION "LZ4 is a fast lossless compression algorithm"
2034 URL "http://www.lz4.org"
2035 PURPOSE "LZ4 decompression in CQL and Kafka dissectors, read compressed capture files"
2037 set_package_properties(SNAPPY PROPERTIES
2038 DESCRIPTION "A fast compressor/decompressor from Google"
2039 URL "https://google.github.io/snappy/"
2040 PURPOSE "Snappy decompression in Couchbase, CQL, Kafka and Mongo dissectors"
2042 set_package_properties(ZSTD PROPERTIES
2043 DESCRIPTION "A compressor/decompressor from Facebook providing better compression than Snappy at a cost of speed"
2044 URL "https://facebook.github.io/zstd/"
2045 PURPOSE "Zstd decompression in Kafka dissector, read compressed capture files"
2047 set_package_properties(NGHTTP2 PROPERTIES
2048 DESCRIPTION "HTTP/2 C library and tools"
2049 URL "https://nghttp2.org"
2050 PURPOSE "Header decompression in HTTP2"
2052 set_package_properties(NGHTTP3 PROPERTIES
2053 DESCRIPTION "HTTP/3 C library and tools"
2054 URL "https://nghttp2.org"
2055 PURPOSE "Header decompression in HTTP3"
2057 set_package_properties(CARES PROPERTIES
2058 DESCRIPTION "Library for asynchronous DNS requests"
2059 URL "https://c-ares.org/"
2060 PURPOSE "DNS name resolution for captures"
2062 set_package_properties(Systemd PROPERTIES
2063 URL "https://freedesktop.org/wiki/Software/systemd/"
2064 DESCRIPTION "System and Service Manager (libraries)"
2065 PURPOSE "Support for systemd journal extcap interface (sdjournal)"
2067 set_package_properties(NL PROPERTIES
2068 URL "https://www.infradead.org/~tgr/libnl/"
2069 DESCRIPTION "Libraries for using the Netlink protocol on Linux"
2070 PURPOSE "Support for managing wireless 802.11 interfaces"
2072 set_package_properties(MaxMindDB PROPERTIES
2073 URL "https://github.com/maxmind/libmaxminddb"
2074 DESCRIPTION "C library for the MaxMind DB file format"
2075 PURPOSE "Support for GeoIP lookup"
2077 set_package_properties(SpeexDSP PROPERTIES
2078 URL "https://www.speex.org/"
2079 DESCRIPTION "SpeexDSP is a patent-free, Open Source/Free Software DSP library"
2080 PURPOSE "RTP audio resampling"
2082 set_package_properties(Minizip PROPERTIES
2083 URL "https://github.com/madler/zlib"
2084 DESCRIPTION "Mini zip and unzip based on zlib"
2085 PURPOSE "Support for profiles import/export"
2087 set_package_properties(Minizipng PROPERTIES
2088 URL "https://github.com/zlib-ng/minizip-ng"
2089 DESCRIPTION "A fork of the minizip library - Mini zip and unzip based on zlib"
2090 PURPOSE "Support for profiles import/export"
2092 set_package_properties(SMI PROPERTIES
2093 URL "https://www.ibr.cs.tu-bs.de/projects/libsmi/"
2094 DESCRIPTION "Library to access SMI management information"
2095 PURPOSE "Support MIB and PIB parsing and OID resolution"
2097 set_package_properties(PCRE2 PROPERTIES
2098 URL "https://www.pcre.org"
2099 DESCRIPTION "Regular expression pattern matching using the same syntax and semantics as Perl 5"
2100 PURPOSE "Support for regular expressions"
2102 set_package_properties(Sinsp PROPERTIES
2103 DESCRIPTION "libsinsp and libscap"
2104 URL "https://github.com/falcosecurity/libs/"
2105 PURPOSE "Support for Falco plugins"
2107 set_package_properties(Lua PROPERTIES
2108 DESCRIPTION "Lua is a powerful, efficient, lightweight, embeddable scripting language"
2109 URL "https://www.lua.org/"
2110 PURPOSE "Lua allows writing dissectors and other extensions without a C/C++ compiler"
2113 string(TOUPPER "${CMAKE_BUILD_TYPE}" _build_type)
2114 message(STATUS "C-Flags: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${_build_type}}")
2115 message(STATUS "CXX-Flags: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${_build_type}}")
2116 if(WERROR_COMMON_FLAGS)
2117 message(STATUS "Warnings as errors enabled: ${WERROR_COMMON_FLAGS}")
2119 message(STATUS "Warnings as errors disabled")
2122 feature_summary(WHAT ALL)
2124 # Should this be part of libui?
2127 ui/win32/file_dlg_win32.cpp
2131 ui/macosx/cocoa_bridge.mm
2134 list(APPEND PLATFORM_UI_SRC ui/macosx/sparkle_bridge.m)
2139 ${CMAKE_SOURCE_DIR}/ui/cli/tap-credentials.c
2140 ${CMAKE_SOURCE_DIR}/ui/cli/tap-camelsrt.c
2141 ${CMAKE_SOURCE_DIR}/ui/cli/tap-diameter-avp.c
2142 ${CMAKE_SOURCE_DIR}/ui/cli/tap-expert.c
2143 ${CMAKE_SOURCE_DIR}/ui/cli/tap-exportobject.c
2144 ${CMAKE_SOURCE_DIR}/ui/cli/tap-endpoints.c
2145 ${CMAKE_SOURCE_DIR}/ui/cli/tap-flow.c
2146 ${CMAKE_SOURCE_DIR}/ui/cli/tap-follow.c
2147 ${CMAKE_SOURCE_DIR}/ui/cli/tap-funnel.c
2148 ${CMAKE_SOURCE_DIR}/ui/cli/tap-gsm_astat.c
2149 ${CMAKE_SOURCE_DIR}/ui/cli/tap-hosts.c
2150 ${CMAKE_SOURCE_DIR}/ui/cli/tap-httpstat.c
2151 ${CMAKE_SOURCE_DIR}/ui/cli/tap-icmpstat.c
2152 ${CMAKE_SOURCE_DIR}/ui/cli/tap-icmpv6stat.c
2153 ${CMAKE_SOURCE_DIR}/ui/cli/tap-iostat.c
2154 ${CMAKE_SOURCE_DIR}/ui/cli/tap-iousers.c
2155 ${CMAKE_SOURCE_DIR}/ui/cli/tap-macltestat.c
2156 ${CMAKE_SOURCE_DIR}/ui/cli/tap-protocolinfo.c
2157 ${CMAKE_SOURCE_DIR}/ui/cli/tap-protohierstat.c
2158 ${CMAKE_SOURCE_DIR}/ui/cli/tap-rlcltestat.c
2159 ${CMAKE_SOURCE_DIR}/ui/cli/tap-rpcprogs.c
2160 ${CMAKE_SOURCE_DIR}/ui/cli/tap-rtd.c
2161 ${CMAKE_SOURCE_DIR}/ui/cli/tap-rtp.c
2162 ${CMAKE_SOURCE_DIR}/ui/cli/tap-rtspstat.c
2163 ${CMAKE_SOURCE_DIR}/ui/cli/tap-sctpchunkstat.c
2164 ${CMAKE_SOURCE_DIR}/ui/cli/tap-simple_stattable.c
2165 ${CMAKE_SOURCE_DIR}/ui/cli/tap-sipstat.c
2166 ${CMAKE_SOURCE_DIR}/ui/cli/tap-smbsids.c
2167 ${CMAKE_SOURCE_DIR}/ui/cli/tap-srt.c
2168 ${CMAKE_SOURCE_DIR}/ui/cli/tap-stats_tree.c
2169 ${CMAKE_SOURCE_DIR}/ui/cli/tap-sv.c
2170 ${CMAKE_SOURCE_DIR}/ui/cli/tap-voip.c
2171 ${CMAKE_SOURCE_DIR}/ui/cli/tap-wspstat.c
2172 ${CUSTOM_TSHARK_TAP_SRC}
2176 # Copied into ${DATAFILE_DIR} at build time and ${CMAKE_INSTALL_DATADIR}/wireshark
2179 resources/share/wireshark/profiles
2180 resources/protocols/diameter
2181 resources/protocols/dtds
2182 resources/protocols/radius
2183 resources/protocols/tpncp
2184 resources/protocols/wimaxasncp
2187 # Copied into ${DATAFILE_DIR} at build time and ${CMAKE_INSTALL_DATADIR}/wireshark
2190 resources/share/wireshark/cfilters
2191 resources/share/wireshark/colorfilters
2192 resources/share/wireshark/dmacros
2193 resources/share/wireshark/dfilters
2194 resources/share/wireshark/ipmap.html
2195 resources/share/wireshark/smi_modules
2200 resources/share/doc/wireshark/pdml2html.xsl
2201 doc/README.xml-output
2205 if (BUILD_stratoshark)
2206 set(LOG_INSTALL_DIRS
2207 resources/share/stratoshark/profiles
2210 set(LOG_INSTALL_FILES
2212 resources/share/stratoshark/colorfilters
2213 resources/share/stratoshark/dfilter_buttons
2217 if (ASCIIDOCTOR_FOUND)
2218 list(APPEND DOC_FILES
2219 ${CMAKE_BINARY_DIR}/doc/man_pages/androiddump.html
2220 ${CMAKE_BINARY_DIR}/doc/man_pages/udpdump.html
2221 ${CMAKE_BINARY_DIR}/doc/man_pages/capinfos.html
2222 ${CMAKE_BINARY_DIR}/doc/man_pages/captype.html
2223 ${CMAKE_BINARY_DIR}/doc/man_pages/ciscodump.html
2224 ${CMAKE_BINARY_DIR}/doc/man_pages/dumpcap.html
2225 ${CMAKE_BINARY_DIR}/doc/man_pages/editcap.html
2226 ${CMAKE_BINARY_DIR}/doc/man_pages/extcap.html
2227 ${CMAKE_BINARY_DIR}/doc/man_pages/mergecap.html
2228 ${CMAKE_BINARY_DIR}/doc/man_pages/randpkt.html
2229 ${CMAKE_BINARY_DIR}/doc/man_pages/randpktdump.html
2230 ${CMAKE_BINARY_DIR}/doc/man_pages/etwdump.html
2231 ${CMAKE_BINARY_DIR}/doc/man_pages/rawshark.html
2232 ${CMAKE_BINARY_DIR}/doc/man_pages/reordercap.html
2233 ${CMAKE_BINARY_DIR}/doc/man_pages/sshdig.html
2234 ${CMAKE_BINARY_DIR}/doc/man_pages/sshdump.html
2235 ${CMAKE_BINARY_DIR}/doc/man_pages/wifidump.html
2236 ${CMAKE_BINARY_DIR}/doc/man_pages/text2pcap.html
2237 ${CMAKE_BINARY_DIR}/doc/man_pages/tshark.html
2238 ${CMAKE_BINARY_DIR}/doc/man_pages/wireshark.html
2239 ${CMAKE_BINARY_DIR}/doc/man_pages/wireshark-filter.html
2240 ${CMAKE_BINARY_DIR}/doc/release-notes.html
2243 list(APPEND DOC_FILES ${CMAKE_BINARY_DIR}/doc/man_pages/mmdbresolve.html)
2246 if (BUILD_corbaidl2wrs)
2247 list(APPEND DOC_FILES ${CMAKE_BINARY_DIR}/doc/man_pages/idl2wrs.html)
2250 list(APPEND DOC_FILES
2251 ${CMAKE_BINARY_DIR}/doc/man_pages/asn2deb.html
2252 ${CMAKE_BINARY_DIR}/doc/man_pages/idl2deb.html
2255 if (BUILD_stratoshark)
2256 list(APPEND DOC_FILES
2257 ${CMAKE_BINARY_DIR}/doc/man_pages/falcodump.html
2263 # We do this for Windows further down in the copy_data_files target.
2264 list(APPEND DOC_FILES COPYING)
2268 set(_dll_output_dir "$<TARGET_FILE_DIR:wsutil>")
2269 add_custom_target(copy_cli_dlls)
2270 set_target_properties(copy_cli_dlls PROPERTIES FOLDER "Copy Tasks")
2271 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
2272 COMMAND ${CMAKE_COMMAND} -E make_directory "${_dll_output_dir}"
2275 # XXX Can (and should) we iterate over these similar to the way
2276 # the top-level CMakeLists.txt iterates over the package list?
2278 # Required DLLs and their corresponding PDBs.
2279 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
2280 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2281 "$<IF:$<CONFIG:Debug>,${GLIB2_DLLS_DEBUG},${GLIB2_DLLS_RELEASE}>"
2282 "$<IF:$<CONFIG:Debug>,${GLIB2_PDBS_DEBUG},${GLIB2_PDBS_RELEASE}>"
2283 "${_dll_output_dir}"
2284 WORKING_DIRECTORY $<IF:$<CONFIG:Debug>,${GLIB2_DLL_DIR_DEBUG},${GLIB2_DLL_DIR_RELEASE}>
2285 COMMAND_EXPAND_LISTS
2288 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
2289 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2290 "$<IF:$<CONFIG:Debug>,${PCRE2_DEBUG_DLL},${PCRE2_RELEASE_DLL}>"
2291 "$<IF:$<CONFIG:Debug>,${PCRE2_DEBUG_PDB},${PCRE2_RELEASE_PDB}>"
2292 "${_dll_output_dir}"
2293 WORKING_DIRECTORY $<IF:$<CONFIG:Debug>,${PCRE2_DEBUG_DLL_DIR},${PCRE2_RELEASE_DLL_DIR}>
2294 COMMAND_EXPAND_LISTS
2297 if (MSVC AND VLD_FOUND)
2298 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
2299 COMMAND ${CMAKE_COMMAND} -E "$<IF:$<CONFIG:Debug>,copy_if_different,true>"
2301 "${_dll_output_dir}"
2302 COMMAND_EXPAND_LISTS
2306 # Third party DLLs and PDBs.
2307 set (THIRD_PARTY_DLLS)
2308 set (THIRD_PARTY_PDBS)
2309 list (APPEND THIRD_PARTY_DLLS "${CARES_DLL_DIR}/${CARES_DLL}")
2310 list (APPEND THIRD_PARTY_PDBS "${CARES_DLL_DIR}/${CARES_PDB}")
2311 # vcpkg's libmaxminddb is static-only for now. This can be uncommented when
2312 # https://github.com/maxmind/libmaxminddb/commit/3998f42bdb6678cbaa1a543057e5c81ba1668ac2
2313 # percolates up to vcpkg.
2314 # if (MAXMINDDB_FOUND)
2315 # list (APPEND THIRD_PARTY_DLLS "${MAXMINDDB_DLL_DIR}/${MAXMINDDB_DLL}")
2316 # endif(MAXMINDDB_FOUND)
2318 foreach( _dll ${LIBSSH_DLLS} )
2319 list (APPEND THIRD_PARTY_DLLS "${LIBSSH_DLL_DIR}/${_dll}")
2322 foreach( _dll ${GCRYPT_DLLS} )
2323 list (APPEND THIRD_PARTY_DLLS "${GCRYPT_DLL_DIR}/${_dll}")
2325 foreach( _dll ${GNUTLS_DLLS} )
2326 list (APPEND THIRD_PARTY_DLLS "${GNUTLS_DLL_DIR}/${_dll}")
2328 foreach( _dll ${KERBEROS_DLLS} )
2329 list (APPEND THIRD_PARTY_DLLS "${KERBEROS_DLL_DIR}/${_dll}")
2332 list (APPEND THIRD_PARTY_DLLS "${LUA_DLL_DIR}/${LUA_DLL}")
2335 list (APPEND THIRD_PARTY_DLLS "${LZ4_DLL_DIR}/${LZ4_DLL}")
2336 list (APPEND THIRD_PARTY_PDBS "${LZ4_DLL_DIR}/${LZ4_PDB}")
2339 list (APPEND THIRD_PARTY_DLLS "${MINIZIP_DLL_DIR}/${MINIZIP_DLL}")
2340 list (APPEND THIRD_PARTY_PDBS "${MINIZIP_DLL_DIR}/${MINIZIP_PDB}")
2342 if (MINIZIPNG_FOUND)
2343 foreach( _dll ${MINIZIPNG_DLLS} )
2344 list (APPEND THIRD_PARTY_DLLS "${MINIZIPNG_DLL_DIR}/${_dll}")
2346 foreach( _pdb ${MINIZIPNG_PDBS} )
2347 list (APPEND THIRD_PARTY_PDBS "${MINIZIPNG_DLL_DIR}/${_pdb}")
2351 list (APPEND THIRD_PARTY_DLLS "${NGHTTP2_DLL_DIR}/${NGHTTP2_DLL}")
2352 list (APPEND THIRD_PARTY_PDBS "${NGHTTP2_DLL_DIR}/${NGHTTP2_PDB}")
2353 endif(NGHTTP2_FOUND)
2355 list (APPEND THIRD_PARTY_DLLS "${NGHTTP3_DLL_DIR}/${NGHTTP3_DLL}")
2356 list (APPEND THIRD_PARTY_PDBS "${NGHTTP3_DLL_DIR}/${NGHTTP3_PDB}")
2357 endif(NGHTTP3_FOUND)
2359 list (APPEND THIRD_PARTY_DLLS "${SBC_DLL_DIR}/${SBC_DLL}")
2362 list (APPEND THIRD_PARTY_DLLS "${SPANDSP_DLL_DIR}/${SPANDSP_DLL}")
2363 endif(SPANDSP_FOUND)
2365 list (APPEND THIRD_PARTY_DLLS "${BCG729_DLL_DIR}/${BCG729_DLL}")
2368 list (APPEND THIRD_PARTY_DLLS "${AMRNB_DLL_DIR}/${AMRNB_DLL}")
2371 list (APPEND THIRD_PARTY_DLLS "${ILBC_DLL_DIR}/${ILBC_DLL}")
2374 list (APPEND THIRD_PARTY_DLLS "${OPUS_DLL_DIR}/${OPUS_DLL}")
2377 foreach( _dll ${LIBXML2_DLLS} )
2378 list (APPEND THIRD_PARTY_DLLS "${LIBXML2_DLL_DIR}/${_dll}")
2380 foreach( _pdb ${LIBXML2_PDBS} )
2381 list (APPEND THIRD_PARTY_PDBS "${LIBXML2_DLL_DIR}/${_pdb}")
2383 endif(LIBXML2_FOUND)
2385 list (APPEND THIRD_PARTY_DLLS "${SMI_DLL_DIR}/${SMI_DLL}")
2386 # Wireshark.nsi wants SMI_DIR which is the base SMI directory
2387 get_filename_component(SMI_DIR ${SMI_DLL_DIR} DIRECTORY)
2388 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
2389 COMMAND ${CMAKE_COMMAND} -E make_directory
2390 "${_dll_output_dir}/snmp"
2391 COMMAND ${CMAKE_COMMAND} -E make_directory
2392 "${_dll_output_dir}/snmp/mibs"
2393 COMMAND ${CMAKE_COMMAND} -E copy_directory
2394 "${SMI_SHARE_DIR}/mibs/iana"
2395 "${_dll_output_dir}/snmp/mibs"
2396 COMMAND ${CMAKE_COMMAND} -E copy_directory
2397 "${SMI_SHARE_DIR}/mibs/ietf"
2398 "${_dll_output_dir}/snmp/mibs"
2399 COMMAND ${CMAKE_COMMAND} -E copy_directory
2400 "${SMI_SHARE_DIR}/mibs/irtf"
2401 "${_dll_output_dir}/snmp/mibs"
2402 COMMAND ${CMAKE_COMMAND} -E copy_directory
2403 "${SMI_SHARE_DIR}/mibs/site"
2404 "${_dll_output_dir}/snmp/mibs"
2405 COMMAND ${CMAKE_COMMAND} -E copy_directory
2406 "${SMI_SHARE_DIR}/mibs/tubs"
2407 "${_dll_output_dir}/snmp/mibs"
2408 COMMAND ${CMAKE_COMMAND} -E copy_directory
2409 "${SMI_SHARE_DIR}/pibs"
2410 "${_dll_output_dir}/snmp/mibs"
2411 COMMAND ${CMAKE_COMMAND} -E copy_directory
2412 "${SMI_SHARE_DIR}/yang"
2413 "${_dll_output_dir}/snmp/mibs"
2414 #remove the extra directories copied (shallow copying the above would remove the need for this)
2415 COMMAND ${CMAKE_COMMAND} -E remove_directory
2416 "${_dll_output_dir}/snmp/mibs/iana"
2417 COMMAND ${CMAKE_COMMAND} -E remove_directory
2418 "${_dll_output_dir}/snmp/mibs/ietf"
2419 COMMAND ${CMAKE_COMMAND} -E remove_directory
2420 "${_dll_output_dir}/snmp/mibs/site"
2421 COMMAND ${CMAKE_COMMAND} -E remove_directory
2422 "${_dll_output_dir}/snmp/mibs/tubs"
2426 list (APPEND THIRD_PARTY_DLLS "${SNAPPY_DLL_DIR}/${SNAPPY_DLL}")
2428 if (WINSPARKLE_FOUND)
2429 list (APPEND THIRD_PARTY_DLLS "${WINSPARKLE_DLL_DIR}/${WINSPARKLE_DLL}")
2430 endif(WINSPARKLE_FOUND)
2432 list (APPEND THIRD_PARTY_DLLS "${ZLIB_DLL_DIR}/${ZLIB_DLL}")
2433 list (APPEND THIRD_PARTY_PDBS "${ZLIB_DLL_DIR}/${ZLIB_PDB}")
2436 list (APPEND THIRD_PARTY_DLLS "${ZLIBNG_DLL_DIR}/${ZLIBNG_DLL}")
2437 list (APPEND THIRD_PARTY_PDBS "${ZLIBNG_DLL_DIR}/${ZLIBNG_PDB}")
2440 foreach( _dll ${BROTLI_DLLS} )
2441 list (APPEND THIRD_PARTY_DLLS "${BROTLI_DLL_DIR}/${_dll}")
2445 list (APPEND THIRD_PARTY_DLLS "${SPEEXDSP_DLL_DIR}/${SPEEXDSP_DLL}")
2448 list (APPEND THIRD_PARTY_DLLS "${ZSTD_DLL_DIR}/${ZSTD_DLL}")
2451 # With libs downloaded to c:/wireshark-x64-libs this currently
2452 # (early 2018) expands to about 1900 characters.
2453 if (THIRD_PARTY_DLLS)
2454 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
2455 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2457 "${_dll_output_dir}"
2460 install(FILES ${THIRD_PARTY_DLLS} DESTINATION "${CMAKE_INSTALL_BINDIR}")
2461 endif(THIRD_PARTY_DLLS)
2463 if (THIRD_PARTY_PDBS)
2464 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
2465 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2467 "${_dll_output_dir}"
2470 endif(THIRD_PARTY_PDBS)
2472 add_dependencies(epan copy_cli_dlls)
2474 # We have a lot of choices for creating zip archives:
2475 # - 7z, WinZip, etc., which require a separate download+install.
2476 # - "CMake -E tar cz", which creates a tar file.
2477 # - CPack, which requires a CPack configuration.
2478 # - PowerShell via PSCX or System.IO.Compression.FileSystem.
2479 # - Python via zipfile.
2480 # For now, just look for 7z. It's installed on the Windows builders,
2481 # which might be the only systems that use this target.
2482 find_program(ZIP_EXECUTABLE 7z
2483 PATH "$ENV{PROGRAMFILES}/7-Zip" "$ENV{PROGRAMW6432}/7-Zip"
2484 DOC "Path to the 7z utility."
2487 add_custom_target(pdb_zip_package COMMENT "This packages .PDBs but will not create them.")
2488 set_target_properties(pdb_zip_package PROPERTIES FOLDER "Packaging")
2489 set(_pdb_zip "${CMAKE_BINARY_DIR}/Wireshark-pdb-${PROJECT_VERSION}-${WIRESHARK_TARGET_PLATFORM}.zip")
2490 file(TO_NATIVE_PATH "${_pdb_zip}" _pdb_zip_win)
2491 add_custom_command(TARGET pdb_zip_package POST_BUILD
2492 COMMAND ${CMAKE_COMMAND} -E remove -f "${_pdb_zip}"
2493 COMMAND ${ZIP_EXECUTABLE} a -tzip -mmt=on "${_pdb_zip_win}"
2496 WORKING_DIRECTORY "${_dll_output_dir}"
2501 # List of extra dependencies for the "copy_data_files" target
2502 set(copy_data_files_depends)
2505 foreach(_install_as_txt_file COPYING README.md)
2506 # On Windows, install some files with a .txt extension so that they're
2508 string(REGEX REPLACE ".md$" "" _no_md_file ${_install_as_txt_file})
2509 set(_output_file "${DATAFILE_DIR}/${_no_md_file}.txt")
2510 add_custom_command(OUTPUT ${_output_file}
2511 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2512 ${CMAKE_SOURCE_DIR}/${_install_as_txt_file}
2515 ${CMAKE_SOURCE_DIR}/${_install_as_txt_file}
2517 list(APPEND copy_data_files_depends "${_output_file}")
2521 foreach(_install_file ${INSTALL_FILES} ${DOC_FILES})
2522 get_filename_component(_install_file_src "${_install_file}" ABSOLUTE)
2523 get_filename_component(_install_basename "${_install_file}" NAME)
2524 set(_output_file "${DATAFILE_DIR}/${_install_basename}")
2525 add_custom_command(OUTPUT "${_output_file}"
2526 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2527 "${_install_file_src}"
2533 list(APPEND copy_data_files_depends "${_output_file}")
2536 if (BUILD_stratoshark)
2537 if (ENABLE_APPLICATION_BUNDLE)
2538 foreach(_install_file ${LOG_INSTALL_FILES} ${DOC_FILES})
2539 get_filename_component(_install_file_src "${_install_file}" ABSOLUTE)
2540 get_filename_component(_install_basename "${_install_file}" NAME)
2541 set(_output_file "${LOG_DATAFILE_DIR}/${_install_basename}")
2542 add_custom_command(OUTPUT "${_output_file}"
2543 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2544 "${_install_file_src}"
2550 list(APPEND copy_data_files_depends "${_output_file}")
2553 # XXX The default profile (colorfilters, dfilters) is at the
2554 # top-level resources directory for both Wireshark and Stratoshark.
2558 set(_protocol_data_dir ${CMAKE_SOURCE_DIR}/resources/protocols)
2559 # Glob patterns relative to the source directory that should be copied to
2560 # ${DATAFILE_DIR} (including directory prefixes)
2561 # TODO shouldn't this use full (relative) paths instead of glob patterns?
2563 ${_protocol_data_dir}/tpncp/tpncp.dat
2564 ${_protocol_data_dir}/wimaxasncp/*.dtd
2565 ${_protocol_data_dir}/wimaxasncp/*.xml
2568 # Copy all paths from the source tree to the data directory. Directories are
2569 # automatically created if missing as the filename is given.
2570 file(GLOB _data_files RELATIVE ${_protocol_data_dir} ${DATA_FILES_SRC})
2571 foreach(_data_file ${_data_files})
2572 add_custom_command(OUTPUT "${DATAFILE_DIR}/${_data_file}"
2573 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2574 ${_protocol_data_dir}/${_data_file}
2575 ${DATAFILE_DIR}/${_data_file}
2577 ${_protocol_data_dir}/${_data_file}
2579 list(APPEND copy_data_files_depends ${DATAFILE_DIR}/${_data_file})
2582 file(GLOB _dtds_src_files RELATIVE ${_protocol_data_dir} ${_protocol_data_dir}/dtds/*.dtd)
2584 set (_dtds_data_files)
2585 set (_dtds_dep_files)
2586 foreach(_data_file ${_dtds_src_files})
2587 list(APPEND _dtds_data_files ${DATAFILE_DIR}/${_data_file})
2588 list(APPEND _dtds_dep_files ${_protocol_data_dir}/${_data_file})
2592 OUTPUT ${_dtds_data_files}
2593 COMMAND ${CMAKE_COMMAND} -E make_directory ${DATAFILE_DIR}/dtds
2594 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2596 ${DATAFILE_DIR}/dtds
2598 DEPENDS ${_dtds_dep_files}
2599 WORKING_DIRECTORY ${_protocol_data_dir}
2602 file(GLOB _diameter_src_files RELATIVE ${_protocol_data_dir}
2603 ${_protocol_data_dir}/diameter/*.dtd
2604 ${_protocol_data_dir}/diameter/*.xml
2607 set (_diameter_data_files)
2608 set (_diameter_dep_files)
2609 foreach(_data_file ${_diameter_src_files})
2610 list(APPEND _diameter_data_files ${DATAFILE_DIR}/${_data_file})
2611 list(APPEND _diameter_dep_files ${_protocol_data_dir}/${_data_file})
2615 OUTPUT ${_diameter_data_files}
2616 COMMAND ${CMAKE_COMMAND} -E make_directory ${DATAFILE_DIR}/diameter
2617 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2618 ${_diameter_src_files}
2619 ${DATAFILE_DIR}/diameter
2621 DEPENDS ${_diameter_dep_files}
2622 WORKING_DIRECTORY ${_protocol_data_dir}
2625 file(GLOB _radius_src_files RELATIVE ${_protocol_data_dir}
2627 ${_protocol_data_dir}/radius/README.radius_dictionary
2628 ${_protocol_data_dir}/radius/custom.includes
2629 ${_protocol_data_dir}/radius/dictionary
2630 ${_protocol_data_dir}/radius/dictionary.*
2633 set (_radius_data_files)
2634 set (_radius_dep_files)
2635 foreach(_data_file ${_radius_src_files})
2636 list(APPEND _radius_data_files ${DATAFILE_DIR}/${_data_file})
2637 list(APPEND _radius_dep_files ${_protocol_data_dir}/${_data_file})
2641 OUTPUT ${_radius_data_files}
2642 COMMAND ${CMAKE_COMMAND} -E make_directory ${DATAFILE_DIR}/radius
2643 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2644 ${_radius_src_files}
2645 ${DATAFILE_DIR}/radius
2647 DEPENDS ${_radius_dep_files}
2648 WORKING_DIRECTORY ${_protocol_data_dir}
2651 file(GLOB _protobuf_src_files RELATIVE ${_protocol_data_dir}
2652 ${_protocol_data_dir}/protobuf/*.proto
2654 set (_protobuf_data_files)
2655 set (_protobuf_dep_files)
2656 foreach(_data_file ${_protobuf_src_files})
2657 list(APPEND _protobuf_data_files ${DATAFILE_DIR}/${_data_file})
2658 list(APPEND _protobuf_dep_files ${_protocol_data_dir}/${_data_file})
2662 OUTPUT ${_protobuf_data_files}
2663 COMMAND ${CMAKE_COMMAND} -E make_directory ${DATAFILE_DIR}/protobuf
2664 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2665 ${_protobuf_src_files}
2666 ${DATAFILE_DIR}/protobuf
2668 DEPENDS ${_protobuf_dep_files}
2669 WORKING_DIRECTORY ${_protocol_data_dir}
2672 set(_profiles_src_dir ${CMAKE_SOURCE_DIR}/resources/share/wireshark)
2673 file(GLOB _profiles_src_files RELATIVE ${_profiles_src_dir} ${_profiles_src_dir}/profiles/*/*)
2674 set (_profiles_data_files)
2675 foreach(_data_file ${_profiles_src_files})
2676 list(APPEND _profiles_data_files "${DATAFILE_DIR}/${_data_file}")
2680 OUTPUT ${_profiles_data_files}
2681 COMMAND ${CMAKE_COMMAND} -E copy_directory
2682 "${CMAKE_SOURCE_DIR}/resources/share/wireshark/profiles" "${DATAFILE_DIR}/profiles"
2685 set (_log_profiles_data_files)
2686 if (BUILD_stratoshark AND ENABLE_APPLICATION_BUNDLE)
2687 set(_profiles_src_dir ${CMAKE_SOURCE_DIR}/resources/share/stratoshark)
2688 file(GLOB _profiles_src_files RELATIVE ${_profiles_src_dir} ${_profiles_src_dir}/profiles/*/*)
2689 foreach(_data_file ${_profiles_src_files})
2690 list(APPEND _log_profiles_data_files "${LOG_DATAFILE_DIR}/${_data_file}")
2694 OUTPUT ${_log_profiles_data_files}
2695 COMMAND ${CMAKE_COMMAND} -E copy_directory
2696 "${CMAKE_SOURCE_DIR}/resources/share/stratoshark/profiles" "${LOG_DATAFILE_DIR}/profiles"
2700 list(APPEND copy_data_files_depends
2702 ${_diameter_data_files}
2703 ${_radius_data_files}
2704 ${_protobuf_data_files}
2705 ${_profiles_data_files}
2706 ${_log_profiles_data_files}
2709 # Copy files including ${INSTALL_FILES} and ${INSTALL_DIRS} to ${DATAFILE_DIR}
2710 add_custom_target(copy_data_files ALL DEPENDS ${copy_data_files_depends} )
2711 set_target_properties(copy_data_files PROPERTIES FOLDER "Copy Tasks")
2713 # sources common for wireshark, tshark, rawshark and sharkd
2714 add_library(shark_common OBJECT
2717 file_packet_provider.c
2720 add_library(cli_main OBJECT cli_main.c)
2722 if(BUILD_wireshark AND QT_FOUND)
2730 $<TARGET_OBJECTS:shark_common>
2732 ${PLATFORM_UI_RC_FILES}
2734 set_executable_resources(wireshark "Wireshark" UNIQUE_RC)
2737 if(BUILD_stratoshark AND QT_FOUND)
2744 set(stratoshark_FILES
2745 $<TARGET_OBJECTS:shark_common>
2747 ${PLATFORM_UI_RC_FILES}
2749 set_executable_resources(stratoshark "Stratoshark" UNIQUE_RC)
2752 if(ENABLE_APPLICATION_BUNDLE)
2754 # Add -Wl,-single_module to the LDFLAGS used with shared
2755 # libraries, to fix some error that show up in some cases;
2756 # some Apple documentation recommends it for most shared
2759 set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-single_module ${CMAKE_SHARED_LINKER_FLAGS}" )
2761 # Add -Wl,-headerpad_max_install_names to the LDFLAGS, as
2762 # code-signing issues is running out of padding space.
2764 # Add -Wl,-search_paths_first to make sure that if we search
2765 # directories A and B, in that order, for a given library, a
2766 # non-shared version in directory A, rather than a shared
2767 # version in directory B, is chosen (so we can use
2768 # --with-pcap=/usr/local to force all programs to be linked
2769 # with a static version installed in /usr/local/lib rather than
2770 # the system version in /usr/lib).
2773 set(CMAKE_EXE_LINKER_FLAGS
2774 "-Wl,-headerpad_max_install_names -Wl,-search_paths_first ${CMAKE_EXE_LINKER_FLAGS}"
2777 # Add files to the Wireshark application bundle
2778 # Wireshark.app/Contents
2779 file(WRITE ${CMAKE_BINARY_DIR}/packaging/macosx/wireshark/PkgInfo "APPLWshk\n")
2780 set(WIRESHARK_BUNDLE_CONTENTS_FILES
2781 ${CMAKE_BINARY_DIR}/packaging/macosx/wireshark/PkgInfo
2783 set_source_files_properties(${WIRESHARK_BUNDLE_CONTENTS_FILES} PROPERTIES
2784 MACOSX_PACKAGE_LOCATION .
2787 # Wireshark.app/Contents/Resources
2788 set(WIRESHARK_BUNDLE_RESOURCE_FILES
2789 ${CMAKE_SOURCE_DIR}/packaging/macosx/Wireshark.icns
2790 ${CMAKE_SOURCE_DIR}/packaging/macosx/Wiresharkdoc.icns
2792 set_source_files_properties(${WIRESHARK_BUNDLE_RESOURCE_FILES} PROPERTIES
2793 MACOSX_PACKAGE_LOCATION Resources
2796 # Wireshark.app/Contents/Resources/share/man/man1
2797 set_source_files_properties(${WIRESHARK_BUNDLE_RESOURCE_SHARE_MAN1_FILES} PROPERTIES
2798 MACOSX_PACKAGE_LOCATION Resources/share/man/man1
2802 # Wireshark.app/Contents/Resources/share/man/man4
2803 set_source_files_properties(${WIRESHARK_BUNDLE_RESOURCE_SHARE_MAN4_FILES} PROPERTIES
2804 MACOSX_PACKAGE_LOCATION Resources/share/man/man4
2808 # INSTALL_FILES and INSTALL_DIRS are handled by copy_data_files
2810 set(EXTRA_WIRESHARK_BUNDLE_FILES
2811 ${WIRESHARK_BUNDLE_CONTENTS_FILES}
2812 ${WIRESHARK_BUNDLE_RESOURCE_FILES}
2813 ${WIRESHARK_BUNDLE_RESOURCE_SHARE_MAN1_FILES}
2814 ${WIRESHARK_BUNDLE_RESOURCE_SHARE_MAN4_FILES}
2817 # Add files to the Stratoshark application bundle
2818 # Stratoshark.app/Contents
2819 file(WRITE ${CMAKE_BINARY_DIR}/packaging/macosx/stratoshark/PkgInfo "APPLLgry\n")
2820 set(STRATOSHARK_BUNDLE_CONTENTS_FILES
2821 ${CMAKE_BINARY_DIR}/packaging/macosx/stratoshark/PkgInfo
2823 set_source_files_properties(${STRATOSHARK_BUNDLE_CONTENTS_FILES} PROPERTIES
2824 MACOSX_PACKAGE_LOCATION .
2827 # Stratoshark.app/Contents/Resources
2828 set(STRATOSHARK_BUNDLE_RESOURCE_FILES
2829 ${CMAKE_SOURCE_DIR}/packaging/macosx/Stratoshark.icns
2830 ${CMAKE_SOURCE_DIR}/packaging/macosx/Wiresharkdoc.icns
2832 set_source_files_properties(${STRATOSHARK_BUNDLE_RESOURCE_FILES} PROPERTIES
2833 MACOSX_PACKAGE_LOCATION Resources
2836 # Stratoshark.app/Contents/Resources/share/man/man1
2837 set_source_files_properties(${STRATOSHARK_BUNDLE_RESOURCE_SHARE_MAN1_FILES} PROPERTIES
2838 MACOSX_PACKAGE_LOCATION Resources/share/man/man1
2842 # Stratoshark.app/Contents/Resources/share/man/man4
2843 set_source_files_properties(${STRATOSHARK_BUNDLE_RESOURCE_SHARE_MAN4_FILES} PROPERTIES
2844 MACOSX_PACKAGE_LOCATION Resources/share/man/man4
2848 # INSTALL_FILES and INSTALL_DIRS are handled by copy_data_files
2850 set(EXTRA_STRATOSHARK_BUNDLE_FILES
2851 ${STRATOSHARK_BUNDLE_CONTENTS_FILES}
2852 ${STRATOSHARK_BUNDLE_RESOURCE_FILES}
2853 ${STRATOSHARK_BUNDLE_RESOURCE_SHARE_MAN1_FILES}
2854 ${STRATOSHARK_BUNDLE_RESOURCE_SHARE_MAN4_FILES}
2858 set(EXTRA_WIRESHARK_BUNDLE_FILES)
2859 set(EXTRA_STRATOSHARK_BUNDLE_FILES)
2862 if(BUILD_wireshark AND QT_FOUND)
2873 ${APPLE_APPLICATION_SERVICES_LIBRARY}
2874 ${APPLE_APPKIT_LIBRARY}
2875 ${APPLE_CORE_FOUNDATION_LIBRARY}
2876 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
2877 ${SPARKLE_LIBRARIES}
2878 ${WIN_WS2_32_LIBRARY}
2879 ${WIN_VERSION_LIBRARY}
2880 ${WINSPARKLE_LIBRARIES}
2881 $<$<BOOL:${WIN32}>:uxtheme.lib>
2882 ${SPEEXDSP_LIBRARIES}
2885 ${MINIZIP_LIBRARIES}
2886 ${MINIZIPNG_LIBRARIES}
2889 add_executable(wireshark WIN32 MACOSX_BUNDLE ${wireshark_FILES} ${EXTRA_WIRESHARK_BUNDLE_FILES})
2891 set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT wireshark)
2893 set(PROGLIST ${PROGLIST} wireshark)
2894 set_target_properties(wireshark PROPERTIES
2895 LINK_FLAGS "${WS_LINK_FLAGS}"
2896 FOLDER "Executables"
2897 INSTALL_RPATH "${EXECUTABLE_INSTALL_RPATH}"
2903 set_target_properties(wireshark PROPERTIES LINK_FLAGS_DEBUG "${WS_MSVC_DEBUG_LINK_FLAGS}")
2906 set_target_properties(wireshark PROPERTIES OUTPUT_NAME wireshark)
2907 elseif(ENABLE_APPLICATION_BUNDLE OR WIN32)
2908 set_target_properties(wireshark PROPERTIES OUTPUT_NAME Wireshark)
2911 if(ENABLE_APPLICATION_BUNDLE)
2912 if(ASCIIDOCTOR_FOUND)
2913 # Make sure to generate files referenced by
2914 # WIRESHARK_BUNDLE_RESOURCE_SHARE_MAN1_FILES
2915 add_dependencies(wireshark manpages)
2917 set_target_properties(
2918 wireshark PROPERTIES
2919 MACOSX_BUNDLE_INFO_PLIST ${CMAKE_BINARY_DIR}/packaging/macosx/WiresharkInfo.plist
2921 if(CMAKE_CFG_INTDIR STREQUAL ".")
2922 # Add a wrapper script which opens the bundle. This is more convenient
2923 # and lets Sparkle find our CFBundleIdentifier, but means that you have
2924 # to pass the full path to run/Wireshark.app/Contents/MacOS/Wireshark
2926 # It is not created if using Xcode
2927 file(REMOVE ${CMAKE_BINARY_DIR}/run/wireshark)
2928 file(WRITE ${CMAKE_BINARY_DIR}/run/wireshark "#!/bin/sh\n")
2929 file(APPEND ${CMAKE_BINARY_DIR}/run/wireshark "# Generated by ${CMAKE_CURRENT_LIST_FILE}\n")
2930 file(APPEND ${CMAKE_BINARY_DIR}/run/wireshark "# Wrapper script which ensures that we're properly activated via Launch Services\n")
2931 file(APPEND ${CMAKE_BINARY_DIR}/run/wireshark "exec \"${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/MacOS/Wireshark\" \"\$\@\"\n")
2932 execute_process(COMMAND chmod a+x ${CMAKE_BINARY_DIR}/run/wireshark)
2936 target_link_libraries(wireshark ${wireshark_LIBS})
2937 target_include_directories(wireshark SYSTEM PRIVATE ${SPARKLE_INCLUDE_DIRS})
2941 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
2942 BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
2945 if(QT_WINDEPLOYQT_EXECUTABLE)
2946 add_custom_target(copy_qt_dlls ALL)
2947 set_target_properties(copy_qt_dlls PROPERTIES FOLDER "Copy Tasks")
2948 # Will we ever need to use --debug? Windeployqt seems to
2949 # be smart enough to copy debug DLLs when needed.
2950 if (USE_MSYSTEM AND Qt${qtver}Widgets_VERSION VERSION_EQUAL 6.5.0)
2951 # windeployqt released with Qt 6.5.0 is broken.
2952 # https://bugreports.qt.io/browse/QTBUG-112204
2953 message(WARNING "Qt Deploy Tool 6.5.0 is broken, please upgrade to a later version.")
2954 # lconvert will fail
2956 add_custom_command(TARGET copy_qt_dlls
2958 COMMAND set "PATH=${QT_BIN_PATH};%PATH%"
2959 COMMAND "${QT_WINDEPLOYQT_EXECUTABLE}"
2960 ${QT_WINDEPLOYQT_EXTRA_ARGS}
2961 --no-compiler-runtime
2963 $<$<BOOL:${MSVC}>:--pdb>
2964 "$<TARGET_FILE:wireshark>"
2966 add_dependencies(copy_qt_dlls wireshark)
2968 install(CODE "execute_process(COMMAND
2969 \"${QT_WINDEPLOYQT_EXECUTABLE}\"
2970 --no-compiler-runtime
2971 \"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/Wireshark.exe\")"
2974 endif(QT_WINDEPLOYQT_EXECUTABLE)
2977 if(BUILD_stratoshark AND QT_FOUND)
2978 set(stratoshark_LIBS
2988 ${APPLE_APPLICATION_SERVICES_LIBRARY}
2989 ${APPLE_APPKIT_LIBRARY}
2990 ${APPLE_CORE_FOUNDATION_LIBRARY}
2991 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
2992 ${SPARKLE_LIBRARIES}
2993 ${WIN_WS2_32_LIBRARY}
2994 ${WIN_VERSION_LIBRARY}
2995 ${WINSPARKLE_LIBRARIES}
2996 $<$<BOOL:${WIN32}>:uxtheme.lib>
2997 ${SPEEXDSP_LIBRARIES}
3000 ${MINIZIP_LIBRARIES}
3001 ${MINIZIPNG_LIBRARIES}
3004 add_executable(stratoshark WIN32 MACOSX_BUNDLE ${stratoshark_FILES} ${EXTRA_STRATOSHARK_BUNDLE_FILES})
3005 if(WIN32 AND NOT BUILD_wireshark)
3006 set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT stratoshark)
3008 set(PROGLIST ${PROGLIST} stratoshark)
3009 set_target_properties(stratoshark PROPERTIES
3010 LINK_FLAGS "${WS_LINK_FLAGS}"
3011 FOLDER "Executables"
3012 INSTALL_RPATH "${EXECUTABLE_INSTALL_RPATH}"
3018 set_target_properties(stratoshark PROPERTIES LINK_FLAGS_DEBUG "${WS_MSVC_DEBUG_LINK_FLAGS}")
3020 if(ENABLE_APPLICATION_BUNDLE OR WIN32)
3021 set_target_properties(stratoshark PROPERTIES OUTPUT_NAME Stratoshark)
3024 if(ENABLE_APPLICATION_BUNDLE)
3025 if(ASCIIDOCTOR_FOUND)
3026 # Make sure to generate files referenced by
3027 # STRATOSHARK_BUNDLE_RESOURCE_SHARE_MAN1_FILES
3028 add_dependencies(stratoshark manpages)
3030 set_target_properties(
3031 stratoshark PROPERTIES
3032 MACOSX_BUNDLE_INFO_PLIST ${CMAKE_BINARY_DIR}/packaging/macosx/StratosharkInfo.plist
3034 if(CMAKE_CFG_INTDIR STREQUAL ".")
3035 # Add a wrapper script which opens the bundle. This is more convenient
3036 # and lets Sparkle find our CFBundleIdentifier, but means that you have
3037 # to pass the full path to run/Wireshark.app/Contents/MacOS/Stratoshark
3039 # It is not created if using Xcode
3040 file(REMOVE ${CMAKE_BINARY_DIR}/run/stratoshark)
3041 file(WRITE ${CMAKE_BINARY_DIR}/run/stratoshark "#!/bin/sh\n")
3042 file(APPEND ${CMAKE_BINARY_DIR}/run/stratoshark "# Generated by ${CMAKE_CURRENT_LIST_FILE}\n")
3043 file(APPEND ${CMAKE_BINARY_DIR}/run/stratoshark "# Wrapper script which ensures that we're properly activated via Launch Services\n")
3044 file(APPEND ${CMAKE_BINARY_DIR}/run/stratoshark "exec \"${CMAKE_BINARY_DIR}/run/Stratoshark.app/Contents/MacOS/Stratoshark\" \"\$\@\"\n")
3045 execute_process(COMMAND chmod a+x ${CMAKE_BINARY_DIR}/run/stratoshark)
3049 target_link_libraries(stratoshark ${stratoshark_LIBS})
3050 target_include_directories(stratoshark SYSTEM PRIVATE ${SPARKLE_INCLUDE_DIRS})
3054 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
3055 BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
3058 # The build can fail if the copy_stratoshark_qt_dlls target is run at
3059 # the same time as the copy_qt_dlls target, so just assume that
3060 # copy_qt_dlls will provide everything we need for now.
3061 if(QT_WINDEPLOYQT_EXECUTABLE AND NOT BUILD_wireshark)
3062 add_custom_target(copy_stratoshark_qt_dlls ALL)
3063 set_target_properties(copy_stratoshark_qt_dlls PROPERTIES FOLDER "Copy Tasks")
3064 # Will we ever need to use --debug? Windeployqt seems to
3065 # be smart enough to copy debug DLLs when needed.
3066 add_custom_command(TARGET copy_stratoshark_qt_dlls
3068 COMMAND set "PATH=${QT_BIN_PATH};%PATH%"
3069 COMMAND "${QT_WINDEPLOYQT_EXECUTABLE}"
3070 --no-compiler-runtime
3072 $<$<BOOL:${MSVC}>:--pdb>
3073 "$<TARGET_FILE:stratoshark>"
3075 add_dependencies(copy_stratoshark_qt_dlls stratoshark)
3077 install(CODE "execute_process(COMMAND
3078 \"${QT_WINDEPLOYQT_EXECUTABLE}\"
3079 --no-compiler-runtime
3080 \"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/Stratoshark.exe\")"
3083 endif(QT_WINDEPLOYQT_EXECUTABLE AND NOT BUILD_wireshark)
3086 if (BUILD_stratoshark AND FALCO_PLUGINS)
3087 add_custom_target(copy_falco_plugins)
3088 add_custom_command(TARGET copy_falco_plugins
3089 # XXX Falco plugins should probably be installed in a path that reflects
3090 # the Falco version or its plugin API version.
3091 COMMAND ${CMAKE_COMMAND} -E make_directory ${STRATOSHARK_PLUGIN_DIR}/../falco
3092 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FALCO_PLUGINS} ${STRATOSHARK_PLUGIN_DIR}/../falco
3095 add_dependencies(stratoshark copy_falco_plugins)
3098 # Common properties for CLI executables
3099 macro(set_extra_executable_properties _executable _folder)
3100 set_target_properties(${_executable} PROPERTIES
3101 LINK_FLAGS "${WILDCARD_OBJ} ${WS_LINK_FLAGS}"
3103 INSTALL_RPATH "${EXECUTABLE_INSTALL_RPATH}"
3106 set_target_properties(${_executable} PROPERTIES LINK_FLAGS_DEBUG "${WS_MSVC_DEBUG_LINK_FLAGS}")
3109 set(PROGLIST ${PROGLIST} ${_executable})
3111 if(ENABLE_APPLICATION_BUNDLE)
3112 if(NOT CMAKE_CFG_INTDIR STREQUAL ".")
3114 set_target_properties(${_executable} PROPERTIES
3115 RUNTIME_OUTPUT_DIRECTORY run/$<CONFIG>/Wireshark.app/Contents/MacOS
3118 set_target_properties(${_executable} PROPERTIES
3119 RUNTIME_OUTPUT_DIRECTORY run/Wireshark.app/Contents/MacOS
3121 # Create a convenience link from run/<name> to its respective
3122 # target in the application bundle.
3123 add_custom_target(${_executable}-symlink
3125 Wireshark.app/Contents/MacOS/${_executable}
3126 ${CMAKE_BINARY_DIR}/run/${_executable}
3128 add_dependencies(${_executable} ${_executable}-symlink)
3133 macro(executable_link_mingw_unicode _target)
3134 # target_link_options() requires CMake >= 3.13
3136 target_link_options(${_target} PRIVATE "-municode")
3140 register_tap_files(tshark-tap-register.c
3153 ${APPLE_CORE_FOUNDATION_LIBRARY}
3154 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
3155 ${WIN_WS2_32_LIBRARY}
3158 $<TARGET_OBJECTS:cli_main>
3159 $<TARGET_OBJECTS:shark_common>
3160 tshark-tap-register.c
3166 set_executable_resources(tshark "TShark" UNIQUE_RC)
3167 add_executable(tshark ${tshark_FILES})
3168 set_extra_executable_properties(tshark "Executables")
3169 target_link_libraries(tshark ${tshark_LIBS})
3170 executable_link_mingw_unicode(tshark)
3171 install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3180 ${APPLE_CORE_FOUNDATION_LIBRARY}
3181 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
3184 $<TARGET_OBJECTS:cli_main>
3185 $<TARGET_OBJECTS:shark_common>
3189 set_executable_resources(tfshark "TFShark")
3190 add_executable(tfshark ${tfshark_FILES})
3191 set_extra_executable_properties(tfshark "Executables")
3192 target_link_libraries(tfshark ${tfshark_LIBS})
3193 install(TARGETS tfshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3196 if(BUILD_rawshark AND PCAP_FOUND)
3202 ${APPLE_CORE_FOUNDATION_LIBRARY}
3203 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
3204 ${WIN_WS2_32_LIBRARY}
3207 $<TARGET_OBJECTS:cli_main>
3208 $<TARGET_OBJECTS:shark_common>
3211 set_executable_resources(rawshark "Rawshark")
3212 add_executable(rawshark ${rawshark_FILES})
3213 set_extra_executable_properties(rawshark "Executables")
3214 target_link_libraries(rawshark ${rawshark_LIBS})
3215 executable_link_mingw_unicode(rawshark)
3216 install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3224 ${APPLE_CORE_FOUNDATION_LIBRARY}
3225 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
3226 ${WIN_WS2_32_LIBRARY}
3227 ${SPEEXDSP_LIBRARIES}
3232 # XXX - currently doesn't work on Windows if it uses
3233 # $<TARGET_OBJECTS:cli_main> and has real_main().
3235 $<TARGET_OBJECTS:shark_common>
3236 ui/cli/simple_dialog.c
3242 set_executable_resources(sharkd "SharkD")
3243 add_executable(sharkd ${sharkd_FILES})
3244 set_extra_executable_properties(sharkd "Executables")
3245 target_link_libraries(sharkd ${sharkd_LIBS})
3246 target_include_directories(sharkd SYSTEM PUBLIC ${SPEEXDSP_INCLUDE_DIRS})
3248 install(TARGETS sharkd RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3260 set_executable_resources(dftest "Dftest")
3261 add_executable(dftest ${dftest_FILES})
3262 set_extra_executable_properties(dftest "Tests")
3263 target_link_libraries(dftest ${dftest_LIBS})
3265 install(TARGETS dftest RUNTIME
3266 DESTINATION ${CMAKE_INSTALL_BINDIR}
3267 COMPONENT "Development"
3280 $<TARGET_OBJECTS:cli_main>
3283 set_executable_resources(randpkt "Randpkt"
3284 COPYRIGHT_INFO "Copyright (C) 1999 by Gilbert Ramirez <gram@alumni.rice.edu>")
3285 add_executable(randpkt ${randpkt_FILES})
3286 set_extra_executable_properties(randpkt "Executables")
3287 target_link_libraries(randpkt ${randpkt_LIBS})
3288 executable_link_mingw_unicode(randpkt)
3289 install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3292 if(BUILD_fuzzshark OR ENABLE_FUZZER OR OSS_FUZZ)
3293 add_subdirectory(fuzz)
3306 $<TARGET_OBJECTS:cli_main>
3309 set_executable_resources(text2pcap "Text2pcap"
3310 COPYRIGHT_INFO "2001 Ashok Narayanan <ashokn@cisco.com>")
3311 add_executable(text2pcap ${text2pcap_FILES})
3312 set_extra_executable_properties(text2pcap "Executables")
3313 target_link_libraries(text2pcap ${text2pcap_LIBS})
3314 executable_link_mingw_unicode(text2pcap)
3315 install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3327 $<TARGET_OBJECTS:cli_main>
3330 set_executable_resources(mergecap "Mergecap")
3331 add_executable(mergecap ${mergecap_FILES})
3332 set_extra_executable_properties(mergecap "Executables")
3333 target_link_libraries(mergecap ${mergecap_LIBS})
3334 executable_link_mingw_unicode(mergecap)
3335 install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3338 if(BUILD_reordercap)
3346 set(reordercap_FILES
3347 $<TARGET_OBJECTS:cli_main>
3350 set_executable_resources(reordercap "Reordercap")
3351 add_executable(reordercap ${reordercap_FILES})
3352 set_extra_executable_properties(reordercap "Executables")
3353 target_link_libraries(reordercap ${reordercap_LIBS})
3354 executable_link_mingw_unicode(reordercap)
3355 install(TARGETS reordercap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3369 $<TARGET_OBJECTS:cli_main>
3372 set_executable_resources(capinfos "Capinfos")
3373 add_executable(capinfos ${capinfos_FILES})
3374 set_extra_executable_properties(capinfos "Executables")
3375 target_link_libraries(capinfos ${capinfos_LIBS})
3376 target_include_directories(capinfos SYSTEM PRIVATE ${GCRYPT_INCLUDE_DIRS})
3377 executable_link_mingw_unicode(capinfos)
3378 install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3391 $<TARGET_OBJECTS:cli_main>
3394 set_executable_resources(captype "Captype")
3395 add_executable(captype ${captype_FILES})
3396 set_extra_executable_properties(captype "Executables")
3397 target_link_libraries(captype ${captype_LIBS})
3398 executable_link_mingw_unicode(captype)
3399 install(TARGETS captype RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3412 $<TARGET_OBJECTS:cli_main>
3415 set_executable_resources(editcap "Editcap")
3416 add_executable(editcap ${editcap_FILES})
3417 set_extra_executable_properties(editcap "Executables")
3418 target_link_libraries(editcap ${editcap_LIBS})
3419 target_include_directories(editcap SYSTEM PRIVATE ${GCRYPT_INCLUDE_DIRS})
3420 executable_link_mingw_unicode(editcap)
3421 install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3424 if(BUILD_dumpcap AND PCAP_FOUND)
3433 ${APPLE_CORE_FOUNDATION_LIBRARY}
3434 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
3435 ${WIN_WS2_32_LIBRARY}
3438 list(APPEND CAPUTILS_SRC
3439 capture/capture-pcap-util-unix.c)
3442 list(APPEND CAPUTILS_SRC
3443 capture/capture_win_ifnames.c
3444 capture/capture-wpcap.c
3447 list(APPEND CAPUTILS_SRC
3448 capture/capture-pcap-util.c
3451 # We don't link with libiface_monitor or libui because those
3452 # are built to be linked against libwsutil as a shared library,
3453 # and dumpcap is deliberately not linked against any of
3454 # Wireshark's shared libraries, to reduce the amount of code
3455 # it uses, and linking against the non-shared libiface_monitor
3456 # or libui libraries will fail on Windows.
3458 # Instead, we just include source files for the relevant code
3459 # to be built as part of dumpcap, so that they're built with
3460 # ENABLE_STATIC defined, and will be able to be built with
3461 # the static version of libwsutil.
3468 capture/iface_monitor.c
3469 capture/ws80211_utils.c
3473 set_executable_resources(dumpcap "Dumpcap" UNIQUE_RC)
3474 add_executable(dumpcap ${dumpcap_FILES})
3475 set_extra_executable_properties(dumpcap "Executables")
3476 target_link_libraries(dumpcap ${dumpcap_LIBS})
3477 target_include_directories(dumpcap SYSTEM PRIVATE ${ZLIB_INCLUDE_DIRS} ${ZLIBNG_INCLUDE_DIRS} ${NL_INCLUDE_DIRS})
3478 target_compile_definitions(dumpcap PRIVATE ENABLE_STATIC)
3479 executable_link_mingw_unicode(dumpcap)
3480 install(TARGETS dumpcap
3481 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
3482 PERMISSIONS ${DUMPCAP_SETUID}
3483 OWNER_READ OWNER_WRITE OWNER_EXECUTE
3484 GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
3486 if(ENABLE_DUMPCAP_GROUP)
3487 install(CODE "execute_process(COMMAND chgrp ${DUMPCAP_INSTALL_GROUP} ${CMAKE_INSTALL_FULL_BINDIR}/dumpcap)")
3488 install(CODE "execute_process(COMMAND chmod o-x ${CMAKE_INSTALL_FULL_BINDIR}/dumpcap)")
3490 if(DUMPCAP_INSTALL_OPTION STREQUAL "capabilities")
3491 install( CODE "execute_process(
3493 ${SETCAP_EXECUTABLE}
3494 cap_net_raw,cap_net_admin+ep
3495 ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/dumpcap${CMAKE_EXECUTABLE_SUFFIX}
3499 if( _SETCAP_RESULT )
3500 message( WARNING \"setcap failed (${_SETCAP_RESULT}).\")
3504 if(BUILD_stratoshark AND ENABLE_APPLICATION_BUNDLE)
3505 add_custom_command(TARGET dumpcap POST_BUILD
3506 COMMAND ${CMAKE_COMMAND} -E copy_if_different
3507 $<TARGET_FILE:dumpcap> run/Stratoshark.app/Contents/MacOS/dumpcap
3510 elseif(BUILD_dumpcap AND ENABLE_PCAP)
3511 message(WARNING "Dumpcap was requested but libpcap dependency is not available. "
3512 "Wireshark will be built without packet capture capability.")
3515 # We have two idl2wrs utilities: this and the CORBA version in tools.
3516 # We probably shouldn't do that.
3517 if(BUILD_dcerpcidl2wrs)
3522 epan/dissectors/dcerpc/idl2wrs.c
3525 add_executable(idl2wrs ${idl2wrs_FILES})
3526 set_target_properties(idl2wrs PROPERTIES FOLDER "Executables")
3527 set_extra_executable_properties(idl2wrs "Executables")
3528 target_link_libraries(idl2wrs ${idl2wrs_LIBS})
3529 install(TARGETS idl2wrs RUNTIME
3530 DESTINATION ${CMAKE_INSTALL_BINDIR}
3531 COMPONENT "Development"
3537 find_package( MSVC_REDIST )
3539 # Must come after executable targets are defined.
3540 find_package( NSIS )
3542 if(MAKENSIS_EXECUTABLE)
3543 add_subdirectory( packaging/nsis EXCLUDE_FROM_ALL )
3544 ADD_NSIS_PACKAGE_TARGETS()
3549 if(WIX_CANDLE_EXECUTABLE)
3550 add_subdirectory( packaging/wix EXCLUDE_FROM_ALL )
3551 ADD_WIX_PACKAGE_TARGET()
3554 find_package( PortableApps )
3555 if(PORTABLEAPPS_LAUNCHER_GENERATOR_EXECUTABLE AND PORTABLEAPPS_INSTALLER_EXECUTABLE)
3556 add_subdirectory( packaging/portableapps EXCLUDE_FROM_ALL )
3557 ADD_PORTABLEAPPS_PACKAGE_TARGET()
3561 if (MAXMINDDB_FOUND)
3562 set(mmdbresolve_LIBS
3563 # Note: libmaxminddb is not GPL-2 compatible.
3564 ${MAXMINDDB_LIBRARY}
3565 # Needed for CMake-built libmaxminddb.lib <= 1.43.
3566 ${WIN_WS2_32_LIBRARY}
3568 set(mmdbresolve_FILES
3571 set_executable_resources(mmdbresolve "Mmdbresolve")
3572 add_executable(mmdbresolve ${mmdbresolve_FILES})
3573 set_extra_executable_properties(mmdbresolve "Executables")
3574 target_link_libraries(mmdbresolve ${mmdbresolve_LIBS})
3575 target_include_directories(mmdbresolve PUBLIC ${MAXMINDDB_INCLUDE_DIRS})
3576 target_compile_definitions(mmdbresolve PUBLIC ${MAXMINDDB_DEFINITIONS})
3577 install(TARGETS mmdbresolve RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3580 if(ENABLE_APPLICATION_BUNDLE AND BUILD_wireshark)
3581 file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}/Wireshark.app/Contents/Resources/Extras")
3583 # --preserve-xattr is undocumented but ensures that we install
3584 # a signed ChmodBPF script.
3585 set (_chmodbpf_version 1.2)
3586 set (install_chmodbpf_component_pkg "${CMAKE_BINARY_DIR}/install.ChmodBPF.pkg")
3587 add_custom_command(OUTPUT "${install_chmodbpf_component_pkg}"
3589 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/root"
3591 -exec chmod 755 "{}" +
3593 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/root/Library/LaunchDaemons/org.wireshark.ChmodBPF.plist"
3595 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/root/Library/Application Support/Wireshark/ChmodBPF/ChmodBPF"
3596 COMMAND "${CMAKE_SOURCE_DIR}/packaging/macosx/osx-extras.sh"
3598 --identifier org.wireshark.ChmodBPF.pkg
3599 --version ${_chmodbpf_version}
3601 --root "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/root"
3602 --scripts "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/install-scripts"
3603 ${install_chmodbpf_component_pkg}
3605 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/root/Library/Application Support/Wireshark/ChmodBPF/ChmodBPF"
3606 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/root/Library/LaunchDaemons/org.wireshark.ChmodBPF.plist"
3607 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/install-scripts/postinstall"
3609 set (install_chmodbpf_pkg "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/Extras/Install ChmodBPF.pkg")
3610 add_custom_command(OUTPUT "${install_chmodbpf_pkg}"
3611 COMMAND productbuild
3612 --identifier org.wireshark.install.ChmodBPF.product
3613 --version ${_chmodbpf_version}
3614 --distribution "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/install-distribution.xml"
3615 --package-path "${CMAKE_BINARY_DIR}"
3616 ${install_chmodbpf_pkg}
3618 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/install-distribution.xml"
3619 ${install_chmodbpf_component_pkg}
3622 set (uninstall_chmodbpf_component_pkg "${CMAKE_BINARY_DIR}/uninstall.ChmodBPF.pkg")
3623 add_custom_command(OUTPUT "${uninstall_chmodbpf_component_pkg}"
3625 --identifier org.wireshark.uninstall.ChmodBPF.pkg
3626 --version ${_chmodbpf_version}
3628 --scripts "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/uninstall-scripts"
3629 ${uninstall_chmodbpf_component_pkg}
3631 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/uninstall-scripts/postinstall"
3633 set (uninstall_chmodbpf_pkg "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/Extras/Uninstall ChmodBPF.pkg")
3634 add_custom_command(OUTPUT "${uninstall_chmodbpf_pkg}"
3635 COMMAND productbuild
3636 --identifier org.wireshark.uninstall.ChmodBPF.product
3637 --version ${_chmodbpf_version}
3638 --distribution "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/uninstall-distribution.xml"
3639 --package-path "${CMAKE_BINARY_DIR}"
3640 ${uninstall_chmodbpf_pkg}
3642 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/uninstall-distribution.xml"
3643 ${uninstall_chmodbpf_component_pkg}
3646 add_custom_target(chmodbpf DEPENDS ${install_chmodbpf_pkg} ${uninstall_chmodbpf_pkg})
3648 set (_path_helper_version 1.1)
3649 set (install_path_helper_component_pkg "${CMAKE_BINARY_DIR}/install.path_helper.pkg")
3650 add_custom_command(OUTPUT "${install_path_helper_component_pkg}"
3652 "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/root"
3654 -exec chmod 755 "{}" +
3656 "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/root"
3658 -exec chmod 644 "{}" +
3660 --identifier org.wireshark.path_helper.pkg
3661 --version ${_path_helper_version}
3662 --root "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/root/etc"
3663 --install-location /private/etc
3664 ${install_path_helper_component_pkg}
3666 "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/root/etc/paths.d/Wireshark"
3667 "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/root/etc/manpaths.d/Wireshark"
3669 set (install_path_helper_pkg "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/Extras/Add Wireshark to the system path.pkg")
3670 add_custom_command(OUTPUT "${install_path_helper_pkg}"
3671 COMMAND productbuild
3672 --identifier org.wireshark.install.path_helper.product
3673 --version ${_path_helper_version}
3674 --distribution "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/install-distribution.xml"
3675 --package-path "${CMAKE_BINARY_DIR}"
3676 ${install_path_helper_pkg}
3678 "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/install-distribution.xml"
3679 ${install_path_helper_component_pkg}
3682 set (uninstall_path_helper_component_pkg "${CMAKE_BINARY_DIR}/uninstall.path_helper.pkg")
3683 add_custom_command(OUTPUT "${uninstall_path_helper_component_pkg}"
3685 --identifier org.wireshark.uninstall.path_helper.pkg
3686 --version ${_path_helper_version}
3688 --scripts "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/uninstall-scripts"
3689 ${uninstall_path_helper_component_pkg}
3691 "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/uninstall-scripts/postinstall"
3693 set (uninstall_path_helper_pkg "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/Extras/Remove Wireshark from the system path.pkg")
3694 add_custom_command(OUTPUT "${uninstall_path_helper_pkg}"
3695 COMMAND productbuild
3696 --identifier org.wireshark.uninstall.path_helper.product
3697 --version ${_path_helper_version}
3698 --distribution "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/uninstall-distribution.xml"
3699 --package-path "${CMAKE_BINARY_DIR}"
3700 ${uninstall_path_helper_pkg}
3702 ${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/uninstall-distribution.xml
3703 ${uninstall_path_helper_component_pkg}
3706 add_custom_target(path_helper DEPENDS ${install_path_helper_pkg} ${uninstall_path_helper_pkg})
3708 add_custom_target(wireshark_app_bundle)
3709 set_target_properties(wireshark_app_bundle PROPERTIES FOLDER "Copy Tasks")
3710 add_custom_command(TARGET wireshark_app_bundle
3712 COMMAND "${CMAKE_BINARY_DIR}/packaging/macosx/osx-app.sh"
3713 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/run"
3715 add_dependencies(wireshark_app_bundle ${PROGLIST} chmodbpf path_helper)
3717 add_custom_target(wireshark_dmg_prep DEPENDS wireshark_app_bundle)
3719 set(_wireshark_read_me_first "packaging/macosx/wireshark/Read me first.html")
3722 ${_wireshark_read_me_first}
3723 COMMAND ${ASCIIDOCTOR_EXECUTABLE}
3725 --out-file ${_wireshark_read_me_first}
3726 --attribute include-dir=${CMAKE_SOURCE_DIR}/doc
3727 --attribute min-macos-version=${MIN_MACOS_VERSION}
3728 ${CMAKE_CURRENT_SOURCE_DIR}/packaging/macosx/Wireshark_read_me_first.adoc
3730 ${CMAKE_CURRENT_SOURCE_DIR}/packaging/macosx/Wireshark_read_me_first.adoc
3733 set(_wireshark_donate "packaging/macosx/wireshark/Donate to the Wireshark Foundation.html")
3736 ${_wireshark_donate}
3737 COMMAND ${ASCIIDOCTOR_EXECUTABLE}
3739 --out-file ${_wireshark_donate}
3740 --attribute include-dir=${CMAKE_SOURCE_DIR}/doc
3741 --attribute min-macos-version=${MIN_MACOS_VERSION}
3742 ${CMAKE_CURRENT_SOURCE_DIR}/packaging/macosx/Donate_to_the_Wireshark_Foundation.adoc
3744 ${CMAKE_CURRENT_SOURCE_DIR}/packaging/macosx/Donate_to_the_Wireshark_Foundation.adoc
3747 set(_wireshark_dsym_installation "packaging/macosx/wireshark/Debugging symbols installation.html")
3750 ${_wireshark_dsym_installation}
3751 COMMAND ${ASCIIDOCTOR_EXECUTABLE}
3753 --out-file ${_wireshark_dsym_installation}
3754 --attribute include-dir=${CMAKE_SOURCE_DIR}/doc
3755 ${CMAKE_CURRENT_SOURCE_DIR}/packaging/macosx/Wireshark_dsym_installation.adoc
3757 ${CMAKE_CURRENT_SOURCE_DIR}/packaging/macosx/Wireshark_dsym_installation.adoc
3760 add_custom_target(wireshark_dmg_readmes DEPENDS ${_wireshark_read_me_first} ${_wireshark_donate} ${_wireshark_dsym_installation} )
3761 add_dependencies(wireshark_dmg_prep wireshark_dmg_readmes)
3763 ADD_CUSTOM_TARGET( wireshark_dmg
3764 COMMAND bash -x ${CMAKE_BINARY_DIR}/packaging/macosx/osx-dmg.sh
3765 # Unlike wireshark_nsis_prep + wireshark_nsis, we can add a direct
3767 DEPENDS wireshark_dmg_prep
3768 # We create Wireshark.app in "run". Do our work there.
3769 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/run
3774 if(ENABLE_APPLICATION_BUNDLE AND BUILD_stratoshark)
3775 add_custom_target(stratoshark_app_bundle)
3776 set_target_properties(stratoshark_app_bundle PROPERTIES FOLDER "Copy Tasks")
3777 add_custom_command(TARGET stratoshark_app_bundle
3779 COMMAND "${CMAKE_BINARY_DIR}/packaging/macosx/osx-app.sh" --bundle Stratoshark.app
3780 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/run"
3783 add_custom_target(stratoshark_dmg_prep DEPENDS stratoshark_app_bundle)
3785 set(_stratoshark_read_me_first "packaging/macosx/stratoshark/Read me first.html")
3788 ${_stratoshark_read_me_first}
3789 COMMAND ${ASCIIDOCTOR_EXECUTABLE}
3791 --out-file ${_stratoshark_read_me_first}
3792 --attribute include-dir=${CMAKE_SOURCE_DIR}/doc
3793 --attribute min-macos-version=${MIN_MACOS_VERSION}
3794 ${CMAKE_CURRENT_SOURCE_DIR}/packaging/macosx/Stratoshark_read_me_first.adoc
3796 ${CMAKE_CURRENT_SOURCE_DIR}/packaging/macosx/Stratoshark_read_me_first.adoc
3799 set(_stratoshark_dsym_installation "packaging/macosx/stratoshark/Debugging symbols installation.html")
3802 ${_stratoshark_dsym_installation}
3803 COMMAND ${ASCIIDOCTOR_EXECUTABLE}
3805 --out-file ${_stratoshark_dsym_installation}
3806 --attribute include-dir=${CMAKE_SOURCE_DIR}/doc
3807 ${CMAKE_CURRENT_SOURCE_DIR}/packaging/macosx/Stratoshark_dsym_installation.adoc
3809 ${CMAKE_CURRENT_SOURCE_DIR}/packaging/macosx/Stratoshark_dsym_installation.adoc
3812 add_custom_target(stratoshark_dmg_readmes DEPENDS ${_stratoshark_read_me_first} ${_stratoshark_dsym_installation} )
3813 add_dependencies(stratoshark_dmg_prep stratoshark_dmg_readmes)
3815 ADD_CUSTOM_TARGET( stratoshark_dmg
3816 COMMAND bash -x ${CMAKE_BINARY_DIR}/packaging/macosx/osx-dmg.sh --app-name Stratoshark
3817 # Unlike wireshark_nsis_prep + wireshark_nsis, we can add a direct
3819 DEPENDS stratoshark_dmg_prep
3820 # We create Wireshark.app in "run". Do our work there.
3821 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/run
3826 if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
3827 find_program(RPMBUILD_EXECUTABLE rpmbuild)
3828 find_program(GIT_EXECUTABLE git)
3829 # Should we add appimaged's monitored directories
3831 # https://github.com/AppImage/appimaged
3832 find_program(LINUXDEPLOY_EXECUTABLE NAMES linuxdeploy-x86_64.AppImage linuxdeploy)
3833 find_program(_linuxdeploy_plugin_qt NAMES linuxdeploy-plugin-qt-x86_64.AppImage linuxdeploy-plugin-qt)
3834 find_program(APPIMAGETOOL_EXECUTABLE NAMES appimagetool-x86_64.AppImage
3839 string(REPLACE "-" "_" RPM_VERSION "${PROJECT_VERSION}")
3840 configure_file(packaging/rpm/wireshark.spec.in ${CMAKE_BINARY_DIR}/packaging/rpm/SPECS/wireshark.spec)
3841 if(RPMBUILD_EXECUTABLE)
3842 foreach(_rpm_dir BUILD RPMS SOURCES SPECS SRPMS)
3843 file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/packaging/rpm/${_rpm_dir}")
3846 set(_rpmbuild_with_args)
3850 # At least some versions of rpmbuild define the cmake_build
3851 # macro to run "cmake --build" with the "--verbose" option,
3852 # with no obvious way to easily override that, so, if you
3853 # are doing a build with lots of source files, and with
3854 # lots of compiler options (for example, a log of -W flags),
3855 # you can get a lot of output from rpmbuild.
3857 # Wireshark is a program with lots of source files and
3858 # lots of compiler options.
3860 # GitLab's shared builders have a limit of 4MB on logs
3863 # Wireshark uses the shared builders, and can produce
3864 # more than 4MB with the Fedora RPM build; this causes
3865 # the builds to fail.
3867 # Forcibly overriding the cmake_build macro with a
3868 # version that lacks the --version file should
3869 # prevent ninja from being run with the -v flag,
3870 # so that it prints the compact output rather
3871 # than the raw command.
3873 # We don't do that by default; if the build has the
3874 # FORCE_CMAKE_NINJA_QUIET environment variable set,
3877 if(DEFINED ENV{FORCE_CMAKE_NINJA_NON_VERBOSE})
3879 # Get the output of a pipeline running
3880 # "rpmbuild --showrc", to find the settings
3881 # of all macros, piped to an awk script
3882 # to extract the value of the cmake_build
3886 COMMAND rpmbuild --showrc
3887 COMMAND awk "/: cmake_build/ { getline; print \$0; exit }"
3888 OUTPUT_VARIABLE CMAKE_BUILD_VALUE
3889 OUTPUT_STRIP_TRAILING_WHITESPACE)
3890 if (CMAKE_BUILD_VALUE MATCHES ".*--verbose.*")
3892 # OK, the setting contains "--verbose".
3895 string(REPLACE "--verbose" ""
3896 NON_VERBOSE_CMAKE_BUILD_VALUE
3897 ${CMAKE_BUILD_VALUE})
3898 list(APPEND _rpmbuild_with_args --define "cmake_build ${NON_VERBOSE_CMAKE_BUILD_VALUE}")
3901 if(CMAKE_VERBOSE_MAKEFILE)
3902 list(APPEND _rpmbuild_with_args -v)
3905 if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
3906 list(APPEND _rpmbuild_with_args --with toolchain_clang)
3908 if(CMAKE_GENERATOR STREQUAL "Ninja")
3909 list(APPEND _rpmbuild_with_args --with ninja)
3911 if(CCACHE_EXECUTABLE)
3912 list(APPEND _rpmbuild_with_args --with ccache)
3914 if(NOT BUILD_wireshark)
3915 list(APPEND _rpmbuild_with_args --without qt5 --without qt6)
3917 list(APPEND _rpmbuild_with_args --without qt5 --with qt6)
3919 list(APPEND _rpmbuild_with_args --with qt5 --without qt6)
3921 if (MAXMINDDB_FOUND)
3922 list(APPEND _rpmbuild_with_args --with mmdbresolve)
3925 list(APPEND _rpmbuild_with_args --with lua)
3927 if (LZ4_FOUND AND SNAPPY_FOUND)
3928 list(APPEND _rpmbuild_with_args --with lz4_and_snappy)
3931 list(APPEND _rpmbuild_with_args --with spandsp)
3934 list(APPEND _rpmbuild_with_args --with bcg729)
3937 list(APPEND _rpmbuild_with_args --with amrnb)
3940 list(APPEND _rpmbuild_with_args --with ilbc)
3943 list(APPEND _rpmbuild_with_args --with opus)
3946 list(APPEND _rpmbuild_with_args --with libxml2)
3949 list(APPEND _rpmbuild_with_args --with nghttp2)
3952 list(APPEND _rpmbuild_with_args --with nghttp3)
3955 list(APPEND _rpmbuild_with_args --with sdjournal)
3958 list(APPEND _rpmbuild_with_args --with brotli)
3960 if(ASCIIDOCTOR_FOUND AND XSLTPROC_EXECUTABLE)
3961 list(APPEND _rpmbuild_with_args --with guides)
3965 COMMAND ${Python3_EXECUTABLE}
3966 ${CMAKE_SOURCE_DIR}/tools/make-version.py
3970 add_custom_target(copy-dist
3971 COMMAND cp ${CMAKE_BINARY_DIR}/wireshark*tar* ${CMAKE_BINARY_DIR}/packaging/rpm/SOURCES/
3974 add_custom_target(wireshark_rpm
3975 COMMAND ${RPMBUILD_EXECUTABLE}
3976 --define "_topdir ${CMAKE_BINARY_DIR}/packaging/rpm"
3977 --define "_prefix ${CMAKE_INSTALL_PREFIX}"
3978 ${_rpmbuild_with_args}
3979 -ba SPECS/wireshark.spec
3981 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/packaging/rpm"
3982 COMMENT "Create a rpm from the current git commit."
3986 if(BUILD_wireshark AND QT_FOUND AND LINUXDEPLOY_EXECUTABLE AND _linuxdeploy_plugin_qt AND APPIMAGETOOL_EXECUTABLE)
3987 configure_file(packaging/appimage/Wireshark-AppRun.in ${CMAKE_BINARY_DIR}/packaging/appimage/Wireshark-AppRun @ONLY)
3988 # Require production builds (/usr + Release).
3989 if (CMAKE_BUILD_TYPE STREQUAL "Release" AND CMAKE_INSTALL_PREFIX STREQUAL "/usr" )
3990 add_custom_target(wireshark_appimage_prerequisites)
3991 add_dependencies(wireshark_appimage_prerequisites ${PROGLIST})
3993 add_custom_target(wireshark_appimage_prerequisites
3994 COMMAND echo "CMAKE_BUILD_TYPE isn't Release or CMAKE_INSTALL_PREFIX isn't /usr."
3998 set (_wireshark_ai_appdir ${CMAKE_BINARY_DIR}/packaging/appimage/wireshark.appdir)
3999 add_custom_target(wireshark_appimage_appdir
4000 COMMAND ${CMAKE_COMMAND} -E make_directory ${_wireshark_ai_appdir}
4001 COMMAND env DESTDIR=${_wireshark_ai_appdir}
4002 ${CMAKE_COMMAND} --build . --target install
4003 DEPENDS wireshark_appimage_prerequisites
4005 set(_wireshark_appimage_exe_args)
4006 foreach(_prog ${PROGLIST})
4007 # XXX This needs to be more robust.
4008 if (${_prog} STREQUAL "dftest" OR ${_prog} STREQUAL "stratoshark")
4011 list(APPEND _wireshark_appimage_exe_args --executable=${_wireshark_ai_appdir}/usr/bin/${_prog})
4013 # It looks like linuxdeploy can't handle executables in nonstandard
4014 # locations, so use it to prep our staging directory here and use
4015 # appimagetool to to build the appimage.
4016 add_custom_target(wireshark_appimage_prep
4017 COMMAND env LD_LIBRARY_PATH=${_wireshark_ai_appdir}/${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} ${LINUXDEPLOY_EXECUTABLE}
4018 --appdir=${_wireshark_ai_appdir}
4019 ${_wireshark_appimage_exe_args}
4020 --desktop-file=${_wireshark_ai_appdir}/usr/share/applications/org.wireshark.Wireshark.desktop
4021 --icon-file=${CMAKE_SOURCE_DIR}/resources/icons/wsicon256.png
4022 --custom-apprun=${CMAKE_BINARY_DIR}/packaging/appimage/Wireshark-AppRun
4024 DEPENDS wireshark_appimage_appdir
4026 add_custom_target(wireshark_appimage
4027 COMMAND env VERSION=${PROJECT_VERSION} ${APPIMAGETOOL_EXECUTABLE} ${_wireshark_ai_appdir}
4028 DEPENDS wireshark_appimage_prep
4032 if(BUILD_stratoshark AND QT_FOUND AND LINUXDEPLOY_EXECUTABLE AND _linuxdeploy_plugin_qt AND APPIMAGETOOL_EXECUTABLE)
4033 configure_file(packaging/appimage/Stratoshark-AppRun.in ${CMAKE_BINARY_DIR}/packaging/appimage/Stratoshark-AppRun @ONLY)
4034 # Require production builds (/usr + Release).
4035 if (CMAKE_BUILD_TYPE STREQUAL "Release" AND CMAKE_INSTALL_PREFIX STREQUAL "/usr" )
4036 add_custom_target(stratoshark_appimage_prerequisites)
4037 add_dependencies(stratoshark_appimage_prerequisites ${PROGLIST})
4039 add_custom_target(stratoshark_appimage_prerequisites
4040 COMMAND echo "CMAKE_BUILD_TYPE isn't Release or CMAKE_INSTALL_PREFIX isn't /usr."
4044 set (_stratoshark_ai_appdir ${CMAKE_BINARY_DIR}/packaging/appimage/stratoshark.appdir)
4045 add_custom_target(stratoshark_appimage_appdir
4046 COMMAND ${CMAKE_COMMAND} -E make_directory ${_stratoshark_ai_appdir}
4047 COMMAND env DESTDIR=${_stratoshark_ai_appdir}
4048 ${CMAKE_COMMAND} --build . --target install
4049 DEPENDS stratoshark_appimage_prerequisites
4051 set(_stratoshark_appimage_exe_args)
4052 foreach(_prog ${PROGLIST})
4053 # XXX This needs to be more robust.
4054 if (${_prog} STREQUAL "dftest" OR ${_prog} STREQUAL "stratoshark")
4057 list(APPEND _stratoshark_appimage_exe_args --executable=${_stratoshark_ai_appdir}/usr/bin/${_prog})
4059 # It looks like linuxdeploy can't handle executables in nonstandard
4060 # locations, so use it to prep our staging directory here and use
4061 # appimagetool to to build the appimage.
4062 add_custom_target(stratoshark_appimage_prep
4063 COMMAND env LD_LIBRARY_PATH=${_stratoshark_ai_appdir}/${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} ${LINUXDEPLOY_EXECUTABLE}
4064 --appdir=${_stratoshark_ai_appdir}
4065 ${_stratoshark_appimage_exe_args}
4066 --desktop-file=${_stratoshark_ai_appdir}/usr/share/applications/org.wireshark.Stratoshark.desktop
4067 --icon-file=${CMAKE_SOURCE_DIR}/resources/icons/ssicon256.png
4068 --custom-apprun=${CMAKE_BINARY_DIR}/packaging/appimage/Stratoshark-AppRun
4070 DEPENDS stratoshark_appimage_appdir
4072 add_custom_target(stratoshark_appimage
4073 COMMAND env VERSION=${LOG_PROJECT_VERSION} ${APPIMAGETOOL_EXECUTABLE} ${_stratoshark_ai_appdir}
4074 DEPENDS stratoshark_appimage_prep
4081 ${stratoshark_FILES}
4087 ${randpktdump_FILES}
4097 ${mmdbresolve_FILES}
4102 # Make sure we don't pass /WX to rc.exe. Rc doesn't have a /WX flag,
4103 # but it does have /W (warn about invalid code pages) and /X (ignore
4104 # the INCLUDE environment variable).
4105 # This should apparently be handled for us via CMAKE_RC_FLAG_REGEX
4106 # in CMakeRCInformation.cmake but that doesn't appear to work.
4108 list(FILTER CLEAN_C_FILES EXCLUDE REGEX ".*\\.rc")
4111 # XXX This also contains object files ($<TARGET_OBJECTS:...>), is that an issue?
4112 set_source_files_properties(
4115 COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
4123 OWNER_WRITE OWNER_READ
4127 ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}
4130 if (BUILD_stratoshark)
4133 ${LOG_INSTALL_FILES}
4135 OWNER_WRITE OWNER_READ
4139 ${CMAKE_INSTALL_DATADIR}/${LOG_PROJECT_NAME}
4147 ${CMAKE_INSTALL_DOCDIR}
4150 if(ASCIIDOCTOR_FOUND AND XSLTPROC_EXECUTABLE)
4152 DIRECTORY "${CMAKE_BINARY_DIR}/doc/wsug_html_chunked"
4153 DESTINATION "${CMAKE_INSTALL_DOCDIR}"
4154 COMPONENT "UserGuide"
4158 DIRECTORY "${CMAKE_BINARY_DIR}/doc/wsdg_html_chunked"
4159 DESTINATION "${CMAKE_INSTALL_DOCDIR}"
4160 COMPONENT "DeveloperGuide"
4165 set(SHARK_PUBLIC_HEADERS
4169 include/ws_attributes.h
4170 include/ws_codepoints.h
4171 include/ws_compiler_tests.h
4172 include/ws_diag_control.h
4173 include/ws_exit_codes.h
4174 include/ws_log_defs.h
4175 include/ws_posix_compat.h
4176 include/ws_symbol_export.h
4178 ${CMAKE_BINARY_DIR}/ws_version.h
4181 install(FILES ${SHARK_PUBLIC_HEADERS}
4182 DESTINATION ${PROJECT_INSTALL_INCLUDEDIR}
4183 COMPONENT "Development"
4187 # Install icons and other desktop files for Freedesktop.org-compliant desktops.
4188 if(BUILD_wireshark AND QT_FOUND AND NOT APPLE AND (NOT WIN32 OR USE_MSYSTEM))
4189 install(FILES resources/freedesktop/org.wireshark.Wireshark-mime.xml
4190 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/mime/packages"
4191 RENAME org.wireshark.Wireshark.xml
4193 install(FILES resources/freedesktop/org.wireshark.Wireshark.metainfo.xml
4194 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo"
4196 if(BUILD_wireshark AND QT_FOUND)
4197 install(FILES resources/freedesktop/org.wireshark.Wireshark.desktop
4198 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
4200 foreach(size 16 24 32 48 64 128 256)
4201 install(FILES resources/icons/wsicon${size}.png
4202 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${size}x${size}/apps"
4203 RENAME org.wireshark.Wireshark.png)
4204 install(FILES resources/icons/WiresharkDoc-${size}.png
4205 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${size}x${size}/mimetypes"
4206 RENAME org.wireshark.Wireshark-mimetype.png)
4210 if(BUILD_stratoshark AND QT_FOUND AND NOT APPLE AND (NOT WIN32 OR USE_MSYSTEM))
4211 install(FILES resources/freedesktop/org.wireshark.Stratoshark-mime.xml
4212 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/mime/packages"
4213 RENAME org.wireshark.Stratoshark.xml
4215 install(FILES resources/freedesktop/org.wireshark.Stratoshark.metainfo.xml
4216 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo"
4218 if(BUILD_wireshark AND QT_FOUND)
4219 install(FILES resources/freedesktop/org.wireshark.Stratoshark.desktop
4220 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
4222 foreach(size 16 32 48 64 128 256)
4223 install(FILES resources/icons/ssicon${size}.png
4224 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${size}x${size}/apps"
4225 RENAME org.wireshark.Stratoshark.png)
4226 install(FILES resources/icons/WiresharkDoc-${size}.png
4227 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${size}x${size}/mimetypes"
4228 RENAME org.wireshark.Stratoshark-mimetype.png)
4230 install(FILES resources/icons/ssicon.svg
4231 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps"
4232 RENAME org.wireshark.Stratoshark.svg)
4235 install(FILES "${CMAKE_BINARY_DIR}/resources/wireshark.pc"
4236 DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
4237 COMPONENT "Development"
4245 ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}
4247 OWNER_WRITE OWNER_READ
4250 DIRECTORY_PERMISSIONS
4251 OWNER_EXECUTE OWNER_WRITE OWNER_READ
4252 GROUP_EXECUTE GROUP_READ
4253 WORLD_EXECUTE WORLD_READ
4254 PATTERN ".git" EXCLUDE
4255 PATTERN ".svn" EXCLUDE
4256 PATTERN "Makefile.*" EXCLUDE
4259 if (BUILD_stratoshark)
4264 ${CMAKE_INSTALL_DATADIR}/${LOG_PROJECT_NAME}
4266 OWNER_WRITE OWNER_READ
4269 DIRECTORY_PERMISSIONS
4270 OWNER_EXECUTE OWNER_WRITE OWNER_READ
4271 GROUP_EXECUTE GROUP_READ
4272 WORLD_EXECUTE WORLD_READ
4273 PATTERN ".git" EXCLUDE
4274 PATTERN ".svn" EXCLUDE
4275 PATTERN "Makefile.*" EXCLUDE
4279 if(WIN32 AND NOT USE_MSYSTEM)
4280 # Note: CMake export mechanism misbehaves with a '.' in the
4281 # path (incorrect relative path computation).
4282 set(WIRESHARK_INSTALL_CMAKEDIR "cmake")
4284 set(WIRESHARK_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
4287 include(CMakePackageConfigHelpers)
4289 configure_package_config_file(WiresharkConfig.cmake.in
4290 ${CMAKE_BINARY_DIR}/WiresharkConfig.cmake
4291 INSTALL_DESTINATION ${WIRESHARK_INSTALL_CMAKEDIR}
4293 CMAKE_INSTALL_LIBDIR
4294 CMAKE_INSTALL_INCLUDEDIR
4295 PLUGIN_INSTALL_VERSION_LIBDIR
4296 EXTCAP_INSTALL_LIBDIR
4299 write_basic_package_version_file(
4300 ${CMAKE_BINARY_DIR}/WiresharkConfigVersion.cmake
4301 COMPATIBILITY AnyNewerVersion
4306 ${CMAKE_BINARY_DIR}/WiresharkConfig.cmake
4307 ${CMAKE_BINARY_DIR}/WiresharkConfigVersion.cmake
4309 ${WIRESHARK_INSTALL_CMAKEDIR}
4315 install(EXPORT WiresharkTargets
4316 DESTINATION ${WIRESHARK_INSTALL_CMAKEDIR}
4317 COMPONENT "Development"
4321 # This isn't strictly needed but it makes working around debhelper's
4322 # cleverness a lot easier.
4323 add_custom_target(install-headers
4324 COMMAND ${CMAKE_COMMAND} -DCOMPONENT=Development -P cmake_install.cmake
4327 if (DOXYGEN_EXECUTABLE)
4329 # We don't have a good way of tracking dependencies, so we simply
4330 # recreate the whole thing from scratch each time.
4331 add_custom_target(wsar_html
4332 COMMAND ${CMAKE_COMMAND} -E remove_directory wsar_html
4333 COMMAND ${DOXYGEN_EXECUTABLE} doxygen.cfg
4336 if(WIN32 AND NOT USE_MSYSTEM)
4337 add_custom_target(wsar_html_perms DEPENDS wsar_html)
4339 add_custom_target(wsar_html_perms
4340 COMMAND find wsar_html
4342 -exec chmod 755 "{}" +
4343 COMMAND find wsar_html
4345 -exec chmod 644 "{}" +
4349 add_custom_target(wsar_html_zip
4350 COMMAND ${CMAKE_COMMAND} -E tar "cfv" "wsar_html.zip" --format=zip wsar_html
4351 DEPENDS wsar_html_perms
4353 set_target_properties(wsar_html wsar_html_zip PROPERTIES
4354 FOLDER "Documentation"
4355 EXCLUDE_FROM_DEFAULT_BUILD True
4357 endif(DOXYGEN_EXECUTABLE)
4359 add_custom_target(test-programs
4361 fifo_string_cache_test
4369 COMMENT "Building unit test programs and wrapper"
4371 set_target_properties(test-programs PROPERTIES
4373 EXCLUDE_FROM_DEFAULT_BUILD True
4376 # Add target to enable capturing from the build directory. Requires Linux capabilities
4377 # and running with sudo.
4378 if(TARGET dumpcap AND SETCAP_EXECUTABLE)
4379 add_custom_target(test-capture
4380 COMMAND ${SETCAP_EXECUTABLE} cap_net_raw,cap_net_admin+ep $<TARGET_FILE:dumpcap>
4384 add_custom_target(test
4385 COMMAND ${CMAKE_COMMAND} -E env PYTHONIOENCODING=UTF-8
4386 ${Python3_EXECUTABLE} -m pytest
4388 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
4389 DEPENDS test-programs
4393 # Make it possible to run pytest without passing the full path as argument.
4394 if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
4395 file(READ "${CMAKE_CURRENT_SOURCE_DIR}/pytest.ini" pytest_ini)
4396 string(REGEX REPLACE "\naddopts = ([^\n]+)"
4397 "\naddopts = ${CMAKE_CURRENT_SOURCE_DIR}/test \\1"
4398 pytest_ini "${pytest_ini}")
4399 file(WRITE "${CMAKE_BINARY_DIR}/pytest.ini" "${pytest_ini}")
4403 # Update AUTHORS file with entries from git shortlog
4406 COMMAND ${Python3_EXECUTABLE} tools/generate_authors.py AUTHORS
4407 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
4409 else (GIT_EXECUTABLE)
4410 add_custom_target( gen-authors COMMAND ${CMAKE_COMMAND} -E echo "Git not found." )
4411 endif (GIT_EXECUTABLE)
4412 set_target_properties(gen-authors PROPERTIES FOLDER "Documentation")
4414 if(WIN32 AND NOT USE_MSYSTEM)
4415 file (TO_NATIVE_PATH ${CMAKE_SOURCE_DIR}/tools/Get-HardenFlags.ps1 _win_harden_flags)
4416 add_custom_target(hardening-check
4417 COMMAND ${POWERSHELL_COMMAND} "${_win_harden_flags}" "${_dll_output_dir_win}"
4419 COMMENT "Checking binaries for security features"
4421 set_target_properties(hardening-check PROPERTIES FOLDER "Tests")
4423 find_program(HARDENING_CHECK_EXECUTABLE hardening-check
4424 DOC "Path to the hardening-check utility."
4426 if(HARDENING_CHECK_EXECUTABLE)
4427 foreach(_prog ${PROGLIST})
4428 get_target_property(_prog_dir ${_prog} RUNTIME_OUTPUT_DIRECTORY)
4430 set(_prog_dir "${CMAKE_BINARY_DIR}/run")
4432 set(_prog_paths ${_prog_paths} "${_prog_dir}/${_prog}")
4434 add_custom_target(hardening-check
4435 COMMAND ${HARDENING_CHECK_EXECUTABLE} ${_prog_paths}
4437 COMMENT "Checking binaries for security features"
4451 find_program(SHELLCHECK_EXECUTABLE shellcheck
4452 DOC "Path to the shellcheck utility."
4454 if(SHELLCHECK_EXECUTABLE)
4455 add_custom_target(shellcheck)
4456 set_target_properties(shellcheck PROPERTIES FOLDER "Tests")
4457 # --external-sources requires 0.4.0 or later.
4458 # ChmodBPF uses "shellcheck shell=bash". Not sure which version
4459 # added support for that.
4460 add_custom_command(TARGET shellcheck POST_BUILD
4461 COMMAND shellcheck --external-sources
4462 resources/stock_icons/svg-to-png.sh
4463 resources/stock_icons/layouts-to-png.sh
4464 packaging/appimage/Stratoshark-AppRun.in
4465 packaging/appimage/Wireshark-AppRun.in
4466 "packaging/macosx/ChmodBPF/root/Library/Application Support/Wireshark/ChmodBPF/ChmodBPF"
4467 packaging/macosx/osx-app.sh.in
4468 packaging/macosx/osx-dmg.sh.in
4469 packaging/source/git-export-release.sh.in
4472 tools/debian-setup.sh
4475 tools/macos-setup-brew.sh
4477 tools/randpkt-test.sh
4478 tools/release-update-debian-soversions.sh
4480 tools/test-captures.sh
4482 tools/valgrind-wireshark.sh
4483 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
4489 "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
4490 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
4493 add_custom_target(uninstall
4494 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
4496 # Break on programmer errors when debugging in Visual Studio
4498 get_property(_targets DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS)
4499 foreach(_target ${_targets})
4500 set_target_properties(${_target} PROPERTIES VS_DEBUGGER_ENVIRONMENT "G_DEBUG=fatal-criticals")
4504 # -----------------------------------------------------------------------------
4506 # -----------------------------------------------------------------------------
4507 include(ConfigCPack.cmake)
4510 # Editor modelines - https://www.wireshark.org/tools/modelines.html
4515 # indent-tabs-mode: t
4518 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
4519 # :indentSize=8:tabSize=8:noTabs=false: