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 # Needed for add_custom_command() WORKING_DIRECTORY generator expressions
19 cmake_minimum_required(VERSION 3.13)
21 cmake_policy(SET CMP0083 NEW)
25 if(DEFINED ENV{MSYSTEM})
26 set(_msystem $ENV{MSYSTEM})
27 set(_repository False)
28 message(STATUS "Using MSYS2 with MSYSTEM=${_msystem}")
32 message(STATUS "Using 3rd party repository")
34 set(USE_MSYSTEM ${_msystem} CACHE INTERNAL "Use MSYS2 subsystem")
35 set(HAVE_MSYSTEM ${USE_MSYSTEM}) # For config.h
36 set(USE_REPOSITORY ${_repository} CACHE INTERNAL "Use Wireshark 3rd Party Repository")
39 if(WIN32 AND NOT USE_MSYSTEM)
40 set(_project_name Wireshark)
41 set(_log_project_name Logray)
43 set(_project_name wireshark)
44 set(_log_project_name logray)
47 project(${_project_name} C CXX)
49 # Updated by tools/make-version.py
50 set(PROJECT_MAJOR_VERSION 4)
51 set(PROJECT_MINOR_VERSION 1)
52 set(PROJECT_PATCH_VERSION 0)
53 set(PROJECT_BUILD_VERSION 0)
54 set(PROJECT_VERSION_EXTENSION "")
56 if(DEFINED ENV{WIRESHARK_VERSION_EXTRA})
57 set(PROJECT_VERSION_EXTENSION "$ENV{WIRESHARK_VERSION_EXTRA}")
60 set(PROJECT_VERSION "${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}.${PROJECT_PATCH_VERSION}${PROJECT_VERSION_EXTENSION}")
62 set(LOG_PROJECT_NAME ${_log_project_name})
63 set(LOG_PROJECT_MAJOR_VERSION 0)
64 set(LOG_PROJECT_MINOR_VERSION 8)
65 set(LOG_PROJECT_PATCH_VERSION 3)
66 set(LOG_PROJECT_VERSION "${LOG_PROJECT_MAJOR_VERSION}.${LOG_PROJECT_MINOR_VERSION}.${LOG_PROJECT_PATCH_VERSION}${PROJECT_VERSION_EXTENSION}")
68 include( CMakeOptions.txt )
70 # We require minimum C11
71 set(CMAKE_C_STANDARD 11)
72 set(CMAKE_C_STANDARD_REQUIRED ON)
74 # We require minimum C++11
75 set(CMAKE_CXX_STANDARD 11)
76 set(CMAKE_CXX_STANDARD_REQUIRED ON)
77 set(CMAKE_CXX_EXTENSIONS OFF)
79 message(STATUS "Generating build using CMake ${CMAKE_VERSION}")
81 # Set a default build type if none was specified
82 set(_default_build_type "RelWithDebInfo")
83 if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
84 set(CMAKE_BUILD_TYPE "${_default_build_type}" CACHE STRING "Choose the type of build." FORCE)
85 # Set the possible values of build type for cmake-gui
86 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
89 # Build type is ignored by multi-config generators.
90 if (NOT CMAKE_CONFIGURATION_TYPES)
91 message(STATUS "Using \"${CMAKE_GENERATOR}\" generator and build type \"${CMAKE_BUILD_TYPE}\"")
93 message(STATUS "Using \"${CMAKE_GENERATOR}\" generator (multi-config)")
96 #Where to find local cmake scripts
97 set(WS_CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
98 set(CMAKE_MODULE_PATH ${WS_CMAKE_MODULE_PATH})
100 # CMake >= 3.9.0 supports LTO/IPO.
102 include(CheckIPOSupported)
103 check_ipo_supported(RESULT lto_supported OUTPUT lto_output)
105 set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
106 message(STATUS "LTO/IPO is enabled for Release configuration")
108 message(STATUS "LTO/IPO requested but it is not supported by the compiler: ${lto_output}")
111 message(STATUS "LTO/IPO is not enabled")
114 # If our target platform is enforced by our generator, set
115 # WIRESHARK_TARGET_PLATFORM accordingly. Otherwise use
116 # %WIRESHARK_TARGET_PLATFORM%.
118 # XXX We should probably consolidate WIRESHARK_TARGET_PLATFORM and
119 # WIRESHARK_TARGET_PROCESSOR_ARCHITECTURE and just use "x64" and "arm64"
120 # instead of "win64" and "win64arm"
123 if(DEFINED ENV{WIRESHARK_TARGET_PLATFORM})
124 string(TOLOWER $ENV{WIRESHARK_TARGET_PLATFORM} _target_platform)
125 set(WIRESHARK_TARGET_PLATFORM ${_target_platform})
126 elseif(USE_MSYSTEM MATCHES "MINGW64|CLANG64|UCRT64")
127 # https://www.msys2.org/docs/environments
128 # MSYS2 comes with different environments/subsystems and
129 # the first thing you have to decide is which one to use.
130 # The differences among the environments are mainly environment
131 # variables, default compilers/linkers, architecture,
132 # system libraries used etc. If you are unsure, go with UCRT64.
133 set(WIRESHARK_TARGET_PLATFORM win64)
135 if($ENV{MSYSTEM_CARCH} MATCHES "x86_64")
136 set(WIRESHARK_TARGET_PLATFORM win64)
137 elseif($ENV{MSYSTEM_CARCH} MATCHES "i686")
138 set(WIRESHARK_TARGET_PLATFORM win32)
139 elseif($ENV{MSYSTEM_CARCH} MATCHES "aarch64")
140 set(WIRESHARK_TARGET_PLATFORM "win64arm")
142 set(WIRESHARK_TARGET_PLATFORM "$ENV{MSYSTEM_CARCH}")
144 elseif($ENV{Platform} MATCHES arm64 OR CMAKE_GENERATOR_PLATFORM MATCHES arm64)
145 set(WIRESHARK_TARGET_PLATFORM win64arm)
146 elseif(CMAKE_CL_64 OR CMAKE_GENERATOR MATCHES Win64)
147 set(WIRESHARK_TARGET_PLATFORM win64)
149 message(WARNING "Assuming \"win64\" target platform")
150 set(WIRESHARK_TARGET_PLATFORM win64)
153 if(WIRESHARK_TARGET_PLATFORM MATCHES "win64")
154 set(WIRESHARK_TARGET_PROCESSOR_ARCHITECTURE x64)
155 elseif(WIRESHARK_TARGET_PLATFORM MATCHES "win64arm")
156 set(WIRESHARK_TARGET_PROCESSOR_ARCHITECTURE arm64)
157 elseif(WIRESHARK_TARGET_PLATFORM MATCHES "win32")
158 message(FATAL_ERROR "Deprecated target platform ${WIRESHARK_TARGET_PLATFORM}. See https://gitlab.com/wireshark/wireshark/-/issues/17779 for details.")
159 set(WIRESHARK_TARGET_PROCESSOR_ARCHITECTURE x86)
161 message(FATAL_ERROR "Invalid target platform: ${WIRESHARK_TARGET_PLATFORM}")
166 if(DEFINED ENV{PLATFORM})
167 string(TOLOWER $ENV{PLATFORM} _vs_platform)
169 set(_vs_platform "[undefined]") # x86
172 (_vs_platform STREQUAL "x64" AND NOT WIRESHARK_TARGET_PLATFORM STREQUAL "win64")
174 (_vs_platform STREQUAL "[undefined]" AND NOT WIRESHARK_TARGET_PLATFORM STREQUAL "win32")
176 message(FATAL_ERROR "The PLATFORM environment variable (${_vs_platform})"
177 " doesn't match the generator platform (${WIRESHARK_TARGET_PLATFORM})")
181 "Building for ${WIRESHARK_TARGET_PLATFORM} \
182 and CPU target ${WIRESHARK_TARGET_PROCESSOR_ARCHITECTURE}"
185 find_package(PowerShell REQUIRED)
187 # Determine where the 3rd party libraries will be
189 if( DEFINED ENV{WIRESHARK_LIB_DIR} )
190 # The buildbots set WIRESHARK_LIB_DIR but not WIRESHARK_BASE_DIR.
191 file( TO_CMAKE_PATH "$ENV{WIRESHARK_LIB_DIR}" _PROJECT_LIB_DIR )
192 elseif( DEFINED ENV{WIRESHARK_BASE_DIR} )
193 file( TO_CMAKE_PATH "$ENV{WIRESHARK_BASE_DIR}" _WS_BASE_DIR )
194 set( _PROJECT_LIB_DIR "${_WS_BASE_DIR}/wireshark-${WIRESHARK_TARGET_PLATFORM}-libs" )
196 # Don't know what to do
197 message(FATAL_ERROR "Neither WIRESHARK_BASE_DIR or WIRESHARK_LIB_DIR are defined")
200 # Download third-party libraries
201 file (TO_NATIVE_PATH ${CMAKE_SOURCE_DIR}/tools/win-setup.ps1 _win_setup)
202 file (TO_NATIVE_PATH ${_PROJECT_LIB_DIR} _ws_lib_dir)
203 file (TO_NATIVE_PATH ${CMAKE_COMMAND} _win_cmake_command)
205 # Is it possible to have a one-time, non-cached option in CMake? If
206 # so, we could add a "-DFORCE_WIN_SETUP" which passes -Force to
209 COMMAND ${POWERSHELL_COMMAND} "\"${_win_setup}\"" -Destination "${_ws_lib_dir}" -Platform ${WIRESHARK_TARGET_PLATFORM} -CMakeExecutable "\"${_win_cmake_command}\""
210 RESULT_VARIABLE _win_setup_failed
211 ERROR_VARIABLE _win_setup_error_output
213 if(_win_setup_failed)
214 message(FATAL_ERROR "Windows setup (win-setup.ps1) failed: ${_win_setup_error_output}.")
217 set(EXTRA_INSTALLER_DIR ${_ws_lib_dir})
219 # XXX Add a dependency on ${_ws_lib_dir}/current_tag.txt?
221 set(EXTRA_INSTALLER_DIR ${CMAKE_BINARY_DIR}/packaging/nsis)
225 include(UseCustomIncludes)
226 ADD_CUSTOM_CMAKE_INCLUDE()
228 # Ensure that all executables and libraries end up in the same directory. Actual
229 # files might end up in a configuration subdirectory, e.g. run/Debug or
230 # run/Release. We try to set DATAFILE_DIR to actual location below.
231 if(NOT ARCHIVE_OUTPUT_PATH)
232 set(ARCHIVE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/run CACHE INTERNAL
233 "Single output directory for building all archives.")
235 if(NOT EXECUTABLE_OUTPUT_PATH)
236 set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/run CACHE INTERNAL
237 "Single output directory for building all executables.")
239 if(NOT LIBRARY_OUTPUT_PATH)
240 set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/run CACHE INTERNAL
241 "Single output directory for building all libraries.")
245 # The release mode (CMAKE_BUILD_TYPE=release) defines NDEBUG for
246 # the Unix Makefile generator.
249 # Defines CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_DATADIR, etc ...
250 if(WIN32 AND NOT USE_MSYSTEM)
251 # Override some values on Windows, to match the existing
252 # convention of installing everything to a single root folder.
253 set(CMAKE_INSTALL_BINDIR ".")
254 set(CMAKE_INSTALL_LIBDIR ".")
255 set(CMAKE_INSTALL_INCLUDEDIR "include")
256 set(CMAKE_INSTALL_DATADIR ".")
257 set(CMAKE_INSTALL_DOCDIR ".")
259 # By default INSTALL_DATADIR is set to INSTALL_DATAROOTDIR, set the
261 set(CMAKE_INSTALL_DATADIR "share/${PROJECT_NAME}"
262 CACHE PATH "Read-only architecture-independent data"
265 include(GNUInstallDirs)
267 set(PROJECT_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}")
269 # Make sure our executables can load our libraries if we install into
270 # a non-default directory on Unix-like systems other than macOS.
271 # https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
272 set(LIBRARY_INSTALL_RPATH "")
273 set(EXECUTABLE_INSTALL_RPATH "")
274 set(EXTCAP_INSTALL_RPATH "")
275 if(NOT (WIN32 OR APPLE OR USE_STATIC))
276 # Try to set a RPATH for installed binaries if the library directory is
277 # not already included in the default search list.
278 list(FIND CMAKE_C_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_FULL_LIBDIR}" IS_SYSTEM_DIR)
279 if(IS_SYSTEM_DIR EQUAL -1)
280 # Some systems support $ORIGIN in RPATH to enable relocatable
281 # binaries. In other cases, only absolute paths can be used.
282 # https://www.lekensteyn.nl/rpath.html
284 # Also note that some systems (notably those using GNU libc)
285 # silently ignore $ORIGIN in RPATH for binaries that are
286 # setuid root or use privileged capabilities.
288 if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|SunOS|FreeBSD)$")
289 set(_enable_rpath_origin TRUE)
291 set(_enable_rpath_origin FALSE)
294 # Provide a knob to optionally force absolute rpaths,
295 # to support old/buggy systems and as a user preference
297 # XXX Should this be a CMake option?
298 set(ENABLE_RPATH_ORIGIN ${_enable_rpath_origin} CACHE BOOL
299 "Use $ORIGIN with INSTALL_RPATH")
300 mark_as_advanced(ENABLE_RPATH_ORIGIN)
302 if(ENABLE_RPATH_ORIGIN)
303 set(LIBRARY_INSTALL_RPATH "$ORIGIN")
304 set(EXECUTABLE_INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
305 set(EXTCAP_INSTALL_RPATH "$ORIGIN/../..")
307 set(LIBRARY_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
308 set(EXECUTABLE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
309 set(EXTCAP_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
311 # Include non-standard external libraries by default in RPATH.
312 if(NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH)
313 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
318 # Ensure that executables in the build directory always have the same RPATH.
319 # This ensures relocatable binaries and reproducible builds (invariant of the
320 # build directory location). (Requires CMake 3.14)
321 set(CMAKE_BUILD_RPATH_USE_ORIGIN ON)
324 # Linking with wsetargv.obj enables "wildcard expansion" of
325 # command-line arguments.
326 set(WILDCARD_OBJ wsetargv.obj)
329 include(CheckSymbolExists)
332 # Large file support on UN*X, a/k/a LFS.
334 # On Windows, we require _fseeki64() and _ftelli64(). Visual
335 # Studio has had supported them since Visual Studio 2005/MSVCR80,
336 # and we require newer versions, so we know we have them.
342 # Add the required #defines.
344 add_definitions(${LFS_DEFINITIONS})
348 # Check for fseeko as well.
355 # Add the required #defines.
357 add_definitions(${FSEEKO_DEFINITIONS})
361 # Banner shown at top right of Qt welcome screen.
362 if(DEFINED ENV{WIRESHARK_VERSION_FLAVOR})
363 set(VERSION_FLAVOR "$ENV{WIRESHARK_VERSION_FLAVOR}")
365 set(VERSION_FLAVOR "Development Build")
368 # Used in .rc files and manifests
369 set(MANIFEST_PROCESSOR_ARCHITECTURE ${WIRESHARK_TARGET_PROCESSOR_ARCHITECTURE})
370 if (MANIFEST_PROCESSOR_ARCHITECTURE MATCHES "x64")
371 set(MANIFEST_PROCESSOR_ARCHITECTURE "amd64")
373 set(RC_VERSION ${PROJECT_MAJOR_VERSION},${PROJECT_MINOR_VERSION},${PROJECT_PATCH_VERSION},${PROJECT_BUILD_VERSION})
374 set(LOG_RC_VERSION ${LOG_PROJECT_MAJOR_VERSION},${LOG_PROJECT_MINOR_VERSION},${PROJECT_PATCH_VERSION},${PROJECT_BUILD_VERSION})
376 message(STATUS "V: ${PROJECT_VERSION}, MaV: ${PROJECT_MAJOR_VERSION}, MiV: ${PROJECT_MINOR_VERSION}, PL: ${PROJECT_PATCH_VERSION}, EV: ${PROJECT_VERSION_EXTENSION}.")
378 find_package(PythonInterp)
380 include(UseMakePluginReg)
382 include(UseExecutableResources)
385 # The following snippet has been taken from
386 # https://github.com/USESystemEngineeringBV/cmake-eclipse-helper/wiki/HowToWorkaroundIndexer
387 # The eclipse indexer otherwise assumes __cplusplus=199711L which will lead to broken
388 # lookup tables for the epan libraries
389 # Check if CXX flags have been set to c++11 -> Setup Eclipse Indexer correctly!
390 # Also setup the project slightly different
391 if(CMAKE_EXTRA_GENERATOR MATCHES "Eclipse CDT4")
393 LIST(LENGTH CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS LIST_LEN)
394 if(LIST_LEN GREATER 0)
398 LIST(LENGTH CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS LIST_LEN)
399 if(LIST_LEN GREATER 0)
402 if(C_ENABLED EQUAL 1 AND CXX_ENABLED EQUAL 1)
403 # Combined project (C and CXX). This will confuse the indexer. For that reason
404 # we unsert set the __cplusplus variable for the indexer
405 list(FIND CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS "__cplusplus" GEN_MACRO_INDEX)
406 if(GEN_MACRO_INDEX GREATER -1)
407 list(REMOVE_AT CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${GEN_MACRO_INDEX})
408 list(REMOVE_AT CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${GEN_MACRO_INDEX})
410 SET(CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS} CACHE INTERNAL "")
411 elseif((CXX_ENABLED EQUAL 1) AND (CMAKE_CXX_FLAGS MATCHES ".*-std=c\\+\\+11.*"))
412 #add_definitions (-D__cplusplus=201103L)
413 # CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS
414 list(FIND CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS "199711L" GEN_MACRO_INDEX)
415 if(GEN_MACRO_INDEX GREATER -1)
416 list(REMOVE_AT CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${GEN_MACRO_INDEX})
417 list(INSERT CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${GEN_MACRO_INDEX} "201103L")
418 SET(CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS} CACHE INTERNAL "")
426 ${CMAKE_SOURCE_DIR}/include
429 if( DUMPCAP_INSTALL_OPTION STREQUAL "suid" )
430 set( DUMPCAP_SETUID "SETUID" )
432 set( DUMPCAP_SETUID )
434 if( NOT CMAKE_SYSTEM_NAME STREQUAL "Linux" AND
435 DUMPCAP_INSTALL_OPTION STREQUAL "capabilities" )
436 message( WARNING "Capabilities are only supported on Linux" )
437 set( DUMPCAP_INSTALL_OPTION )
440 set(OSS_FUZZ OFF CACHE BOOL "Whether building for oss-fuzz")
441 mark_as_advanced(OSS_FUZZ)
444 # In oss-fuzz mode, the fuzzing engine can be afl or libFuzzer.
445 message(FATAL_ERROR "Cannot force libFuzzer when using oss-fuzz")
447 # Must not depend on external dependencies so statically link all libs.
452 set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
456 # Linking can consume a lot of memory, especially when built with ASAN and
457 # static libraries (like oss-fuzz) or Debug mode. With Ninja, the number of
458 # parallel linker processes is constrained by job parallelism (-j), but this can
459 # be reduced further by setting "job pools" to a lower number.
461 if(CMAKE_MAKE_PROGRAM MATCHES "ninja" AND OSS_FUZZ)
462 # Assume oss-fuzz linker jobs do not require more than 1.2G per task
463 set(per_job_memory_mb 1200)
464 cmake_host_system_information(RESULT total_memory_mb QUERY TOTAL_PHYSICAL_MEMORY)
465 math(EXPR parallel_link_jobs "${total_memory_mb} / ${per_job_memory_mb}")
466 if(parallel_link_jobs LESS 1)
467 set(parallel_link_jobs 1)
469 set_property(GLOBAL APPEND PROPERTY JOB_POOLS link_job_pool=${parallel_link_jobs})
470 set(CMAKE_JOB_POOL_LINK link_job_pool)
471 message(STATUS "Ninja job pool size: ${parallel_link_jobs}")
474 # Always enable position-independent code when compiling, even for
475 # executables, so you can build position-independent executables.
476 # -pie is added below for non-MSVC, but requires objects to be built with
477 # -fPIC/-fPIE (so set CMAKE_POSITION_INDEPENDENT_CODE to enable that).
478 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
480 # Preprocessor definitions common to all compilers
481 set_property(DIRECTORY
482 PROPERTY COMPILE_DEFINITIONS
483 "G_DISABLE_DEPRECATED"
484 "G_DISABLE_SINGLE_INCLUDES"
485 $<$<OR:$<BOOL:${ENABLE_DEBUG}>,$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:WS_DEBUG>
486 $<$<OR:$<BOOL:${ENABLE_DEBUG_UTF_8}>,$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:WS_DEBUG_UTF_8>
491 # NOTE: Because of the way Qt moc is including "config.h" (not as the
492 # first header) this *MUST* be defined on the command line to precede
493 # every included header and not trigger symbol redefinition errors.
496 -DWIN32_LEAN_AND_MEAN
498 # Use Unicode in Windows runtime functions.
503 # NOMINMAX keeps windows.h from defining "min" and "max" via windef.h.
504 # This avoids conflicts with the C++ standard library.
513 # Enable POSIX APIs. This will switch stdio to ANSI C functions and
514 # enable C99 conformant vsnprintf() among other things.
518 list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_POSIX)
521 if( CMAKE_C_COMPILER_ID MATCHES "MSVC")
522 if (MSVC_VERSION LESS "1928")
523 message(FATAL_ERROR "Microsoft Visual Studio 2019 version 16.8 or later is required")
525 if (MSVC_VERSION GREATER_EQUAL "2000")
526 message(FATAL_ERROR "You are using an unsupported version of MSVC")
530 /D_CRT_SECURE_NO_DEPRECATE
531 # -DPSAPI_VERSION=1 Programs that must run on earlier versions of Windows as well as Windows 7 and later
532 # versions should always call this function as GetProcessMemoryInfo. To ensure correct
533 # resolution of symbols, add Psapi.lib to the TARGETLIBS macro and compile the program
534 # with -DPSAPI_VERSION=1.To use run-time dynamic linking, load Psapi.dll.
535 # https://docs.microsoft.com/en-us/windows/win32/api/psapi/nf-psapi-getprocessmemoryinfo
536 # -D_ALLOW_KEYWORD_MACROS For VS2012 onwards the, C++ STL does not permit macro redefinitions of keywords
537 # (see https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/bb531344(v=vs.110))
538 # This definition prevents the complaint about the redefinition of inline by WinPCap
539 # in pcap-stdinc.h when compiling C++ files, e.g. the Qt UI
541 /D_ALLOW_KEYWORD_MACROS
542 # Disable deprecation of POSIX function names.
543 # https://stackoverflow.com/questions/37845163/what-is-the-purpose-of-microsofts-underscore-c-functions
544 /D_CRT_NONSTDC_NO_WARNINGS
547 if(NOT WIRESHARK_TARGET_PLATFORM STREQUAL "win64")
548 add_definitions("/D_BIND_TO_CURRENT_CRT_VERSION=1")
555 set(WS_LINK_FLAGS "/LARGEADDRESSAWARE /MANIFEST:NO /INCREMENTAL:NO /RELEASE")
557 # To do: Add /external:... See https://devblogs.microsoft.com/cppblog/broken-warnings-theory/
559 # /diagnostics:caret Place a caret under compilation issues similar to
561 # /Zo Enhanced debugging of optimised code
562 # /utf-8 Set Source and Executable character sets to UTF-8
563 # VS2015(MSVC14): On by default when /Zi or /Z7 used.
564 # /guard:cf Control Flow Guard (compile and link).
565 # See https://docs.microsoft.com/en-us/windows/win32/secbp/control-flow-guard
566 # Note: This requires CMake 3.9.0 or newer.
567 # https://gitlab.kitware.com/cmake/cmake/commit/f973d49ab9d4c59b93f6dac812a94bb130200836
568 # /Qspectre Speculative execution attack mitigation
569 # See https://devblogs.microsoft.com/cppblog/spectre-mitigations-in-msvc/
570 list(APPEND LOCAL_CFLAGS /diagnostics:caret /Zo /utf-8 /guard:cf)
571 set(WS_LINK_FLAGS "${WS_LINK_FLAGS} /guard:cf")
572 # /Qspectre is not available for VS2015 or older VS2017. Test for its availability.
573 set(WIRESHARK_COMMON_FLAGS /Qspectre)
575 if(ENABLE_CODE_ANALYSIS)
576 # We should probably add a code_analysis.props file and use it to set
577 # CAExcludePath, otherwise we trigger on Qt's headers:
578 # https://stackoverflow.com/questions/59669026/how-to-add-property-to-affect-code-analysis-in-cmake
579 # https://gitlab.kitware.com/cmake/cmake/-/issues/19682
580 # For now, we set CAExcludePath=C:\Qt;%include% in the Visual Studio
581 # Code Analys builder's environment.
582 list(APPEND LOCAL_CFLAGS /analyze:WX-)
585 # Additional compiler warnings to be treated as "Level 3"
586 # when compiling Wireshark sources. (Selected from "level 4" warnings).
587 ## 4295: array is too small to include a terminating null character
588 ## 4100: unreferenced formal parameter
589 ## 4189: local variable is initialized but not referenced
590 # Disable warnings about use of flexible array members:
591 ## 4200: nonstandard extension used : zero-sized array in struct/union
592 list(APPEND LOCAL_CFLAGS /w34295 /w34100 /w34189 /wd4200)
594 # MSVC 14.28 + C11 enables C5105, but older Windows SDKs aren't completely compatible.
595 # Windows SDK 10.0.17763.0 generates syntax errors with C11 enabled.
596 if (CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION VERSION_LESS 10.0.18362.0)
597 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.")
599 # Windows SDK 10.0.18362.0 to 10.0.19041.685 generate warning C5105 with C11 enabled.
600 if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION VERSION_LESS 10.0.20348.0)
601 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.")
602 ## 5105: macro expansion producing 'defined' has undefined behavior
603 list(APPEND LOCAL_CFLAGS /wd5105)
606 # We've matched these to specific compiler versions using the
607 # checks above. There's no need to pass them to check_c_compiler_flag
608 # or check_cxx_compiler_flag, which can be slow.
609 string(REPLACE ";" " " _flags "${LOCAL_CFLAGS}")
610 set(CMAKE_C_FLAGS "${_flags} ${CMAKE_C_FLAGS}")
611 set(CMAKE_CXX_FLAGS "${_flags} ${CMAKE_CXX_FLAGS}")
615 # MIN_MACOS_VERSION is used to set LSMinimumSystemVersion
616 # in Info.plist, so start with something low.
617 set(MIN_MACOS_VERSION 10.10)
618 if(CMAKE_OSX_DEPLOYMENT_TARGET)
619 if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS MIN_MACOS_VERSION)
620 message(FATAL_ERROR "We don't support building for macOS < ${MIN_MACOS_VERSION}")
622 set(MIN_MACOS_VERSION ${CMAKE_OSX_DEPLOYMENT_TARGET})
627 # NOTE: Adding new warnings is a policy decision that can have far-reaching
628 # implications for the project and each developers workflow. Modern
629 # C compilers are on a race to add new warnings, not always sensibly.
630 # They are opt-in so take a moment to fully consider the implications
631 # of enabling the latest shiny new warning.
632 # If in doubt ask on the Wireshark developer list (recommended).
634 list(APPEND WIRESHARK_COMMON_FLAGS
636 ### Flags common to C and C++ ###
638 # -O<X> and -g get set by the CMAKE_BUILD_TYPE
644 -fexcess-precision=fast # GCC-only
647 -Wpragmas # Clang-only
648 -Wheader-guard # Clang-only
650 -Wshorten-64-to-32 # Clang-only
652 -Wunreachable-code # Clang-only
653 -Wdocumentation # Clang-only
654 -Wlogical-op # GCC-only
656 # Disable errors unconditionally for some static analysis warnings
657 # that are dormant at lower optimizations levels or active only in
658 # bleeding edge versions of a compiler and possibly also
659 # prone to false positives and compiler bugs. This is
660 # a big nuisance because the warning is dormant and a low
661 # priority target for action. That is very disruptive
662 # with -Werror enabled (the default on the master branch).
664 -Wno-error=stringop-overflow=
666 # XXX Now that we have a CI job with Release build type (using
667 # -O3 optimization level) the dormancy issue should be ameliorated
668 # so comment out these exceptions to re-evaluate the impact.
669 #-Wno-error=maybe-uninitialized
670 #-Wno-error=alloc-size-larger-than=
672 # Updating external dependencies can introduce new deprecations.
673 # Also fixing new internal deprecations takes time.
674 # We want to be able to build with -Werror in that case. New
675 # code should not introduce new deprecations in any case.
677 -Wno-error=deprecated-declarations
680 if((NOT ENABLE_ASAN) AND (NOT ENABLE_TSAN) AND (NOT ENABLE_UBSAN) AND (NOT DISABLE_FRAME_LARGER_THAN_WARNING))
682 # Only do this if none of ASan, TSan, and UBSan are
683 # enabled; the instrumentation they add increases
684 # the stack usage - we only care about stack
685 # usage in normal operation.
687 list(APPEND WIRESHARK_COMMON_FLAGS
688 -Wframe-larger-than=32768
692 list(APPEND WIRESHARK_C_ONLY_FLAGS
694 ### Flags for C only ###
697 # XXX - some versions of GCC, including the one in at
698 # least some Xcode versions that come with Mac OS X
699 # 10.5, complain about variables in function and
700 # function pointer *declarations* shadowing other
701 # variables. The autoconf script checked for that; we
704 -Wold-style-definition
709 # The universal zero initializer (in C: struct s x = { 0 };) for
710 # structures with multiple members is perfectly legal, but some older
711 # compilers warn about it. Silence those older compilers.
713 if((CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "5.1") OR
714 (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "6.0") OR
715 (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "12.0"))
716 if(NOT CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_VERSION VERSION_LESS "5.0")
717 list(APPEND WIRESHARK_C_ONLY_FLAGS -Wno-missing-field-initializers)
719 # Silence warnings for initialization of nested structs like
720 # struct { struct { int a, b; } s; int c; } v = { 0 };
721 list(APPEND WIRESHARK_C_ONLY_FLAGS -Wno-missing-braces)
724 list(APPEND WIRESHARK_CXX_ONLY_FLAGS
726 ### Flags for C++ only ###
728 -Wextra-semi # Clang-only
732 # Not all warnings are the same. They fall on a spectrum from "critical"
733 # to "pedantic nonsense". These are warnings that realistically are worth
736 if(ENABLE_TODO_WARNINGS)
737 list(APPEND WIRESHARK_COMMON_FLAGS
739 # All the registration functions block these for now.
742 -Wmissing-declarations
744 # A bunch of "that might not work on SPARC" code blocks
745 # this one for now; some of it is code that *will* work
746 # on SPARC, such as casts of "struct sockaddr *" to
747 # "struct sockaddr_in *", which are required by some
748 # APIs such as getifaddrs().
753 list(APPEND WIRESHARK_COMMON_FLAGS
755 # Converting from g_printf() and g_snprintf() to stdio.h turns
756 # up many of these warnings. They will have to be handled later.
757 # It can be a lot of work to fix properly and none of them
758 # seem to flag very interesting issues.
760 -Wno-format-truncation # Enabled with -Wall
762 list(APPEND WIRESHARK_C_ONLY_FLAGS
763 -Wno-pointer-sign # Enabled with -Wall
768 # These are not enabled by default, because the warnings they
769 # produce are very hard or impossible to eliminate.
771 if(ENABLE_PEDANTIC_COMPILER_WARNINGS)
772 list(APPEND WIRESHARK_COMMON_FLAGS
773 # The following are for C and C++
775 -Wno-overlength-strings
778 # As we use variadic macros, we don't want warnings
779 # about them, even with -Wpedantic.
783 # Various code blocks this one.
786 -fstrict-overflow -Wstrict-overflow=4
788 # Due to various places where APIs we don't control
789 # require us to cast away constness, we can probably
790 # never enable this one with -Werror.
794 # Doesn't warn of interesting issues. Usually the
795 # duplicated branches are protocol constants that
796 # happen to be equal and are relevant for documentation
797 # and readability and are trivially optimized by the
800 -Wduplicated-branches # GCC-only
802 # No longer supported by El Capitan clang on C++
803 # XXX - is this one of those where CMake's check
804 # doesn't fail, so it won't reject this?
806 -fno-delete-null-pointer-checks
810 # Some loops are safe, but it's hard to convince the compiler of
811 # that. Always disable the warning on GCC 7 due to a bug that
812 # cause lots of false positives.
813 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81408
815 if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION MATCHES "^7\\.")
816 list(APPEND WIRESHARK_COMMON_FLAGS -Wunsafe-loop-optimizations)
819 list(APPEND WIRESHARK_C_ONLY_FLAGS
820 # The following are C only, not C++
822 # Due to various places where APIs we don't control
823 # require us to cast away constness, we can probably
824 # never enable this one with -Werror.
829 list(APPEND WIRESHARK_CXX_ONLY_FLAGS
833 if(ENABLE_COMPILER_COLOR_DIAGNOSTICS)
834 if(CMAKE_C_COMPILER_ID MATCHES "Clang")
835 set(WIRESHARK_COMMON_FLAGS ${WIRESHARK_COMMON_FLAGS}
838 elseif(CMAKE_C_COMPILER_ID MATCHES "GNU")
839 set(WIRESHARK_COMMON_FLAGS ${WIRESHARK_COMMON_FLAGS}
840 -fdiagnostics-color=always
845 set(WIRESHARK_LD_FLAGS
846 # See also CheckCLinkerFlag.cmake
854 # Counterhack to work around some cache magic in CHECK_C_SOURCE_COMPILES
855 include(CheckCCompilerFlag)
856 include(CheckCXXCompilerFlag)
859 set(BUILD_SHARED_LIBS 0)
861 set(BUILD_SHARED_LIBS 1)
864 function(test_compiler_flag _lang _this_flag _valid_flags_var)
865 string(MAKE_C_IDENTIFIER "${_lang}${_this_flag}_VALID" _flag_var)
866 set(_test_flags "${${_valid_flags_var}} ${_this_flag}")
867 if(_lang STREQUAL "C")
868 check_c_compiler_flag("${_test_flags}" ${_flag_var})
869 elseif(_lang STREQUAL "CXX")
870 check_cxx_compiler_flag("${_test_flags}" ${_flag_var})
872 message(FATAL_ERROR "Language must be C or CXX")
875 set(${_valid_flags_var} "${_test_flags}" PARENT_SCOPE)
879 foreach(THIS_FLAG ${WIRESHARK_COMMON_FLAGS} ${WIRESHARK_C_ONLY_FLAGS})
880 test_compiler_flag(C ${THIS_FLAG} ADDED_CMAKE_C_FLAGS)
882 set(CMAKE_C_FLAGS "${ADDED_CMAKE_C_FLAGS} ${CMAKE_C_FLAGS}")
884 foreach(THIS_FLAG ${WIRESHARK_COMMON_FLAGS} ${WIRESHARK_CXX_ONLY_FLAGS})
885 test_compiler_flag(CXX ${THIS_FLAG} ADDED_CMAKE_CXX_FLAGS)
887 set(CMAKE_CXX_FLAGS "${ADDED_CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
889 # Strips the source and build directory prefix from the __FILE__ macro to ensure
890 # reproducible builds. Supported since GCC 8, Clang support is pending.
891 if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
892 # If the build dir is within the source dir, CMake will use something
893 # like ../epan/dfilter/semcheck.c. Map these relative paths in addition
894 # to CMAKE_BINARY_DIR since compile_commands.json uses absolute paths.
895 file(RELATIVE_PATH _relative_source_dir "${CMAKE_BINARY_DIR}" "${CMAKE_SOURCE_DIR}")
896 string(REGEX REPLACE "/$" "" _relative_source_dir "${_relative_source_dir}")
898 check_c_compiler_flag(-fmacro-prefix-map=old=new C_fmacro_prefix_map_old_new_VALID)
899 check_cxx_compiler_flag(-fmacro-prefix-map=old=new CXX_fmacro_prefix_map_old_new_VALID)
901 if(${_lang}_fmacro_prefix_map_old_new_VALID)
902 set(_flags CMAKE_${_lang}_FLAGS)
903 set(${_flags} "${${_flags}} -fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=")
904 set(${_flags} "${${_flags}} -fmacro-prefix-map=${CMAKE_BINARY_DIR}/=")
905 if(_relative_source_dir MATCHES "\\.\\.$")
906 set(${_flags} "${${_flags}} -fmacro-prefix-map=${_relative_source_dir}/=")
912 include(CMakePushCheckState)
915 # Available since MSVC 2019 version 16.9
916 cmake_push_check_state()
917 set(ASAN_FLAG "-fsanitize=address")
918 set(CMAKE_REQUIRED_FLAGS ${ASAN_FLAG})
919 check_c_compiler_flag(${ASAN_FLAG} C__fsanitize_address_VALID)
920 check_cxx_compiler_flag(${ASAN_FLAG} CXX__fsanitize_address_VALID)
921 cmake_pop_check_state()
922 if(NOT C__fsanitize_address_VALID OR NOT CXX__fsanitize_address_VALID)
923 message(FATAL_ERROR "ENABLE_ASAN was requested, but not supported!")
925 add_compile_options(${ASAN_FLAG})
927 # Using ASAN makes some of our code require object files with
928 # a 32-bit index to the section table instead of 16-bit.
929 # This makes the .obj files slightly larger (~2%) and makes
930 # it so that Microsoft linkers prior to MSVC 2005 can't read
931 # the files, but those are too old anyway.
932 add_compile_options(/bigobj)
933 # The Microsoft LINK linker doesn't recognize or need the
934 # ASAN flag, and will give a LNK4044 warning.
936 # Clang/gcc need the flag added to the linker
937 # add_link_options since CMake 3.13 (our minimum)
938 add_link_options(${ASAN_FLAG})
940 # Disable ASAN for build-time tools, e.g. lemon
941 # (MSVC doesn't support this flag)
942 check_c_compiler_flag(-fno-sanitize=all C__fno_sanitize_all_VALID)
943 if(C__fno_sanitize_all_VALID)
944 set(NO_SANITIZE_CFLAGS "-fno-sanitize=all")
945 set(NO_SANITIZE_LDFLAGS "-fno-sanitize=all")
950 # Available since Clang >= 3.2 and GCC >= 4.8
951 cmake_push_check_state()
952 set(CMAKE_REQUIRED_LIBRARIES "-fsanitize=thread")
953 check_c_compiler_flag(-fsanitize=thread C__fsanitize_thread_VALID)
954 check_cxx_compiler_flag(-fsanitize=thread CXX__fsanitize_thread_VALID)
955 cmake_pop_check_state()
956 if(NOT C__fsanitize_thread_VALID OR NOT CXX__fsanitize_thread_VALID)
957 message(FATAL_ERROR "ENABLE_TSAN was requested, but not supported!")
959 set(CMAKE_C_FLAGS "-fsanitize=thread ${CMAKE_C_FLAGS}")
960 set(CMAKE_CXX_FLAGS "-fsanitize=thread ${CMAKE_CXX_FLAGS}")
961 set(WS_LINK_FLAGS "-fsanitize=thread ${WS_LINK_FLAGS}")
965 # Available since Clang >= 3.3 and GCC >= 4.9
966 cmake_push_check_state()
967 set(CMAKE_REQUIRED_LIBRARIES "-fsanitize=undefined")
968 check_c_compiler_flag(-fsanitize=undefined C__fsanitize_undefined_VALID)
969 check_cxx_compiler_flag(-fsanitize=undefined CXX__fsanitize_undefined_VALID)
970 cmake_pop_check_state()
971 if(NOT C__fsanitize_undefined_VALID OR NOT CXX__fsanitize_undefined_VALID)
972 message(FATAL_ERROR "ENABLE_UBSAN was requested, but not supported!")
974 set(CMAKE_C_FLAGS "-fsanitize=undefined ${CMAKE_C_FLAGS}")
975 set(CMAKE_CXX_FLAGS "-fsanitize=undefined ${CMAKE_CXX_FLAGS}")
979 # Available since Clang >= 6
980 # Will enable coverage flags which can be used by the fuzzshark target.
981 cmake_push_check_state()
982 set(CMAKE_REQUIRED_LIBRARIES "-fsanitize=fuzzer-no-link")
983 check_c_compiler_flag(-fsanitize=fuzzer C__fsanitize_fuzzer_no_link_VALID)
984 check_cxx_compiler_flag(-fsanitize=fuzzer CXX__fsanitize_fuzzer_no_link_VALID)
985 cmake_pop_check_state()
986 if(NOT C__fsanitize_fuzzer_no_link_VALID OR NOT CXX__fsanitize_fuzzer_no_link_VALID)
987 message(FATAL_ERROR "ENABLE_FUZZER was requested, but not supported!")
989 set(CMAKE_C_FLAGS "-fsanitize=fuzzer-no-link ${CMAKE_C_FLAGS}")
990 set(CMAKE_CXX_FLAGS "-fsanitize=fuzzer-no-link ${CMAKE_CXX_FLAGS}")
997 message(FATAL_ERROR "ENABLE_VLD was requested, but not found!")
999 message(STATUS "Enabling Visual Leak Detector in Debug configuration")
1000 set(WS_MSVC_DEBUG_LINK_FLAGS ${VLD_LINK_FLAGS})
1004 set(WERROR_COMMON_FLAGS "")
1006 if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
1007 set(WERROR_COMMON_FLAGS "/WX")
1010 # If a warning has been enabled by -Wall or -W,
1011 # and have specified -Werror, there appears to be
1012 # no way, in Apple's llvm-gcc, to prevent that
1013 # particular warning from giving an error - not
1014 # with a pragma, not with -Wno-{warning}, and not
1015 # with -Wno-error={warning}.
1017 # Therefore, with that compiler, we just disable
1020 if ((NOT APPLE) OR CMAKE_C_COMPILER_ID MATCHES "Clang")
1021 check_c_compiler_flag(-Werror WERROR)
1023 set(WERROR_COMMON_FLAGS "-Werror")
1030 # Try to have the compiler default to hiding symbols, so that only
1031 # symbols explicitly exported with WS_DLL_PUBLIC will be visible
1032 # outside (shared) libraries; that way, more UN*X builds will catch
1033 # failures to export symbols, rather than having that fail only on
1036 # We don't need that with MSVC, as that's the default.
1038 if( NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
1040 # Try the GCC-and-compatible -fvisibility-hidden first.
1042 check_c_compiler_flag(-fvisibility=hidden FVHIDDEN)
1044 set(CMAKE_C_FLAGS "-fvisibility=hidden ${CMAKE_C_FLAGS}")
1047 # OK, try the Sun^WOracle C -xldscope=hidden
1049 check_c_compiler_flag(-xldscope=hidden XLDSCOPEHIDDEN)
1051 set(CMAKE_C_FLAGS "-xldscope=hidden ${CMAKE_C_FLAGS}")
1055 # If there is anything else, we might want to
1056 # make a list of options to try, and try them
1059 message(WARNING "Hiding shared library symbols is not supported by the compiler."
1060 " All shared library symbols will be exported.")
1065 include(CheckCLinkerFlag)
1067 if(NOT CMAKE_C_COMPILER_ID MATCHES "MSVC" AND NOT OSS_FUZZ)
1069 # The -pie linker option produces a position-independent executable.
1070 # Some Linux distributions have this enabled by default in the compiler,
1071 # so setting it here will be superfluous though.
1073 # Note that linking with static libraries that are not position
1074 # independent may fail, the user can set CMAKE_EXE_LINKER_FLAGS=-no-pie
1077 if(CMAKE_VERSION VERSION_LESS "3.14")
1078 check_c_linker_flag(-pie LINK_pie_VALID)
1080 set(CMAKE_EXE_LINKER_FLAGS "-pie ${CMAKE_EXE_LINKER_FLAGS}")
1083 include(CheckPIESupported)
1084 check_pie_supported()
1088 foreach(THIS_FLAG ${WIRESHARK_LD_FLAGS})
1089 string(MAKE_C_IDENTIFIER "LINK${THIS_FLAG}_VALID" _flag_var)
1090 check_c_linker_flag(${THIS_FLAG} ${_flag_var})
1092 set(WS_LINK_FLAGS "${WS_LINK_FLAGS} ${THIS_FLAG}")
1095 message(STATUS "Linker flags: ${WS_LINK_FLAGS}")
1097 if(APPLE AND EXISTS /usr/local/opt/gettext)
1098 # GLib on macOS requires libintl. Homebrew installs gettext (and
1099 # libintl) in /usr/local/opt/gettext
1100 include_directories(SYSTEM /usr/local/opt/gettext/include)
1101 link_directories(/usr/local/opt/gettext/lib)
1104 # Resets cache variables if the <PackageName>_LIBRARY has become invalid.
1105 # Call it before a find_package(<PackageName> ...) invocation that uses
1106 # find_library(<PackageName>_LIBRARY ...).
1108 # Usage: reset_find_package(<PackageName> [<extra variables to clear>])
1109 function(reset_find_package _package_name)
1111 # find_library / find_package
1112 ${_package_name}_LIBRARY
1113 ${_package_name}_INCLUDE_DIR
1115 ${_package_name}_LIBRARIES
1116 ${_package_name}_INCLUDE_DIRS
1118 ${_package_name}_DLL_DIR
1119 ${_package_name}_DLLS
1120 ${_package_name}_DLL
1121 ${_package_name}_PDB
1124 if(NOT ${_package_name}_LIBRARY OR EXISTS ${${_package_name}_LIBRARY})
1125 # Cache variable is already missing or cache entry is valid.
1128 message(STATUS "Package ${_package_name} has changed, clearing cache.")
1129 foreach(_var IN LISTS variables)
1130 unset(${_var} CACHE)
1134 # ws_find_package(<PackageName>
1135 # <CMakeOptions.txt boolean variable>
1136 # <cmakeconfig.h.in macro definition>
1137 # [remaining find_package() arguments])
1138 macro(ws_find_package _package_name _enable_package _package_cmakedefine)
1139 if(${_enable_package})
1140 # Clear outdated cache variables if not already.
1141 reset_find_package(${_package_name})
1142 find_package(${_package_name} ${ARGN})
1143 if(${_package_name}_FOUND)
1144 set(${_package_cmakedefine} 1)
1149 # The minimum package list
1151 reset_find_package(GLIB2 GLIB2_MAIN_INCLUDE_DIR GLIB2_INTERNAL_INCLUDE_DIR)
1152 find_package(GLIB2 "2.54.0" REQUIRED)
1153 include_directories(SYSTEM ${GLIB2_INCLUDE_DIRS})
1154 reset_find_package(GMODULE2)
1155 find_package(GMODULE2)
1156 reset_find_package(GTHREAD2)
1157 find_package(GTHREAD2 REQUIRED)
1158 reset_find_package(GCRYPT GCRYPT_ERROR_LIBRARY)
1159 find_package(GCRYPT "1.8.0" REQUIRED)
1160 # C Asynchronous resolver
1161 reset_find_package(CARES)
1162 find_package(CARES "1.13.0" REQUIRED)
1163 find_package(LEX REQUIRED)
1165 find_package(PCRE2 REQUIRED)
1168 find_package(Gettext)
1169 find_package(M REQUIRED)
1172 if(BUILD_sshdump OR BUILD_ciscodump OR BUILD_wifidump)
1173 set(ENABLE_LIBSSH ON)
1175 set(ENABLE_LIBSSH OFF)
1177 ws_find_package(LIBSSH ENABLE_LIBSSH HAVE_LIBSSH "0.6")
1179 ws_find_package(PCAP ENABLE_PCAP HAVE_LIBPCAP)
1180 ws_find_package(AIRPCAP ENABLE_AIRPCAP HAVE_AIRPCAP)
1181 ws_find_package(Systemd BUILD_sdjournal HAVE_SYSTEMD)
1183 # Build one of the Qt GUIs?
1184 if(BUILD_wireshark OR BUILD_logray)
1187 if(DEFINED ENV{WIRESHARK_QT6_PREFIX_PATH})
1188 list(APPEND CMAKE_PREFIX_PATH $ENV{WIRESHARK_QT6_PREFIX_PATH})
1192 if(DEFINED ENV{WIRESHARK_QT5_PREFIX_PATH})
1193 list(APPEND CMAKE_PREFIX_PATH $ENV{WIRESHARK_QT5_PREFIX_PATH})
1194 # XXX We used to recommend setting QT5_BASE_DIR. Remove after the 4.0 branch is created.
1195 elseif(WIN32 AND NOT USE_MSYSTEM AND DEFINED ENV{QT5_BASE_DIR})
1196 message(WARNING "Support for QT5_BASE_DIR will be removed in a future release.")
1197 set(QT5_BASE_PATH "$ENV{QT5_BASE_DIR}")
1198 set(CMAKE_PREFIX_PATH "${QT5_BASE_PATH}")
1201 if(APPLE AND EXISTS /usr/local/opt/qt5)
1202 # Homebrew installs Qt5 (up to at least 5.11.0) in
1203 # /usr/local/qt5. Ensure that it can be found by CMake
1204 # since it is not in the default /usr/local prefix.
1205 # Add it to PATHS so that it doesn't override the
1206 # CMAKE_PREFIX_PATH environment variable.
1207 # QT_FIND_PACKAGE_OPTIONS should be passed to find_package,
1208 # e.g. find_package(Qt5Core ${QT_FIND_PACKAGE_OPTIONS})
1209 list(APPEND QT_FIND_PACKAGE_OPTIONS PATHS /usr/local/opt/qt5)
1214 Qt${qtver}LinguistTools
1215 Qt${qtver}PrintSupport
1217 Qt${qtver}Concurrent
1219 set(QT_OPTIONAL_PACKAGELIST
1220 Qt${qtver}Multimedia
1223 set(CMAKE_CXX_STANDARD 17)
1224 # Setting CMAKE_CXX_STANDARD is not sufficient with MSVC, see
1225 # https://gitlab.kitware.com/cmake/cmake/-/issues/18837
1226 # The below test can be found in Qt6, lib/cmake/Qt6/QtFeature.cmake
1227 if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND MSVC_VERSION GREATER_EQUAL 1913)
1228 add_definitions("-Zc:__cplusplus")
1230 list(APPEND QT_PACKAGELIST Qt6Core5Compat)
1233 list(APPEND QT_PACKAGELIST Qt5WinExtras)
1236 foreach(_qt_package IN LISTS QT_PACKAGELIST)
1237 find_package(${_qt_package} REQUIRED ${QT_FIND_PACKAGE_OPTIONS})
1238 list(APPEND QT_LIBRARIES ${${_qt_package}_LIBRARIES})
1239 list(APPEND QT_INCLUDE_DIRS ${${_qt_package}_INCLUDE_DIRS})
1240 list(APPEND QT_COMPILE_DEFINITIONS ${${_qt_package}_COMPILE_DEFINITIONS})
1242 foreach(_qt_package IN LISTS QT_OPTIONAL_PACKAGELIST)
1243 find_package(${_qt_package} ${QT_FIND_PACKAGE_OPTIONS})
1244 list(APPEND QT_LIBRARIES ${${_qt_package}_LIBRARIES})
1245 list(APPEND QT_INCLUDE_DIRS ${${_qt_package}_INCLUDE_DIRS})
1246 list(APPEND QT_COMPILE_DEFINITIONS ${${_qt_package}_COMPILE_DEFINITIONS})
1248 if(APPLE AND "/usr/local/opt/qt5/lib/QtCore.framework" IN_LIST Qt5Core_INCLUDE_DIRS)
1249 # When qt@6 and qt@5 are both installed via Homebrew,
1250 # /usr/local/include/QtCore/qvariant.h points to Qt 6 headers.
1251 # Normally the Headers from `-iframework /usr/local/opt/qt5/lib`
1252 # should be used, but `-isystem /usr/local/include` (via
1253 # Libgcrypt and others) seems to prioritized, resulting in use
1254 # of the Qt6 headers. Resolve this by explicit including Qt5.
1255 list(APPEND QT_INCLUDE_DIRS /usr/local/opt/qt5/include)
1259 ws_find_package(Sparkle ENABLE_SPARKLE HAVE_SOFTWARE_UPDATE 2)
1261 if(Qt${qtver}Multimedia_FOUND)
1262 set(QT_MULTIMEDIA_LIB 1)
1266 # MaxMind DB address resolution
1267 reset_find_package(MAXMINDDB)
1268 ws_find_package(MaxMindDB BUILD_mmdbresolve HAVE_MAXMINDDB)
1271 reset_find_package(SMI SMI_SHARE_DIR)
1272 ws_find_package(SMI ENABLE_SMI HAVE_LIBSMI)
1274 # Support for TLS decryption using RSA private keys.
1275 ws_find_package(GNUTLS ENABLE_GNUTLS HAVE_LIBGNUTLS "3.5.8")
1278 ws_find_package(KERBEROS ENABLE_KERBEROS HAVE_KERBEROS)
1281 ws_find_package(ZLIB ENABLE_ZLIB HAVE_ZLIB)
1283 # Minizip compression
1284 ws_find_package(Minizip ENABLE_MINIZIP HAVE_MINIZIP)
1286 # Brotli compression
1287 ws_find_package(BROTLI ENABLE_BROTLI HAVE_BROTLI)
1290 ws_find_package(LZ4 ENABLE_LZ4 HAVE_LZ4)
1292 # Snappy compression
1293 ws_find_package(SNAPPY ENABLE_SNAPPY HAVE_SNAPPY)
1296 ws_find_package(ZSTD ENABLE_ZSTD HAVE_ZSTD "1.0.0")
1298 # Enhanced HTTP/2 dissection
1299 ws_find_package(NGHTTP2 ENABLE_NGHTTP2 HAVE_NGHTTP2 "1.11.0")
1301 # Embedded Lua interpreter
1302 ws_find_package(LUA ENABLE_LUA HAVE_LUA "5.1")
1304 ws_find_package(NL ENABLE_NETLINK HAVE_LIBNL)
1306 ws_find_package(SBC ENABLE_SBC HAVE_SBC)
1309 ws_find_package(SPANDSP ENABLE_SPANDSP HAVE_SPANDSP)
1311 ws_find_package(BCG729 ENABLE_BCG729 HAVE_BCG729)
1313 ws_find_package(AMRNB ENABLE_AMRNB HAVE_AMRNB)
1315 ws_find_package(ILBC ENABLE_ILBC HAVE_ILBC)
1317 ws_find_package(OPUS ENABLE_OPUS HAVE_OPUS)
1320 # libsinsp+libscap, required for falco-bridge
1321 ws_find_package(Sinsp ENABLE_SINSP HAVE_SINSP)
1324 # CMake 3.9 and below used 'LIBXML2_LIBRARIES' as the name of the cache entry
1325 # storing the find_library result. Transfer it to the new cache variable such
1326 # that reset_find_package can detect and clear outdated cache variables.
1327 if(DEFINED LIBXML2_LIBRARIES AND NOT DEFINED LIBXML2_LIBRARY)
1328 set(LIBXML2_LIBRARY ${LIBXML2_LIBRARIES} CACHE FILEPATH "")
1330 # Call reset_find_package explicitly since variables are in upper case.
1331 reset_find_package(LIBXML2)
1332 ws_find_package(LibXml2 ENABLE_LIBXML2 HAVE_LIBXML2)
1333 if(NOT LIBXML2_FOUND)
1334 # CMake 3.9 and below used LIBXML2_LIBRARIES as the name of
1335 # the cache entry storing the find_library result.
1336 # Current CMake (3.13) and below sets LIBXML2_LIBRARIES and LIBXML2_INCLUDE_DIRS
1337 # to a non-empty value, be sure to clear it when not found.
1338 set(LIBXML2_LIBRARIES "")
1339 set(LIBXML2_INCLUDE_DIRS "")
1342 # Capabilities to run dumpcap as non-root user.
1343 if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
1344 ws_find_package(CAP ENABLE_CAP HAVE_LIBCAP)
1345 find_package(SETCAP)
1348 # Windows version updates
1349 ws_find_package(WinSparkle ENABLE_WINSPARKLE HAVE_SOFTWARE_UPDATE)
1351 find_package( Asciidoctor 1.5 )
1352 find_package( XSLTPROC )
1354 find_package(DOXYGEN)
1356 # The SpeexDSP resampler is required iff building wireshark or sharkd.
1357 if(BUILD_wireshark OR BUILD_logray OR BUILD_sharkd)
1358 find_package(SpeexDSP REQUIRED)
1361 # Generate the distribution tarball.
1362 add_custom_target(dist
1363 COMMAND ${CMAKE_BINARY_DIR}/packaging/source/git-export-release.sh -d "${CMAKE_BINARY_DIR}"
1364 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
1368 # Calculating public keys from PKCS #11 private keys requires GnuTLS
1371 # Check that the support is present in case GnuTLS was compiled
1372 # --without-p11-kit as macos-setup.sh did until December 2020.
1373 cmake_push_check_state()
1374 if(WIN32 AND NOT MINGW)
1375 set(CMAKE_REQUIRED_DEFINITIONS -Dssize_t=int)
1377 set(CMAKE_REQUIRED_INCLUDES ${GNUTLS_INCLUDE_DIRS})
1378 set(CMAKE_REQUIRED_LIBRARIES ${GNUTLS_LIBRARIES})
1379 check_symbol_exists(gnutls_pkcs11_obj_list_import_url4 gnutls/pkcs11.h HAVE_GNUTLS_PKCS11)
1380 cmake_pop_check_state()
1384 if (Qt${qtver}Widgets_VERSION VERSION_LESS 5.10)
1385 message(FATAL_ERROR "Qt 5.12 or later is required.")
1387 if (Qt${qtver}Widgets_VERSION VERSION_LESS 5.12)
1388 message(WARNING "Wireshark can be build with this version of Qt, though 5.12 or higher is recommended.")
1390 if(NOT DEFINED MOC_OPTIONS)
1391 # Squelch moc verbose "nothing to do" output
1392 set(MOC_OPTIONS -nn)
1395 # CMake uses qmake to find Qt4. It relies on Qt's CMake modules
1396 # to find Qt5. This means that we can't assume that the qmake
1397 # in our PATH is the correct one. We can fetch qmake's location
1398 # from Qt5::qmake, which is defined in Qt5CoreConfigExtras.cmake.
1399 get_target_property(QT_QMAKE_EXECUTABLE Qt${qtver}::qmake IMPORTED_LOCATION)
1400 get_filename_component(_qt_bin_path "${QT_QMAKE_EXECUTABLE}" DIRECTORY)
1401 set(QT_BIN_PATH "${_qt_bin_path}" CACHE INTERNAL
1402 "Path to qmake, macdeployqt, windeployqt, and other Qt utilities."
1404 # Use qmake to find windeployqt and macdeployqt. Ideally one of
1405 # the modules in ${QTDIR}/lib/cmake would do this for us.
1407 if (USE_qt6 AND USE_MSYSTEM)
1408 set(_windeployqt_name "windeployqt-qt6")
1410 set(_windeployqt_name "windeployqt")
1412 find_program(QT_WINDEPLOYQT_EXECUTABLE ${_windeployqt_name}
1413 HINTS "${QT_BIN_PATH}"
1414 DOC "Path to the windeployqt utility."
1416 # As of Qt 6.5.0, the official Qt "MSVC 2019 ARM64 (TP)" libraries don't ship
1417 # with native Arm64 executables. Instead, you get x64 executables installed in
1418 # msvc2019_x64. Look for the path to "qmake.bat", which has to be passed to
1419 # windeployqt so that it can install the proper DLLs.
1420 # https://bugreports.qt.io/browse/QTBUG-100070
1421 set(QT_WINDEPLOYQT_EXTRA_ARGS)
1422 find_program(_qt_qmake_bat qmake.bat
1423 HINTS ENV CMAKE_PREFIX_PATH
1425 DOC "Path to qmake.bat."
1428 set (QT_WINDEPLOYQT_EXTRA_ARGS "--qmake \"${_qt_qmake_bat}\"")
1431 find_program(QT_MACDEPLOYQT_EXECUTABLE macdeployqt
1432 HINTS "${QT_BIN_PATH}"
1433 DOC "Path to the macdeployqt utility."
1435 find_program(DMGBUILD_EXECUTABLE dmgbuild
1436 DOC "Path to the dmgbuild utility"
1438 # https://doc.qt.io/qt-5/supported-platforms.html
1439 # https://doc.qt.io/qt-5.11/supported-platforms-and-configurations.html
1440 # https://doc.qt.io/qt-5.15/supported-platforms.html
1441 # https://doc-snapshots.qt.io/qt6-dev/supported-platforms.html
1442 if(Qt${qtver}Widgets_VERSION VERSION_GREATER_EQUAL "6.0.0")
1443 set(MIN_MACOS_VERSION 10.14)
1444 elseif(Qt5Widgets_VERSION VERSION_GREATER_EQUAL "5.14.0")
1445 set(MIN_MACOS_VERSION 10.13)
1446 elseif(Qt5Widgets_VERSION VERSION_GREATER_EQUAL "5.12.0")
1447 set(MIN_MACOS_VERSION 10.12)
1448 elseif(Qt5Widgets_VERSION VERSION_GREATER_EQUAL "5.10.0")
1449 set(MIN_MACOS_VERSION 10.11)
1451 if(CMAKE_OSX_DEPLOYMENT_TARGET AND CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS MIN_MACOS_VERSION)
1452 message(FATAL_ERROR "Qt version ${Qt${qtver}Widgets_VERSION} requires CMAKE_OSX_DEPLOYMENT_TARGET (${CMAKE_OSX_DEPLOYMENT_TARGET}) >= ${MIN_MACOS_VERSION}")
1456 # Qt requires MSVC /permissive- option since 6.3 release
1457 if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND Qt${qtver}Widgets_VERSION VERSION_GREATER_EQUAL "6.3.0")
1458 add_compile_options("/permissive-")
1462 if(ENABLE_CHECKHF_CONFLICT)
1463 set(ENABLE_CHECK_FILTER 1)
1467 # Platform-specific additional libraries.
1470 set(WIN_COMCTL32_LIBRARY comctl32.lib)
1471 set(WIN_IPHLPAPI_LIBRARY iphlpapi.lib)
1472 set(WIN_PSAPI_LIBRARY psapi.lib)
1473 set(WIN_VERSION_LIBRARY version.lib)
1474 set(WIN_WS2_32_LIBRARY ws2_32.lib)
1479 # We assume that APPLE means macOS so that we have the macOS
1482 set(HAVE_MACOS_FRAMEWORKS 1)
1483 FIND_LIBRARY (APPLE_APPLICATION_SERVICES_LIBRARY ApplicationServices)
1484 FIND_LIBRARY (APPLE_APPKIT_LIBRARY AppKit)
1485 FIND_LIBRARY (APPLE_CORE_FOUNDATION_LIBRARY CoreFoundation)
1486 FIND_LIBRARY (APPLE_SYSTEM_CONFIGURATION_LIBRARY SystemConfiguration)
1488 message(STATUS "Building for Mac OS X/OS X/macOS ${MIN_MACOS_VERSION} using SDK ${CMAKE_OSX_SYSROOT}")
1491 include(ConfigureChecks.cmake)
1494 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1497 if(NOT (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang"))
1498 # https://ccache.dev/platform-compiler-language-support.html
1499 message(WARNING "Ccache is enabled, but your compiler is ${CMAKE_C_COMPILER_ID}."
1500 " We wish you the best of luck.")
1502 find_program(CCACHE_EXECUTABLE ccache)
1503 if(CCACHE_EXECUTABLE)
1504 set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}")
1505 set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}")
1506 set(CMAKE_C_LINKER_LAUNCHER "${CCACHE_EXECUTABLE}")
1507 set(CMAKE_CXX_LINKER_LAUNCHER "${CCACHE_EXECUTABLE}")
1511 # The top level checkAPIs target, add before subdirectory calls so it's avaiable to all
1512 add_custom_target(checkAPI)
1513 set_target_properties(checkAPI
1516 EXCLUDE_FROM_ALL True
1517 EXCLUDE_FROM_DEFAULT_BUILD True
1520 include( UseCheckAPI )
1522 # Target platform locations
1523 # UN*X in general, including macOS if not building an app bundle:
1524 # $DESTDIR/lib/wireshark/extcap
1525 # Windows: $DESTDIR/extcap
1526 # macOS app bundle: Wireshark.app/Contents/Resources/share/wireshark/extcap
1527 # If you change the nesting level be sure to check also the INSTALL_RPATH
1529 if(WIN32 AND NOT USE_MSYSTEM)
1530 set(EXTCAP_INSTALL_LIBDIR "extcap" CACHE INTERNAL "The extcap dir")
1532 set(EXTCAP_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/extcap" CACHE INTERNAL "The extcap dir")
1534 set(EXTCAP_INSTALL_FULL_LIBDIR "${CMAKE_INSTALL_PREFIX}/${EXTCAP_INSTALL_LIBDIR}")
1538 # As https://developer.apple.com/library/archive/technotes/tn2206/_index.html
1541 # "Note that a location where code is expected to reside cannot generally
1542 # contain directories full of nested code, because those directories tend
1543 # to be interpreted as bundles. So this occasional practice is not
1544 # recommended and not officially supported. If you do do this, do not use
1545 # periods in the directory names. The code signing machinery interprets
1546 # directories with periods in their names as code bundles and will reject
1547 # them if they don't conform to the expected code bundle layout."
1549 set(PLUGIN_PATH_ID "${PROJECT_MAJOR_VERSION}-${PROJECT_MINOR_VERSION}")
1551 set(PLUGIN_PATH_ID "${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}")
1554 # Directory where plugins and Lua dissectors can be found.
1555 if(WIN32 AND NOT USE_MSYSTEM)
1556 set(PLUGIN_INSTALL_LIBDIR "plugins" CACHE INTERNAL "The plugin dir")
1558 set(PLUGIN_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/plugins" CACHE INTERNAL "The plugin dir")
1560 set(PLUGIN_INSTALL_FULL_LIBDIR "${CMAKE_INSTALL_PREFIX}/${PLUGIN_INSTALL_LIBDIR}")
1561 set(PLUGIN_INSTALL_VERSION_LIBDIR "${PLUGIN_INSTALL_LIBDIR}/${PLUGIN_PATH_ID}")
1562 set(PLUGIN_VERSION_DIR "plugins/${PLUGIN_PATH_ID}")
1564 add_subdirectory( capture )
1565 add_subdirectory( doc )
1566 add_subdirectory( docbook EXCLUDE_FROM_ALL )
1567 add_subdirectory( epan )
1568 add_subdirectory( extcap )
1569 add_subdirectory( randpkt_core )
1570 if(NOT LEMON_EXECUTABLE)
1571 add_subdirectory( tools/lemon )
1574 add_subdirectory( tools/radiotap-gen )
1576 add_subdirectory( ui )
1577 add_subdirectory( wiretap )
1578 add_subdirectory( writecap )
1580 # Location of our data files. This should be set to a value that allows
1581 # running from the build directory on Windows, on macOS when building an
1582 # application bundle, and on UNIX in general if
1583 # WIRESHARK_RUN_FROM_BUILD_DIRECTORY is set.
1584 if(ENABLE_APPLICATION_BUNDLE)
1585 if(CMAKE_CFG_INTDIR STREQUAL ".")
1586 set(_datafile_dir "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/share/wireshark")
1589 set(_datafile_dir "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}/Wireshark.app/Contents/Resources/share/wireshark")
1591 elseif(NOT CMAKE_CFG_INTDIR STREQUAL ".")
1592 # Visual Studio, Xcode, etc.
1593 set(_datafile_dir "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}")
1595 # Makefile, Ninja, etc.
1596 set(_datafile_dir "${CMAKE_BINARY_DIR}/run")
1599 set(DATAFILE_DIR ${_datafile_dir} CACHE INTERNAL "Build time data file location.")
1601 if(ENABLE_APPLICATION_BUNDLE)
1602 if(CMAKE_CFG_INTDIR STREQUAL ".")
1603 set(_log_datafile_dir "${CMAKE_BINARY_DIR}/run/Logray.app/Contents/Resources/share/logray")
1606 set(_log_datafile_dir "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}/Logray.app/Contents/Resources/share/logray")
1608 set(LOG_DATAFILE_DIR ${_log_datafile_dir} CACHE INTERNAL "Build time log analysis data file location.")
1609 # XXX We need to update wsutil/filesystem.c and packaging/nsis/*logray* to match.
1610 # elseif(NOT CMAKE_CFG_INTDIR STREQUAL ".")
1611 # # Visual Studio, Xcode, etc.
1612 # set(_log_datafile_dir "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}/share/logray")
1614 # # Makefile, Ninja, etc.
1615 # set(_log_datafile_dir "${CMAKE_BINARY_DIR}/run/share/logray")
1619 # wsutil must be added after DATAFILE_DIR is set such that filesystem.c can
1620 # learn about the directory location.
1621 add_subdirectory( wsutil )
1623 if(BUILD_wireshark AND QT_FOUND)
1624 add_subdirectory( ui/qt )
1625 elseif(BUILD_wireshark AND USE_qt6)
1626 message(VERBOSE "To use Qt5 instead of Qt6 use CMake option USE_qt6=OFF.")
1629 if(BUILD_logray AND QT_FOUND)
1630 add_subdirectory( ui/logray )
1633 # Location of our plugins. PLUGIN_DIR should allow running
1634 # from the build directory similar to DATAFILE_DIR above.
1636 # Target platform locations
1637 # UN*X in general, including macOS if not building an app bundle:
1638 # $DESTDIR/lib/wireshark/plugins/$VERSION
1639 # Windows: $DESTDIR/wireshark/plugins/$VERSION
1640 # macOS app bundle: Wireshark.app/Contents/PlugIns/wireshark
1642 add_custom_target(plugins)
1643 set_target_properties(plugins PROPERTIES FOLDER "Plugins")
1645 plugins/epan/ethercat
1646 plugins/epan/gryphon
1650 plugins/epan/profinet
1651 plugins/epan/stats_tree
1652 plugins/epan/transum
1653 plugins/epan/unistim
1655 plugins/epan/wimaxasncp
1656 plugins/epan/wimaxmacphy
1657 plugins/wiretap/usbdump
1659 plugins/codecs/l16_mono
1660 ${CUSTOM_PLUGIN_SRC_DIR}
1662 set(LOGRAY_PLUGIN_SRC_DIRS)
1664 list(APPEND LOGRAY_PLUGIN_SRC_DIRS
1665 plugins/epan/falco_bridge
1669 list(APPEND PLUGIN_SRC_DIRS
1675 list(APPEND PLUGIN_SRC_DIRS
1680 list(APPEND PLUGIN_SRC_DIRS
1681 plugins/codecs/amrnb
1685 list(APPEND PLUGIN_SRC_DIRS
1690 list(APPEND PLUGIN_SRC_DIRS
1691 plugins/codecs/opus_dec
1695 list(APPEND PLUGIN_SRC_DIRS
1700 # Build demo plugin, only if asked explicitly
1701 if(ENABLE_PLUGIN_IFDEMO)
1702 list(APPEND PLUGIN_SRC_DIRS
1703 plugins/epan/pluginifdemo
1708 set(PLUGIN_SRC_DIRS )
1709 set(LOGRAY_PLUGIN_SRC_DIRS )
1712 if(ENABLE_APPLICATION_BUNDLE)
1713 if(CMAKE_CFG_INTDIR STREQUAL ".")
1714 set(_plugin_dir "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/PlugIns/wireshark/${PLUGIN_PATH_ID}")
1717 set(_plugin_dir "${CMAKE_BINARY_DIR}/run/$<CONFIG>/Wireshark.app/Contents/PlugIns/wireshark/${PLUGIN_PATH_ID}")
1719 if(CMAKE_CFG_INTDIR STREQUAL ".")
1720 set(_logray_plugin_dir "${CMAKE_BINARY_DIR}/run/Logray.app/Contents/PlugIns/logray/${PLUGIN_PATH_ID}")
1723 set(_logray_plugin_dir "${CMAKE_BINARY_DIR}/run/$<CONFIG>/Logray.app/Contents/PlugIns/logray/${PLUGIN_PATH_ID}")
1725 elseif(MSVC AND NOT CMAKE_CFG_INTDIR STREQUAL ".")
1726 set(_plugin_dir "${CMAKE_BINARY_DIR}/run/$<CONFIG>/${PLUGIN_VERSION_DIR}")
1727 set(_logray_plugin_dir ${_plugin_dir})
1729 set(_plugin_dir "${DATAFILE_DIR}/${PLUGIN_VERSION_DIR}")
1730 set(_logray_plugin_dir ${_plugin_dir})
1732 set (PLUGIN_DIR ${_plugin_dir} CACHE INTERNAL "Build time plugin location.")
1733 set (LOGRAY_PLUGIN_DIR ${_logray_plugin_dir} CACHE INTERNAL "Build time Logray plugin location.")
1735 foreach(_plugin_src_dir ${PLUGIN_SRC_DIRS} ${LOGRAY_PLUGIN_SRC_DIRS})
1736 add_subdirectory( ${_plugin_src_dir} )
1739 if(VCSVERSION_OVERRIDE)
1740 # Allow distributors to override detection of the Git tag and version.
1741 string(CONFIGURE "#define VCSVERSION \"@VCSVERSION_OVERRIDE@\"\n"
1742 _version_h_contents ESCAPE_QUOTES)
1743 file(WRITE "${CMAKE_BINARY_DIR}/vcs_version.h" "${_version_h_contents}")
1744 message(STATUS "VCSVERSION_OVERRIDE: ${VCSVERSION_OVERRIDE}")
1746 add_custom_target(vcs_version
1747 BYPRODUCTS vcs_version.h
1748 COMMAND ${PYTHON_EXECUTABLE}
1749 ${CMAKE_SOURCE_DIR}/tools/make-version.py
1752 set_target_properties(vcs_version PROPERTIES FOLDER "Auxiliary")
1755 set( configure_input "Built with CMake ${CMAKE_VERSION}" )
1756 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
1758 configure_file(${CMAKE_SOURCE_DIR}/ws_version.h.in ${CMAKE_BINARY_DIR}/ws_version.h)
1760 set( prefix "${CMAKE_INSTALL_PREFIX}" )
1761 set( exec_prefix "\${prefix}" )
1762 set( libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}" )
1763 set( includedir "\${prefix}/include" )
1764 set( plugindir "\${libdir}/wireshark/${PLUGIN_VERSION_DIR}" )
1767 file(GLOB TOP_LEVEL_SOURCE_LIST *.c *.cpp *.h)
1768 string (REPLACE ";" " " DOXYGEN_TOP_LEVEL_SOURCES "${TOP_LEVEL_SOURCE_LIST}")
1769 set(DOXYGEN_INPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
1770 set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
1774 packaging/macosx/osx-app.sh
1775 packaging/macosx/osx-dmg.sh
1776 packaging/macosx/wireshark-app.dmgbuild
1777 packaging/macosx/wireshark-dsym.dmgbuild
1778 packaging/macosx/WiresharkInfo.plist
1779 packaging/source/git-export-release.sh
1780 resources/dumpcap.rc
1781 resources/libwireshark.rc
1782 resources/libwiretap.rc
1783 resources/libwsutil.rc
1784 resources/wireshark.exe.manifest
1785 resources/wireshark.rc
1790 list(APPEND CFG_OUT_FILES
1791 packaging/macosx/LograyInfo.plist
1792 packaging/macosx/logray-app.dmgbuild
1793 packaging/macosx/logray-dsym.dmgbuild
1794 resources/logray.exe.manifest
1798 foreach( _cfg_file ${CFG_OUT_FILES} )
1799 configure_file( ${CMAKE_SOURCE_DIR}/${_cfg_file}.in ${CMAKE_BINARY_DIR}/${_cfg_file} @ONLY )
1802 include(FeatureSummary)
1803 set_package_properties(CAP PROPERTIES
1804 DESCRIPTION "The Libcap package implements the user-space interfaces to the POSIX 1003.1e capabilities available in Linux kernels"
1805 URL "https://sites.google.com/site/fullycapable/"
1806 PURPOSE "Allow packet captures without running as root"
1808 set_package_properties(SBC PROPERTIES
1809 DESCRIPTION "Bluetooth low-complexity, subband codec (SBC) decoder"
1810 URL "https://git.kernel.org/pub/scm/bluetooth/sbc.git"
1811 PURPOSE "Support for playing SBC codec in RTP player"
1813 set_package_properties(SPANDSP PROPERTIES
1814 DESCRIPTION "a library of many DSP functions for telephony"
1815 URL "https://www.soft-switch.org"
1816 PURPOSE "Support for G.722 and G.726 codecs in RTP player"
1818 set_package_properties(BCG729 PROPERTIES
1819 DESCRIPTION "G.729 decoder"
1820 URL "https://www.linphone.org/technical-corner/bcg729"
1821 PURPOSE "Support for G.729 codec in RTP player"
1823 set_package_properties(AMRNB PROPERTIES
1824 DESCRIPTION "AMRNB decoder"
1825 URL "https://sourceforge.net/p/opencore-amr"
1826 PURPOSE "Support for AMRNB codec in RTP player"
1828 set_package_properties(ILBC PROPERTIES
1829 DESCRIPTION "iLBC decoder"
1830 URL "https://github.com/TimothyGu/libilbc"
1831 PURPOSE "Support for iLBC codec in RTP player"
1833 set_package_properties(OPUS PROPERTIES
1834 DESCRIPTION "opus decoder"
1835 URL "https://opus-codec.org/"
1836 PURPOSE "Support for opus codec in RTP player"
1838 set_package_properties(LIBXML2 PROPERTIES
1839 DESCRIPTION "XML parsing library"
1840 URL "http://xmlsoft.org/"
1841 PURPOSE "Read XML configuration files in EPL dissector"
1843 set_package_properties(LIBSSH PROPERTIES
1844 DESCRIPTION "Library for implementing SSH clients"
1845 URL "https://www.libssh.org/"
1846 PURPOSE "extcap remote SSH interfaces (sshdump, ciscodump, wifidump)"
1848 set_package_properties(LZ4 PROPERTIES
1849 DESCRIPTION "LZ4 is a fast lossless compression algorithm"
1850 URL "http://www.lz4.org"
1851 PURPOSE "LZ4 decompression in CQL and Kafka dissectors, read compressed capture files"
1853 set_package_properties(SNAPPY PROPERTIES
1854 DESCRIPTION "A fast compressor/decompressor from Google"
1855 URL "https://google.github.io/snappy/"
1856 PURPOSE "Snappy decompression in CQL and Kafka dissectors"
1858 set_package_properties(ZSTD PROPERTIES
1859 DESCRIPTION "A compressor/decompressor from Facebook providing better compression than Snappy at a cost of speed"
1860 URL "https://facebook.github.io/zstd/"
1861 PURPOSE "Zstd decompression in Kafka dissector, read compressed capture files"
1863 set_package_properties(NGHTTP2 PROPERTIES
1864 DESCRIPTION "HTTP/2 C library and tools"
1865 URL "https://nghttp2.org"
1866 PURPOSE "Header decompression in HTTP2"
1868 set_package_properties(CARES PROPERTIES
1869 DESCRIPTION "Library for asynchronous DNS requests"
1870 URL "https://c-ares.org/"
1871 PURPOSE "DNS name resolution for captures"
1873 set_package_properties(Systemd PROPERTIES
1874 URL "https://freedesktop.org/wiki/Software/systemd/"
1875 DESCRIPTION "System and Service Manager (libraries)"
1876 PURPOSE "Support for systemd journal extcap interface (sdjournal)"
1878 set_package_properties(NL PROPERTIES
1879 URL "https://www.infradead.org/~tgr/libnl/"
1880 DESCRIPTION "Libraries for using the Netlink protocol on Linux"
1881 PURPOSE "Support for managing wireless 802.11 interfaces"
1883 set_package_properties(MaxMindDB PROPERTIES
1884 URL "https://github.com/maxmind/libmaxminddb"
1885 DESCRIPTION "C library for the MaxMind DB file format"
1886 PURPOSE "Support for GeoIP lookup"
1888 set_package_properties(SpeexDSP PROPERTIES
1889 URL "https://www.speex.org/"
1890 DESCRIPTION "SpeexDSP is a patent-free, Open Source/Free Software DSP library"
1891 PURPOSE "RTP audio resampling"
1893 set_package_properties(Minizip PROPERTIES
1894 URL "https://github.com/madler/zlib"
1895 DESCRIPTION "Mini zip and unzip based on zlib"
1896 PURPOSE "Support for profiles import/export"
1898 set_package_properties(SMI PROPERTIES
1899 URL "https://www.ibr.cs.tu-bs.de/projects/libsmi/"
1900 DESCRIPTION "Library to access SMI management information"
1901 PURPOSE "Support MIB and PIB parsing and OID resolution"
1903 set_package_properties(PCRE2 PROPERTIES
1904 URL "https://www.pcre.org"
1905 DESCRIPTION "Regular expression pattern matching using the same syntax and semantics as Perl 5"
1906 PURPOSE "Support for regular expressions"
1908 set_package_properties(Sinsp PROPERTIES
1909 DESCRIPTION "libsinsp and libscap"
1910 URL "https://github.com/falcosecurity/libs/"
1911 PURPOSE "Support for Falco plugins"
1914 string(TOUPPER "${CMAKE_BUILD_TYPE}" _build_type)
1915 message(STATUS "C-Flags: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${_build_type}}")
1916 message(STATUS "CXX-Flags: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${_build_type}}")
1917 if(WERROR_COMMON_FLAGS)
1918 message(STATUS "Warnings as errors enabled: ${WERROR_COMMON_FLAGS}")
1920 message(STATUS "Warnings as errors disabled")
1923 feature_summary(WHAT ALL)
1925 # Should this be part of libui?
1928 ui/win32/file_dlg_win32.cpp
1930 set(PLATFORM_UI_RC_FILES
1931 resources/file_dlg_win32.rc
1935 ui/macosx/cocoa_bridge.mm
1938 list(APPEND PLATFORM_UI_SRC ui/macosx/sparkle_bridge.m)
1943 ${CMAKE_SOURCE_DIR}/ui/cli/tap-credentials.c
1944 ${CMAKE_SOURCE_DIR}/ui/cli/tap-camelsrt.c
1945 ${CMAKE_SOURCE_DIR}/ui/cli/tap-diameter-avp.c
1946 ${CMAKE_SOURCE_DIR}/ui/cli/tap-expert.c
1947 ${CMAKE_SOURCE_DIR}/ui/cli/tap-exportobject.c
1948 ${CMAKE_SOURCE_DIR}/ui/cli/tap-endpoints.c
1949 ${CMAKE_SOURCE_DIR}/ui/cli/tap-flow.c
1950 ${CMAKE_SOURCE_DIR}/ui/cli/tap-follow.c
1951 ${CMAKE_SOURCE_DIR}/ui/cli/tap-funnel.c
1952 ${CMAKE_SOURCE_DIR}/ui/cli/tap-gsm_astat.c
1953 ${CMAKE_SOURCE_DIR}/ui/cli/tap-hosts.c
1954 ${CMAKE_SOURCE_DIR}/ui/cli/tap-httpstat.c
1955 ${CMAKE_SOURCE_DIR}/ui/cli/tap-icmpstat.c
1956 ${CMAKE_SOURCE_DIR}/ui/cli/tap-icmpv6stat.c
1957 ${CMAKE_SOURCE_DIR}/ui/cli/tap-iostat.c
1958 ${CMAKE_SOURCE_DIR}/ui/cli/tap-iousers.c
1959 ${CMAKE_SOURCE_DIR}/ui/cli/tap-macltestat.c
1960 ${CMAKE_SOURCE_DIR}/ui/cli/tap-protocolinfo.c
1961 ${CMAKE_SOURCE_DIR}/ui/cli/tap-protohierstat.c
1962 ${CMAKE_SOURCE_DIR}/ui/cli/tap-rlcltestat.c
1963 ${CMAKE_SOURCE_DIR}/ui/cli/tap-rpcprogs.c
1964 ${CMAKE_SOURCE_DIR}/ui/cli/tap-rtd.c
1965 ${CMAKE_SOURCE_DIR}/ui/cli/tap-rtp.c
1966 ${CMAKE_SOURCE_DIR}/ui/cli/tap-rtspstat.c
1967 ${CMAKE_SOURCE_DIR}/ui/cli/tap-sctpchunkstat.c
1968 ${CMAKE_SOURCE_DIR}/ui/cli/tap-simple_stattable.c
1969 ${CMAKE_SOURCE_DIR}/ui/cli/tap-sipstat.c
1970 ${CMAKE_SOURCE_DIR}/ui/cli/tap-smbsids.c
1971 ${CMAKE_SOURCE_DIR}/ui/cli/tap-srt.c
1972 ${CMAKE_SOURCE_DIR}/ui/cli/tap-stats_tree.c
1973 ${CMAKE_SOURCE_DIR}/ui/cli/tap-sv.c
1974 ${CMAKE_SOURCE_DIR}/ui/cli/tap-wspstat.c
1975 ${CUSTOM_TSHARK_TAP_SRC}
1979 # Installed into ${DATAFILE_DIR}
1981 resources/share/wireshark/profiles
1982 resources/protocols/diameter
1983 resources/protocols/dtds
1984 resources/protocols/radius
1985 resources/protocols/tpncp
1986 resources/protocols/wimaxasncp
1989 # Installed into ${DATAFILE_DIR}
1993 resources/share/wireshark/cfilters
1994 resources/share/wireshark/colorfilters
1995 resources/share/wireshark/dfilter_macros
1996 resources/share/wireshark/dfilters
1997 resources/share/wireshark/smi_modules
2002 resources/share/doc/wireshark/ipmap.html
2003 resources/share/doc/wireshark/pdml2html.xsl
2004 doc/README.xml-output
2009 set(LOG_INSTALL_FILES
2011 resources/share/logray/colorfilters
2012 resources/share/logray/dfilter_buttons
2016 if (ASCIIDOCTOR_FOUND)
2017 list(APPEND DOC_FILES
2018 ${CMAKE_BINARY_DIR}/doc/androiddump.html
2019 ${CMAKE_BINARY_DIR}/doc/udpdump.html
2020 ${CMAKE_BINARY_DIR}/doc/capinfos.html
2021 ${CMAKE_BINARY_DIR}/doc/captype.html
2022 ${CMAKE_BINARY_DIR}/doc/ciscodump.html
2023 ${CMAKE_BINARY_DIR}/doc/dumpcap.html
2024 ${CMAKE_BINARY_DIR}/doc/editcap.html
2025 ${CMAKE_BINARY_DIR}/doc/extcap.html
2026 ${CMAKE_BINARY_DIR}/doc/mergecap.html
2027 ${CMAKE_BINARY_DIR}/doc/randpkt.html
2028 ${CMAKE_BINARY_DIR}/doc/randpktdump.html
2029 ${CMAKE_BINARY_DIR}/doc/etwdump.html
2030 ${CMAKE_BINARY_DIR}/doc/rawshark.html
2031 ${CMAKE_BINARY_DIR}/doc/reordercap.html
2032 ${CMAKE_BINARY_DIR}/doc/sshdump.html
2033 ${CMAKE_BINARY_DIR}/doc/wifidump.html
2034 ${CMAKE_BINARY_DIR}/doc/text2pcap.html
2035 ${CMAKE_BINARY_DIR}/doc/tshark.html
2036 ${CMAKE_BINARY_DIR}/doc/wireshark.html
2037 ${CMAKE_BINARY_DIR}/doc/wireshark-filter.html
2040 list(APPEND DOC_FILES ${CMAKE_BINARY_DIR}/doc/mmdbresolve.html)
2043 if (BUILD_corbaidl2wrs)
2044 list(APPEND DOC_FILES ${CMAKE_BINARY_DIR}/doc/idl2wrs.html)
2047 list(APPEND DOC_FILES
2048 ${CMAKE_BINARY_DIR}/doc/asn2deb.html
2049 ${CMAKE_BINARY_DIR}/doc/idl2deb.html
2053 list(APPEND DOC_FILES
2054 ${CMAKE_BINARY_DIR}/doc/falcodump.html
2060 # We do this for Windows further down in the copy_data_files target.
2061 list(APPEND DOC_FILES COPYING)
2065 set(_dll_output_dir "$<TARGET_FILE_DIR:wsutil>")
2066 add_custom_target(copy_cli_dlls)
2067 set_target_properties(copy_cli_dlls PROPERTIES FOLDER "Copy Tasks")
2068 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
2069 COMMAND ${CMAKE_COMMAND} -E make_directory "${_dll_output_dir}"
2072 # XXX Can (and should) we iterate over these similar to the way
2073 # the top-level CMakeLists.txt iterates over the package list?
2075 # Required DLLs and their corresponding PDBs.
2076 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
2077 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2078 "$<IF:$<CONFIG:Debug>,${GLIB2_DLLS_DEBUG},${GLIB2_DLLS_RELEASE}>"
2079 "$<IF:$<CONFIG:Debug>,${GLIB2_PDBS_DEBUG},${GLIB2_PDBS_RELEASE}>"
2080 "${_dll_output_dir}"
2081 WORKING_DIRECTORY $<IF:$<CONFIG:Debug>,${GLIB2_DLL_DIR_DEBUG},${GLIB2_DLL_DIR_RELEASE}>
2082 COMMAND_EXPAND_LISTS
2085 if (MSVC AND VLD_FOUND)
2086 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
2087 COMMAND ${CMAKE_COMMAND} -E "$<IF:$<CONFIG:Debug>,copy_if_different,true>"
2089 "${_dll_output_dir}"
2090 COMMAND_EXPAND_LISTS
2094 # Third party DLLs and PDBs.
2095 set (THIRD_PARTY_DLLS)
2096 set (THIRD_PARTY_PDBS)
2098 list (APPEND THIRD_PARTY_DLLS "${AIRPCAP_DLL_DIR}/${AIRPCAP_DLL}")
2099 endif(AIRPCAP_FOUND)
2100 list (APPEND THIRD_PARTY_DLLS "${CARES_DLL_DIR}/${CARES_DLL}")
2101 list (APPEND THIRD_PARTY_PDBS "${CARES_DLL_DIR}/${CARES_PDB}")
2102 # vcpkg's libmaxminddb is static-only for now. This can be uncommented when
2103 # https://github.com/maxmind/libmaxminddb/commit/3998f42bdb6678cbaa1a543057e5c81ba1668ac2
2104 # percolates up to vcpkg.
2105 # if (MAXMINDDB_FOUND)
2106 # list (APPEND THIRD_PARTY_DLLS "${MAXMINDDB_DLL_DIR}/${MAXMINDDB_DLL}")
2107 # endif(MAXMINDDB_FOUND)
2109 foreach( _dll ${LIBSSH_DLLS} )
2110 list (APPEND THIRD_PARTY_DLLS "${LIBSSH_DLL_DIR}/${_dll}")
2113 foreach( _dll ${GCRYPT_DLLS} )
2114 list (APPEND THIRD_PARTY_DLLS "${GCRYPT_DLL_DIR}/${_dll}")
2116 foreach( _dll ${GNUTLS_DLLS} )
2117 list (APPEND THIRD_PARTY_DLLS "${GNUTLS_DLL_DIR}/${_dll}")
2119 foreach( _dll ${KERBEROS_DLLS} )
2120 list (APPEND THIRD_PARTY_DLLS "${KERBEROS_DLL_DIR}/${_dll}")
2123 list (APPEND THIRD_PARTY_DLLS "${LUA_DLL_DIR}/${LUA_DLL}")
2126 list (APPEND THIRD_PARTY_DLLS "${LZ4_DLL_DIR}/${LZ4_DLL}")
2127 list (APPEND THIRD_PARTY_PDBS "${LZ4_DLL_DIR}/${LZ4_PDB}")
2130 list (APPEND THIRD_PARTY_DLLS "${ZSTD_DLL_DIR}/${ZSTD_DLL}")
2133 list (APPEND THIRD_PARTY_DLLS "${NGHTTP2_DLL_DIR}/${NGHTTP2_DLL}")
2134 list (APPEND THIRD_PARTY_PDBS "${NGHTTP2_DLL_DIR}/${NGHTTP2_PDB}")
2135 endif(NGHTTP2_FOUND)
2137 list (APPEND THIRD_PARTY_DLLS "${PCRE2_DLL_DIR}/${PCRE2_DLL}")
2138 list (APPEND THIRD_PARTY_PDBS "${PCRE2_DLL_DIR}/${PCRE2_PDB}")
2141 list (APPEND THIRD_PARTY_DLLS "${SBC_DLL_DIR}/${SBC_DLL}")
2144 list (APPEND THIRD_PARTY_DLLS "${SPANDSP_DLL_DIR}/${SPANDSP_DLL}")
2145 endif(SPANDSP_FOUND)
2147 list (APPEND THIRD_PARTY_DLLS "${BCG729_DLL_DIR}/${BCG729_DLL}")
2150 list (APPEND OPTIONAL_DLLS "${AMRNB_DLL_DIR}/${AMRNB_DLL}")
2153 list (APPEND THIRD_PARTY_DLLS "${ILBC_DLL_DIR}/${ILBC_DLL}")
2156 list (APPEND THIRD_PARTY_DLLS "${OPUS_DLL_DIR}/${OPUS_DLL}")
2159 foreach( _dll ${LIBXML2_DLLS} )
2160 list (APPEND THIRD_PARTY_DLLS "${LIBXML2_DLL_DIR}/${_dll}")
2162 foreach( _pdb ${LIBXML2_PDBS} )
2163 list (APPEND THIRD_PARTY_PDBS "${LIBXML2_DLL_DIR}/${_pdb}")
2165 endif(LIBXML2_FOUND)
2167 list (APPEND THIRD_PARTY_DLLS "${SMI_DLL_DIR}/${SMI_DLL}")
2168 # Wireshark.nsi wants SMI_DIR which is the base SMI directory
2169 get_filename_component(SMI_DIR ${SMI_DLL_DIR} DIRECTORY)
2170 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
2171 COMMAND ${CMAKE_COMMAND} -E make_directory
2172 "${_dll_output_dir}/snmp"
2173 COMMAND ${CMAKE_COMMAND} -E make_directory
2174 "${_dll_output_dir}/snmp/mibs"
2175 COMMAND ${CMAKE_COMMAND} -E copy_directory
2176 "${SMI_SHARE_DIR}/mibs/iana"
2177 "${_dll_output_dir}/snmp/mibs"
2178 COMMAND ${CMAKE_COMMAND} -E copy_directory
2179 "${SMI_SHARE_DIR}/mibs/ietf"
2180 "${_dll_output_dir}/snmp/mibs"
2181 COMMAND ${CMAKE_COMMAND} -E copy_directory
2182 "${SMI_SHARE_DIR}/mibs/irtf"
2183 "${_dll_output_dir}/snmp/mibs"
2184 COMMAND ${CMAKE_COMMAND} -E copy_directory
2185 "${SMI_SHARE_DIR}/mibs/site"
2186 "${_dll_output_dir}/snmp/mibs"
2187 COMMAND ${CMAKE_COMMAND} -E copy_directory
2188 "${SMI_SHARE_DIR}/mibs/tubs"
2189 "${_dll_output_dir}/snmp/mibs"
2190 COMMAND ${CMAKE_COMMAND} -E copy_directory
2191 "${SMI_SHARE_DIR}/pibs"
2192 "${_dll_output_dir}/snmp/mibs"
2193 COMMAND ${CMAKE_COMMAND} -E copy_directory
2194 "${SMI_SHARE_DIR}/yang"
2195 "${_dll_output_dir}/snmp/mibs"
2196 #remove the extra directories copied (shallow copying the above would remove the need for this)
2197 COMMAND ${CMAKE_COMMAND} -E remove_directory
2198 "${_dll_output_dir}/snmp/mibs/iana"
2199 COMMAND ${CMAKE_COMMAND} -E remove_directory
2200 "${_dll_output_dir}/snmp/mibs/ietf"
2201 COMMAND ${CMAKE_COMMAND} -E remove_directory
2202 "${_dll_output_dir}/snmp/mibs/site"
2203 COMMAND ${CMAKE_COMMAND} -E remove_directory
2204 "${_dll_output_dir}/snmp/mibs/tubs"
2208 list (APPEND THIRD_PARTY_DLLS "${SNAPPY_DLL_DIR}/${SNAPPY_DLL}")
2210 if (WINSPARKLE_FOUND)
2211 list (APPEND THIRD_PARTY_DLLS "${WINSPARKLE_DLL_DIR}/${WINSPARKLE_DLL}")
2212 endif(WINSPARKLE_FOUND)
2214 list (APPEND THIRD_PARTY_DLLS "${ZLIB_DLL_DIR}/${ZLIB_DLL}")
2215 list (APPEND THIRD_PARTY_PDBS "${ZLIB_DLL_DIR}/${ZLIB_PDB}")
2218 foreach( _dll ${BROTLI_DLLS} )
2219 list (APPEND THIRD_PARTY_DLLS "${BROTLI_DLL_DIR}/${_dll}")
2223 list (APPEND THIRD_PARTY_DLLS "${SPEEXDSP_DLL_DIR}/${SPEEXDSP_DLL}")
2226 # With libs downloaded to c:/wireshark-win64-libs this currently
2227 # (early 2018) expands to about 1900 characters.
2228 if (THIRD_PARTY_DLLS)
2229 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
2230 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2232 "${_dll_output_dir}"
2235 install(FILES ${THIRD_PARTY_DLLS} DESTINATION "${CMAKE_INSTALL_BINDIR}")
2236 endif(THIRD_PARTY_DLLS)
2238 if (THIRD_PARTY_PDBS)
2239 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
2240 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2242 "${_dll_output_dir}"
2245 endif(THIRD_PARTY_PDBS)
2247 add_dependencies(epan copy_cli_dlls)
2249 # We have a lot of choices for creating zip archives:
2250 # - 7z, WinZip, etc., which require a separate download+install.
2251 # - "CMake -E tar cz", which creates a tar file.
2252 # - CPack, which requires a CPack configuration.
2253 # - PowerShell via PSCX or System.IO.Compression.FileSystem.
2254 # - Python via zipfile.
2255 # For now, just look for 7z. It's installed on the Windows builders,
2256 # which might be the only systems that use this target.
2257 find_program(ZIP_EXECUTABLE 7z
2258 PATH "$ENV{PROGRAMFILES}/7-Zip" "$ENV{PROGRAMW6432}/7-Zip"
2259 DOC "Path to the 7z utility."
2262 add_custom_target(pdb_zip_package COMMENT "This packages .PDBs but will not create them.")
2263 set_target_properties(pdb_zip_package PROPERTIES FOLDER "Packaging")
2264 set(_pdb_zip "${CMAKE_BINARY_DIR}/Wireshark-pdb-${PROJECT_VERSION}-${WIRESHARK_TARGET_PROCESSOR_ARCHITECTURE}.zip")
2265 file(TO_NATIVE_PATH "${_pdb_zip}" _pdb_zip_win)
2266 add_custom_command(TARGET pdb_zip_package POST_BUILD
2267 COMMAND ${CMAKE_COMMAND} -E remove -f "${_pdb_zip}"
2268 COMMAND ${ZIP_EXECUTABLE} a -tzip -mmt=on "${_pdb_zip_win}"
2271 WORKING_DIRECTORY "${_dll_output_dir}"
2276 # List of extra dependencies for the "copy_data_files" target
2277 set(copy_data_files_depends)
2280 foreach(_install_as_txt_file COPYING NEWS README.md README.windows)
2281 # On Windows, install some files with a .txt extension so that they're
2283 string(REGEX REPLACE ".md$" "" _no_md_file ${_install_as_txt_file})
2284 set(_output_file "${DATAFILE_DIR}/${_no_md_file}.txt")
2285 add_custom_command(OUTPUT ${_output_file}
2286 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2287 ${CMAKE_SOURCE_DIR}/${_install_as_txt_file}
2290 ${CMAKE_SOURCE_DIR}/${_install_as_txt_file}
2292 list(APPEND copy_data_files_depends "${_output_file}")
2296 foreach(_install_file ${INSTALL_FILES} ${DOC_FILES})
2297 get_filename_component(_install_file_src "${_install_file}" ABSOLUTE)
2298 get_filename_component(_install_basename "${_install_file}" NAME)
2299 set(_output_file "${DATAFILE_DIR}/${_install_basename}")
2300 add_custom_command(OUTPUT "${_output_file}"
2301 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2302 "${_install_file_src}"
2308 list(APPEND copy_data_files_depends "${_output_file}")
2311 if (BUILD_logray AND ENABLE_APPLICATION_BUNDLE)
2312 foreach(_install_file ${LOG_INSTALL_FILES})
2313 get_filename_component(_install_file_src "${_install_file}" ABSOLUTE)
2314 get_filename_component(_install_basename "${_install_file}" NAME)
2315 set(_output_file "${LOG_DATAFILE_DIR}/${_install_basename}")
2316 add_custom_command(OUTPUT "${_output_file}"
2317 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2318 "${_install_file_src}"
2324 list(APPEND copy_data_files_depends "${_output_file}")
2328 # Install Lua files in staging directory such that Lua can used when Wireshark
2329 # is ran from the build directory. For install targets, see
2330 # epan/wslua/CMakeLists.txt
2331 if(LUA_FOUND AND ENABLE_LUA)
2333 "${CMAKE_SOURCE_DIR}/epan/wslua/init.lua"
2334 "${CMAKE_SOURCE_DIR}/epan/wslua/console.lua"
2335 "${CMAKE_SOURCE_DIR}/epan/wslua/dtd_gen.lua"
2337 foreach(_lua_file ${_lua_files})
2338 get_filename_component(_lua_filename "${_lua_file}" NAME)
2339 list(APPEND copy_data_files_depends
2340 "${DATAFILE_DIR}/${_lua_filename}")
2341 add_custom_command(OUTPUT "${DATAFILE_DIR}/${_lua_filename}"
2342 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2344 "${DATAFILE_DIR}/${_lua_filename}"
2349 endif(LUA_FOUND AND ENABLE_LUA)
2350 # doc/*.html handled elsewhere.
2352 set(_protocol_data_dir ${CMAKE_SOURCE_DIR}/resources/protocols)
2353 # Glob patterns relative to the source directory that should be copied to
2354 # ${DATAFILE_DIR} (including directory prefixes)
2355 # TODO shouldn't this use full (relative) paths instead of glob patterns?
2357 ${_protocol_data_dir}/tpncp/tpncp.dat
2358 ${_protocol_data_dir}/wimaxasncp/*.dtd
2359 ${_protocol_data_dir}/wimaxasncp/*.xml
2362 # Copy all paths from the source tree to the data directory. Directories are
2363 # automatically created if missing as the filename is given.
2364 file(GLOB _data_files RELATIVE ${_protocol_data_dir} ${DATA_FILES_SRC})
2365 foreach(_data_file ${_data_files})
2366 add_custom_command(OUTPUT "${DATAFILE_DIR}/${_data_file}"
2367 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2368 ${_protocol_data_dir}/${_data_file}
2369 ${DATAFILE_DIR}/${_data_file}
2371 ${_protocol_data_dir}/${_data_file}
2373 list(APPEND copy_data_files_depends ${DATAFILE_DIR}/${_data_file})
2376 file(GLOB _dtds_src_files RELATIVE ${_protocol_data_dir} ${_protocol_data_dir}/dtds/*.dtd)
2378 set (_dtds_data_files)
2379 set (_dtds_dep_files)
2380 foreach(_data_file ${_dtds_src_files})
2381 list(APPEND _dtds_data_files ${DATAFILE_DIR}/${_data_file})
2382 list(APPEND _dtds_dep_files ${_protocol_data_dir}/${_data_file})
2386 OUTPUT ${_dtds_data_files}
2387 COMMAND ${CMAKE_COMMAND} -E make_directory ${DATAFILE_DIR}/dtds
2388 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2390 ${DATAFILE_DIR}/dtds
2392 DEPENDS ${_dtds_dep_files}
2393 WORKING_DIRECTORY ${_protocol_data_dir}
2396 file(GLOB _diameter_src_files RELATIVE ${_protocol_data_dir}
2397 ${_protocol_data_dir}/diameter/*.dtd
2398 ${_protocol_data_dir}/diameter/*.xml
2401 set (_diameter_data_files)
2402 set (_diameter_dep_files)
2403 foreach(_data_file ${_diameter_src_files})
2404 list(APPEND _diameter_data_files ${DATAFILE_DIR}/${_data_file})
2405 list(APPEND _diameter_dep_files ${_protocol_data_dir}/${_data_file})
2409 OUTPUT ${_diameter_data_files}
2410 COMMAND ${CMAKE_COMMAND} -E make_directory ${DATAFILE_DIR}/diameter
2411 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2412 ${_diameter_src_files}
2413 ${DATAFILE_DIR}/diameter
2415 DEPENDS ${_diameter_dep_files}
2416 WORKING_DIRECTORY ${_protocol_data_dir}
2419 file(GLOB _radius_src_files RELATIVE ${_protocol_data_dir}
2420 ${_protocol_data_dir}/radius/README.radius_dictionary
2421 ${_protocol_data_dir}/radius/custom.includes
2422 ${_protocol_data_dir}/radius/dictionary
2423 ${_protocol_data_dir}/radius/dictionary.*
2426 set (_radius_data_files)
2427 set (_radius_dep_files)
2428 foreach(_data_file ${_radius_src_files})
2429 list(APPEND _radius_data_files ${DATAFILE_DIR}/${_data_file})
2430 list(APPEND _radius_dep_files ${_protocol_data_dir}/${_data_file})
2434 OUTPUT ${_radius_data_files}
2435 COMMAND ${CMAKE_COMMAND} -E make_directory ${DATAFILE_DIR}/radius
2436 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2437 ${_radius_src_files}
2438 ${DATAFILE_DIR}/radius
2440 DEPENDS ${_radius_dep_files}
2441 WORKING_DIRECTORY ${_protocol_data_dir}
2444 file(GLOB _protobuf_src_files RELATIVE ${_protocol_data_dir}
2445 ${_protocol_data_dir}/protobuf/*.proto
2447 set (_protobuf_data_files)
2448 set (_protobuf_dep_files)
2449 foreach(_data_file ${_protobuf_src_files})
2450 list(APPEND _protobuf_data_files ${DATAFILE_DIR}/${_data_file})
2451 list(APPEND _protobuf_dep_files ${_protocol_data_dir}/${_data_file})
2455 OUTPUT ${_protobuf_data_files}
2456 COMMAND ${CMAKE_COMMAND} -E make_directory ${DATAFILE_DIR}/protobuf
2457 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2458 ${_protobuf_src_files}
2459 ${DATAFILE_DIR}/protobuf
2461 DEPENDS ${_protobuf_dep_files}
2462 WORKING_DIRECTORY ${_protocol_data_dir}
2465 set(_profiles_src_dir ${CMAKE_SOURCE_DIR}/resources/share/wireshark)
2466 file(GLOB _profiles_src_files RELATIVE ${_profiles_src_dir} ${_profiles_src_dir}/profiles/*/*)
2467 set (_profiles_data_files)
2468 foreach(_data_file ${_profiles_src_files})
2469 list(APPEND _profiles_data_files "${DATAFILE_DIR}/${_data_file}")
2473 OUTPUT ${_profiles_data_files}
2474 COMMAND ${CMAKE_COMMAND} -E copy_directory
2475 "${CMAKE_SOURCE_DIR}/resources/share/wireshark/profiles" "${DATAFILE_DIR}/profiles"
2478 list(APPEND copy_data_files_depends
2480 ${_diameter_data_files}
2481 ${_radius_data_files}
2482 ${_protobuf_data_files}
2483 ${_profiles_data_files}
2486 # Copy files including ${INSTALL_FILES} and ${INSTALL_DIRS} to ${DATAFILE_DIR}
2487 add_custom_target(copy_data_files ALL DEPENDS ${copy_data_files_depends} )
2488 set_target_properties(copy_data_files PROPERTIES FOLDER "Copy Tasks")
2490 # sources common for wireshark, tshark, rawshark and sharkd
2491 add_library(shark_common OBJECT
2494 file_packet_provider.c
2498 add_library(cli_main OBJECT cli_main.c)
2499 add_library(capture_opts OBJECT capture_opts.c)
2500 target_include_directories(capture_opts SYSTEM PRIVATE ${PCAP_INCLUDE_DIRS})
2501 set_target_properties(shark_common cli_main capture_opts
2503 COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
2507 if(BUILD_wireshark AND QT_FOUND)
2515 $<TARGET_OBJECTS:capture_opts>
2516 $<TARGET_OBJECTS:qtui>
2517 $<TARGET_OBJECTS:shark_common>
2519 ${PLATFORM_UI_RC_FILES}
2521 set_executable_resources(wireshark "Wireshark" UNIQUE_RC)
2524 if(BUILD_logray AND QT_FOUND)
2532 $<TARGET_OBJECTS:capture_opts>
2533 $<TARGET_OBJECTS:ui_logray>
2534 $<TARGET_OBJECTS:shark_common>
2536 ${PLATFORM_UI_RC_FILES}
2538 set_executable_resources(logray "Logray" UNIQUE_RC)
2541 if(ENABLE_APPLICATION_BUNDLE)
2543 # Add -Wl,-single_module to the LDFLAGS used with shared
2544 # libraries, to fix some error that show up in some cases;
2545 # some Apple documentation recommends it for most shared
2548 set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-single_module ${CMAKE_SHARED_LINKER_FLAGS}" )
2550 # Add -Wl,-headerpad_max_install_names to the LDFLAGS, as
2551 # code-signing issues is running out of padding space.
2553 # Add -Wl,-search_paths_first to make sure that if we search
2554 # directories A and B, in that order, for a given library, a
2555 # non-shared version in directory A, rather than a shared
2556 # version in directory B, is chosen (so we can use
2557 # --with-pcap=/usr/local to force all programs to be linked
2558 # with a static version installed in /usr/local/lib rather than
2559 # the system version in /usr/lib).
2562 set(CMAKE_EXE_LINKER_FLAGS
2563 "-Wl,-headerpad_max_install_names -Wl,-search_paths_first ${CMAKE_EXE_LINKER_FLAGS}"
2566 # Add files to the Wireshark application bundle
2567 # Wireshark.app/Contents
2568 file(WRITE ${CMAKE_BINARY_DIR}/packaging/macosx/wireshark/PkgInfo "APPLWshk\n")
2569 set(WIRESHARK_BUNDLE_CONTENTS_FILES
2570 ${CMAKE_BINARY_DIR}/packaging/macosx/wireshark/PkgInfo
2572 set_source_files_properties(${WIRESHARK_BUNDLE_CONTENTS_FILES} PROPERTIES
2573 MACOSX_PACKAGE_LOCATION .
2576 # Wireshark.app/Contents/Resources
2577 set(WIRESHARK_BUNDLE_RESOURCE_FILES
2578 ${CMAKE_SOURCE_DIR}/packaging/macosx/Wireshark.icns
2579 ${CMAKE_SOURCE_DIR}/packaging/macosx/Wiresharkdoc.icns
2581 set_source_files_properties(${WIRESHARK_BUNDLE_RESOURCE_FILES} PROPERTIES
2582 MACOSX_PACKAGE_LOCATION Resources
2585 # Wireshark.app/Contents/Resources/share/man/man1
2586 set_source_files_properties(${WIRESHARK_BUNDLE_RESOURCE_SHARE_MAN1_FILES} PROPERTIES
2587 MACOSX_PACKAGE_LOCATION Resources/share/man/man1
2591 # Wireshark.app/Contents/Resources/share/man/man4
2592 set_source_files_properties(${WIRESHARK_BUNDLE_RESOURCE_SHARE_MAN4_FILES} PROPERTIES
2593 MACOSX_PACKAGE_LOCATION Resources/share/man/man4
2597 # INSTALL_FILES and INSTALL_DIRS are handled by copy_data_files
2599 set(EXTRA_WIRESHARK_BUNDLE_FILES
2600 ${WIRESHARK_BUNDLE_CONTENTS_FILES}
2601 ${WIRESHARK_BUNDLE_RESOURCE_FILES}
2602 ${WIRESHARK_BUNDLE_RESOURCE_SHARE_MAN1_FILES}
2603 ${WIRESHARK_BUNDLE_RESOURCE_SHARE_MAN4_FILES}
2606 # Add files to the Logray application bundle
2607 # Logray.app/Contents
2608 file(WRITE ${CMAKE_BINARY_DIR}/packaging/macosx/logray/PkgInfo "APPLLgry\n")
2609 set(LOGRAY_BUNDLE_CONTENTS_FILES
2610 ${CMAKE_BINARY_DIR}/packaging/macosx/logray/PkgInfo
2612 set_source_files_properties(${LOGRAY_BUNDLE_CONTENTS_FILES} PROPERTIES
2613 MACOSX_PACKAGE_LOCATION .
2616 # Logray.app/Contents/Resources
2617 set(LOGRAY_BUNDLE_RESOURCE_FILES
2618 ${CMAKE_SOURCE_DIR}/packaging/macosx/Logray.icns
2619 ${CMAKE_SOURCE_DIR}/packaging/macosx/Wiresharkdoc.icns
2621 set_source_files_properties(${LOGRAY_BUNDLE_RESOURCE_FILES} PROPERTIES
2622 MACOSX_PACKAGE_LOCATION Resources
2625 # Logray.app/Contents/Resources/share/man/man1
2626 set_source_files_properties(${LOGRAY_BUNDLE_RESOURCE_SHARE_MAN1_FILES} PROPERTIES
2627 MACOSX_PACKAGE_LOCATION Resources/share/man/man1
2631 # Logray.app/Contents/Resources/share/man/man4
2632 set_source_files_properties(${LOGRAY_BUNDLE_RESOURCE_SHARE_MAN4_FILES} PROPERTIES
2633 MACOSX_PACKAGE_LOCATION Resources/share/man/man4
2637 # INSTALL_FILES and INSTALL_DIRS are handled by copy_data_files
2639 set(EXTRA_LOGRAY_BUNDLE_FILES
2640 ${LOGRAY_BUNDLE_CONTENTS_FILES}
2641 ${LOGRAY_BUNDLE_RESOURCE_FILES}
2642 ${LOGRAY_BUNDLE_RESOURCE_SHARE_MAN1_FILES}
2643 ${LOGRAY_BUNDLE_RESOURCE_SHARE_MAN4_FILES}
2647 set(EXTRA_WIRESHARK_BUNDLE_FILES)
2648 set(EXTRA_LOGRAY_BUNDLE_FILES)
2651 if(BUILD_wireshark AND QT_FOUND)
2661 ${APPLE_APPLICATION_SERVICES_LIBRARY}
2662 ${APPLE_APPKIT_LIBRARY}
2663 ${APPLE_CORE_FOUNDATION_LIBRARY}
2664 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
2665 ${SPARKLE_LIBRARIES}
2666 ${WIN_WS2_32_LIBRARY}
2667 ${WIN_VERSION_LIBRARY}
2668 ${WINSPARKLE_LIBRARIES}
2669 $<$<BOOL:${WIN32}>:uxtheme.lib>
2670 ${SPEEXDSP_LIBRARIES}
2672 ${MINIZIP_LIBRARIES}
2675 add_executable(wireshark WIN32 MACOSX_BUNDLE ${wireshark_FILES} ${EXTRA_WIRESHARK_BUNDLE_FILES})
2677 set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT wireshark)
2679 set(PROGLIST ${PROGLIST} wireshark)
2680 set_target_properties(wireshark PROPERTIES
2681 LINK_FLAGS "${WS_LINK_FLAGS}"
2682 FOLDER "Executables"
2683 INSTALL_RPATH "${EXECUTABLE_INSTALL_RPATH}"
2689 set_target_properties(wireshark PROPERTIES LINK_FLAGS_DEBUG "${WS_MSVC_DEBUG_LINK_FLAGS}")
2692 set_target_properties(wireshark PROPERTIES OUTPUT_NAME wireshark)
2693 elseif(ENABLE_APPLICATION_BUNDLE OR WIN32)
2694 set_target_properties(wireshark PROPERTIES OUTPUT_NAME Wireshark)
2697 if(ENABLE_APPLICATION_BUNDLE)
2698 if(ASCIIDOCTOR_FOUND)
2699 # Make sure to generate files referenced by
2700 # WIRESHARK_BUNDLE_RESOURCE_SHARE_MAN1_FILES
2701 add_dependencies(wireshark manpages)
2703 set_target_properties(
2704 wireshark PROPERTIES
2705 MACOSX_BUNDLE_INFO_PLIST ${CMAKE_BINARY_DIR}/packaging/macosx/WiresharkInfo.plist
2707 if(CMAKE_CFG_INTDIR STREQUAL ".")
2708 # Add a wrapper script which opens the bundle. This is more convenient
2709 # and lets Sparkle find our CFBundleIdentifier, but means that you have
2710 # to pass the full path to run/Wireshark.app/Contents/MacOS/Wireshark
2712 # It is not created if using Xcode
2713 file(REMOVE ${CMAKE_BINARY_DIR}/run/wireshark)
2714 file(WRITE ${CMAKE_BINARY_DIR}/run/wireshark "#!/bin/sh\n")
2715 file(APPEND ${CMAKE_BINARY_DIR}/run/wireshark "# Generated by ${CMAKE_CURRENT_LIST_FILE}\n")
2716 file(APPEND ${CMAKE_BINARY_DIR}/run/wireshark "# Wrapper script which ensures that we're properly activated via Launch Services\n")
2717 file(APPEND ${CMAKE_BINARY_DIR}/run/wireshark "exec ${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/MacOS/Wireshark \"\$\@\"\n")
2718 execute_process(COMMAND chmod a+x ${CMAKE_BINARY_DIR}/run/wireshark)
2722 target_link_libraries(wireshark ${wireshark_LIBS})
2723 target_include_directories(wireshark SYSTEM PRIVATE ${SPARKLE_INCLUDE_DIRS})
2727 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
2728 BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
2731 if(QT_WINDEPLOYQT_EXECUTABLE)
2732 add_custom_target(copy_qt_dlls ALL)
2733 set_target_properties(copy_qt_dlls PROPERTIES FOLDER "Copy Tasks")
2734 # Will we ever need to use --debug? Windeployqt seems to
2735 # be smart enough to copy debug DLLs when needed.
2736 if (USE_MSYSTEM AND Qt${qtver}Widgets_VERSION VERSION_EQUAL 6.5.0)
2737 # windeployqt released with Qt 6.5.0 is broken.
2738 # https://bugreports.qt.io/browse/QTBUG-112204
2739 message(WARNING "Qt Deploy Tool 6.5.0 is broken, skipping translations.")
2740 list(APPEND QT_WINDEPLOYQT_EXTRA_ARGS --no-translations)
2741 set(SKIP_QT_TRANSLATIONS True)
2743 add_custom_command(TARGET copy_qt_dlls
2745 COMMAND set "PATH=${QT_BIN_PATH};%PATH%"
2746 COMMAND "${QT_WINDEPLOYQT_EXECUTABLE}"
2747 ${QT_WINDEPLOYQT_EXTRA_ARGS}
2748 --no-compiler-runtime
2750 $<$<BOOL:${MSVC}>:--pdb>
2751 "$<TARGET_FILE:wireshark>"
2753 add_dependencies(copy_qt_dlls wireshark)
2755 install(CODE "execute_process(COMMAND
2756 \"${QT_WINDEPLOYQT_EXECUTABLE}\"
2757 --no-compiler-runtime
2758 \"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/Wireshark.exe\")"
2761 endif(QT_WINDEPLOYQT_EXECUTABLE)
2764 if(BUILD_logray AND QT_FOUND)
2774 ${APPLE_APPLICATION_SERVICES_LIBRARY}
2775 ${APPLE_APPKIT_LIBRARY}
2776 ${APPLE_CORE_FOUNDATION_LIBRARY}
2777 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
2778 ${SPARKLE_LIBRARIES}
2779 ${WIN_WS2_32_LIBRARY}
2780 ${WIN_VERSION_LIBRARY}
2781 ${WINSPARKLE_LIBRARIES}
2782 $<$<BOOL:${WIN32}>:uxtheme.lib>
2783 ${SPEEXDSP_LIBRARIES}
2785 ${MINIZIP_LIBRARIES}
2788 add_executable(logray WIN32 MACOSX_BUNDLE ${logray_FILES} ${EXTRA_LOGRAY_BUNDLE_FILES})
2789 if(WIN32 AND NOT BUILD_wireshark)
2790 set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT logray)
2792 set(PROGLIST ${PROGLIST} logray)
2793 set_target_properties(logray PROPERTIES
2794 LINK_FLAGS "${WS_LINK_FLAGS}"
2795 FOLDER "Executables"
2796 INSTALL_RPATH "${EXECUTABLE_INSTALL_RPATH}"
2802 set_target_properties(logray PROPERTIES LINK_FLAGS_DEBUG "${WS_MSVC_DEBUG_LINK_FLAGS}")
2804 if(ENABLE_APPLICATION_BUNDLE OR WIN32)
2805 set_target_properties(logray PROPERTIES OUTPUT_NAME Logray)
2808 if(ENABLE_APPLICATION_BUNDLE)
2809 if(ASCIIDOCTOR_FOUND)
2810 # Make sure to generate files referenced by
2811 # LOGRAY_BUNDLE_RESOURCE_SHARE_MAN1_FILES
2812 add_dependencies(logray manpages)
2814 set_target_properties(
2816 MACOSX_BUNDLE_INFO_PLIST ${CMAKE_BINARY_DIR}/packaging/macosx/LograyInfo.plist
2818 if(CMAKE_CFG_INTDIR STREQUAL ".")
2819 # Add a wrapper script which opens the bundle. This is more convenient
2820 # and lets Sparkle find our CFBundleIdentifier, but means that you have
2821 # to pass the full path to run/Wireshark.app/Contents/MacOS/Logray
2823 # It is not created if using Xcode
2824 file(REMOVE ${CMAKE_BINARY_DIR}/run/logray)
2825 file(WRITE ${CMAKE_BINARY_DIR}/run/logray "#!/bin/sh\n")
2826 file(APPEND ${CMAKE_BINARY_DIR}/run/logray "# Generated by ${CMAKE_CURRENT_LIST_FILE}\n")
2827 file(APPEND ${CMAKE_BINARY_DIR}/run/logray "# Wrapper script which ensures that we're properly activated via Launch Services\n")
2828 file(APPEND ${CMAKE_BINARY_DIR}/run/logray "exec ${CMAKE_BINARY_DIR}/run/Logray.app/Contents/MacOS/Logray \"\$\@\"\n")
2829 execute_process(COMMAND chmod a+x ${CMAKE_BINARY_DIR}/run/logray)
2833 target_link_libraries(logray ${logray_LIBS})
2834 target_include_directories(logray SYSTEM PRIVATE ${SPARKLE_INCLUDE_DIRS})
2838 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
2839 BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
2842 if(QT_WINDEPLOYQT_EXECUTABLE)
2843 add_custom_target(copy_ls_qt_dlls ALL)
2844 set_target_properties(copy_ls_qt_dlls PROPERTIES FOLDER "Copy Tasks")
2845 # Will we ever need to use --debug? Windeployqt seems to
2846 # be smart enough to copy debug DLLs when needed.
2847 add_custom_command(TARGET copy_ls_qt_dlls
2849 COMMAND set "PATH=${QT_BIN_PATH};%PATH%"
2850 COMMAND "${QT_WINDEPLOYQT_EXECUTABLE}"
2851 --no-compiler-runtime
2853 $<$<BOOL:${MSVC}>:--pdb>
2854 "$<TARGET_FILE:logray>"
2856 add_dependencies(copy_ls_qt_dlls logray)
2858 install(CODE "execute_process(COMMAND
2859 \"${QT_WINDEPLOYQT_EXECUTABLE}\"
2860 --no-compiler-runtime
2861 \"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/Logray.exe\")"
2864 endif(QT_WINDEPLOYQT_EXECUTABLE)
2867 if (BUILD_logray AND FALCO_PLUGINS)
2868 add_custom_target(copy_falco_plugins)
2869 add_custom_command(TARGET copy_falco_plugins
2870 COMMAND ${CMAKE_COMMAND} -E make_directory ${LOGRAY_PLUGIN_DIR}/falco
2871 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FALCO_PLUGINS} ${LOGRAY_PLUGIN_DIR}/falco
2874 add_dependencies(logray copy_falco_plugins)
2877 # Common properties for CLI executables
2878 macro(set_extra_executable_properties _executable _folder)
2879 set_target_properties(${_executable} PROPERTIES
2880 LINK_FLAGS "${WILDCARD_OBJ} ${WS_LINK_FLAGS}"
2882 INSTALL_RPATH "${EXECUTABLE_INSTALL_RPATH}"
2885 set_target_properties(${_executable} PROPERTIES LINK_FLAGS_DEBUG "${WS_MSVC_DEBUG_LINK_FLAGS}")
2888 set(PROGLIST ${PROGLIST} ${_executable})
2890 if(ENABLE_APPLICATION_BUNDLE)
2891 if(NOT CMAKE_CFG_INTDIR STREQUAL ".")
2893 set_target_properties(${_executable} PROPERTIES
2894 RUNTIME_OUTPUT_DIRECTORY run/$<CONFIG>/Wireshark.app/Contents/MacOS
2897 set_target_properties(${_executable} PROPERTIES
2898 RUNTIME_OUTPUT_DIRECTORY run/Wireshark.app/Contents/MacOS
2900 # Create a convenience link from run/<name> to its respective
2901 # target in the application bundle.
2902 add_custom_target(${_executable}-symlink
2904 Wireshark.app/Contents/MacOS/${_executable}
2905 ${CMAKE_BINARY_DIR}/run/${_executable}
2907 add_dependencies(${_executable} ${_executable}-symlink)
2912 macro(executable_link_mingw_unicode _target)
2913 # target_link_options() requires CMake >= 3.13
2915 target_link_options(${_target} PRIVATE "-municode")
2919 register_tap_files(tshark-tap-register.c
2931 ${APPLE_CORE_FOUNDATION_LIBRARY}
2932 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
2933 ${WIN_WS2_32_LIBRARY}
2937 $<TARGET_OBJECTS:capture_opts>
2938 $<TARGET_OBJECTS:cli_main>
2939 $<TARGET_OBJECTS:shark_common>
2940 tshark-tap-register.c
2946 set_executable_resources(tshark "TShark" UNIQUE_RC)
2947 add_executable(tshark ${tshark_FILES})
2948 set_extra_executable_properties(tshark "Executables")
2949 target_link_libraries(tshark ${tshark_LIBS})
2950 executable_link_mingw_unicode(tshark)
2951 install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
2960 ${APPLE_CORE_FOUNDATION_LIBRARY}
2961 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
2964 $<TARGET_OBJECTS:cli_main>
2965 $<TARGET_OBJECTS:shark_common>
2969 set_executable_resources(tfshark "TFShark")
2970 add_executable(tfshark ${tfshark_FILES})
2971 set_extra_executable_properties(tfshark "Executables")
2972 target_link_libraries(tfshark ${tfshark_LIBS})
2973 install(TARGETS tfshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
2976 if(BUILD_rawshark AND PCAP_FOUND)
2982 ${APPLE_CORE_FOUNDATION_LIBRARY}
2983 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
2984 ${WIN_WS2_32_LIBRARY}
2987 $<TARGET_OBJECTS:cli_main>
2988 $<TARGET_OBJECTS:shark_common>
2991 set_executable_resources(rawshark "Rawshark")
2992 add_executable(rawshark ${rawshark_FILES})
2993 set_extra_executable_properties(rawshark "Executables")
2994 target_link_libraries(rawshark ${rawshark_LIBS})
2995 executable_link_mingw_unicode(rawshark)
2996 install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3004 ${APPLE_CORE_FOUNDATION_LIBRARY}
3005 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
3006 ${WIN_WS2_32_LIBRARY}
3007 ${SPEEXDSP_LIBRARIES}
3011 # XXX - currently doesn't work on Windows if it uses
3012 # $<TARGET_OBJECTS:cli_main> and has real_main().
3014 $<TARGET_OBJECTS:shark_common>
3019 set_executable_resources(sharkd "SharkD")
3020 add_executable(sharkd ${sharkd_FILES})
3021 set_extra_executable_properties(sharkd "Executables")
3022 target_link_libraries(sharkd ${sharkd_LIBS})
3023 target_include_directories(sharkd SYSTEM PUBLIC ${SPEEXDSP_INCLUDE_DIRS})
3025 install(TARGETS sharkd RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3037 set_executable_resources(dftest "Dftest")
3038 add_executable(dftest ${dftest_FILES})
3039 set_extra_executable_properties(dftest "Tests")
3040 target_link_libraries(dftest ${dftest_LIBS})
3051 $<TARGET_OBJECTS:cli_main>
3054 set_executable_resources(randpkt "Randpkt"
3055 COPYRIGHT_INFO "Copyright (C) 1999 by Gilbert Ramirez <gram@alumni.rice.edu>")
3056 add_executable(randpkt ${randpkt_FILES})
3057 set_extra_executable_properties(randpkt "Executables")
3058 target_link_libraries(randpkt ${randpkt_LIBS})
3059 executable_link_mingw_unicode(randpkt)
3060 install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3063 if(BUILD_fuzzshark OR ENABLE_FUZZER OR OSS_FUZZ)
3064 add_subdirectory(fuzz)
3076 $<TARGET_OBJECTS:cli_main>
3079 set_executable_resources(text2pcap "Text2pcap"
3080 COPYRIGHT_INFO "2001 Ashok Narayanan <ashokn@cisco.com>")
3081 add_executable(text2pcap ${text2pcap_FILES})
3082 set_extra_executable_properties(text2pcap "Executables")
3083 target_link_libraries(text2pcap ${text2pcap_LIBS})
3084 executable_link_mingw_unicode(text2pcap)
3085 install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3096 $<TARGET_OBJECTS:cli_main>
3099 set_executable_resources(mergecap "Mergecap")
3100 add_executable(mergecap ${mergecap_FILES})
3101 set_extra_executable_properties(mergecap "Executables")
3102 target_link_libraries(mergecap ${mergecap_LIBS})
3103 executable_link_mingw_unicode(mergecap)
3104 install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3107 if(BUILD_reordercap)
3114 set(reordercap_FILES
3115 $<TARGET_OBJECTS:cli_main>
3118 set_executable_resources(reordercap "Reordercap")
3119 add_executable(reordercap ${reordercap_FILES})
3120 set_extra_executable_properties(reordercap "Executables")
3121 target_link_libraries(reordercap ${reordercap_LIBS})
3122 executable_link_mingw_unicode(reordercap)
3123 install(TARGETS reordercap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3136 $<TARGET_OBJECTS:cli_main>
3139 set_executable_resources(capinfos "Capinfos")
3140 add_executable(capinfos ${capinfos_FILES})
3141 set_extra_executable_properties(capinfos "Executables")
3142 target_link_libraries(capinfos ${capinfos_LIBS})
3143 target_include_directories(capinfos SYSTEM PRIVATE ${GCRYPT_INCLUDE_DIRS})
3144 executable_link_mingw_unicode(capinfos)
3145 install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3157 $<TARGET_OBJECTS:cli_main>
3160 set_executable_resources(captype "Captype")
3161 add_executable(captype ${captype_FILES})
3162 set_extra_executable_properties(captype "Executables")
3163 target_link_libraries(captype ${captype_LIBS})
3164 executable_link_mingw_unicode(captype)
3165 install(TARGETS captype RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3177 $<TARGET_OBJECTS:cli_main>
3180 set_executable_resources(editcap "Editcap")
3181 add_executable(editcap ${editcap_FILES})
3182 set_extra_executable_properties(editcap "Executables")
3183 target_link_libraries(editcap ${editcap_LIBS})
3184 target_include_directories(editcap SYSTEM PRIVATE ${GCRYPT_INCLUDE_DIRS})
3185 executable_link_mingw_unicode(editcap)
3186 install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3189 if(BUILD_dumpcap AND PCAP_FOUND)
3197 ${APPLE_CORE_FOUNDATION_LIBRARY}
3198 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
3199 ${WIN_WS2_32_LIBRARY}
3202 list(APPEND CAPUTILS_SRC
3203 capture/capture-pcap-util-unix.c)
3206 list(APPEND CAPUTILS_SRC
3207 capture/capture_win_ifnames.c
3208 capture/capture-wpcap.c
3211 list(APPEND CAPUTILS_SRC
3212 capture/capture-pcap-util.c
3215 list(APPEND CAPUTILS_SRC capture/airpcap_loader.c)
3223 capture/iface_monitor.c
3224 capture/ws80211_utils.c
3227 set_executable_resources(dumpcap "Dumpcap" UNIQUE_RC)
3228 add_executable(dumpcap ${dumpcap_FILES})
3229 set_extra_executable_properties(dumpcap "Executables")
3230 target_link_libraries(dumpcap ${dumpcap_LIBS})
3231 target_include_directories(dumpcap SYSTEM PRIVATE ${ZLIB_INCLUDE_DIRS} ${NL_INCLUDE_DIRS})
3232 target_compile_definitions(dumpcap PRIVATE ENABLE_STATIC)
3233 executable_link_mingw_unicode(dumpcap)
3234 install(TARGETS dumpcap
3235 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
3236 PERMISSIONS ${DUMPCAP_SETUID}
3237 OWNER_READ OWNER_WRITE OWNER_EXECUTE
3238 GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
3240 if(ENABLE_DUMPCAP_GROUP)
3241 install(CODE "execute_process(COMMAND chgrp ${DUMPCAP_INSTALL_GROUP} ${CMAKE_INSTALL_FULL_BINDIR}/dumpcap)")
3242 install(CODE "execute_process(COMMAND chmod o-x ${CMAKE_INSTALL_FULL_BINDIR}/dumpcap)")
3244 if(DUMPCAP_INSTALL_OPTION STREQUAL "capabilities")
3245 install( CODE "execute_process(
3247 ${SETCAP_EXECUTABLE}
3248 cap_net_raw,cap_net_admin+ep
3249 ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/dumpcap${CMAKE_EXECUTABLE_SUFFIX}
3253 if( _SETCAP_RESULT )
3254 message( WARNING \"setcap failed (${_SETCAP_RESULT}).\")
3258 if(BUILD_logray AND ENABLE_APPLICATION_BUNDLE)
3259 add_custom_command(TARGET dumpcap POST_BUILD
3260 COMMAND ${CMAKE_COMMAND} -E copy_if_different
3261 $<TARGET_FILE:dumpcap> run/Logray.app/Contents/MacOS/dumpcap
3264 elseif(BUILD_dumpcap AND ENABLE_PCAP)
3265 message(WARNING "Dumpcap was requested but libpcap dependency is not available. "
3266 "Wireshark will be built without packet capture capability.")
3269 # We have two idl2wrs utilities: this and the CORBA version in tools.
3270 # We probably shouldn't do that.
3271 if(BUILD_dcerpcidl2wrs)
3276 epan/dissectors/dcerpc/idl2wrs.c
3279 add_executable(idl2wrs ${idl2wrs_FILES})
3280 set_target_properties(idl2wrs PROPERTIES FOLDER "Executables")
3281 set_extra_executable_properties(idl2wrs "Executables")
3282 target_link_libraries(idl2wrs ${idl2wrs_LIBS})
3283 install(TARGETS idl2wrs RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3287 find_package( MSVC_REDIST )
3289 # Must come after executable targets are defined.
3290 find_package( NSIS )
3292 if(MAKENSIS_EXECUTABLE)
3293 add_subdirectory( packaging/nsis EXCLUDE_FROM_ALL )
3294 ADD_NSIS_UNINSTALLER_TARGETS()
3295 ADD_NSIS_PACKAGE_TARGETS()
3300 if(WIX_CANDLE_EXECUTABLE)
3301 add_subdirectory( packaging/wix EXCLUDE_FROM_ALL )
3302 ADD_WIX_PACKAGE_TARGET()
3305 find_package( PortableApps )
3306 if(PORTABLEAPPS_LAUNCHER_GENERATOR_EXECUTABLE AND PORTABLEAPPS_INSTALLER_EXECUTABLE)
3307 add_subdirectory( packaging/portableapps EXCLUDE_FROM_ALL )
3308 ADD_PORTABLEAPPS_PACKAGE_TARGET()
3312 if (MAXMINDDB_FOUND)
3313 set(mmdbresolve_LIBS
3314 # Note: libmaxminddb is not GPL-2 compatible.
3315 ${MAXMINDDB_LIBRARY}
3316 # Needed for CMake-built libmaxminddb.lib <= 1.43.
3317 ${WIN_WS2_32_LIBRARY}
3319 set(mmdbresolve_FILES
3322 set_executable_resources(mmdbresolve "Mmdbresolve")
3323 add_executable(mmdbresolve ${mmdbresolve_FILES})
3324 set_extra_executable_properties(mmdbresolve "Executables")
3325 target_link_libraries(mmdbresolve ${mmdbresolve_LIBS})
3326 target_include_directories(mmdbresolve PUBLIC ${MAXMINDDB_INCLUDE_DIRS})
3327 target_compile_definitions(mmdbresolve PUBLIC ${MAXMINDDB_DEFINITIONS})
3328 install(TARGETS mmdbresolve RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3331 if(ENABLE_APPLICATION_BUNDLE AND BUILD_wireshark)
3332 file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}/Wireshark.app/Contents/Resources/Extras")
3334 # --preserve-xattr is undocumented but ensures that we install
3335 # a signed ChmodBPF script.
3336 set (_chmodbpf_version 1.2)
3337 set (install_chmodbpf_component_pkg "${CMAKE_BINARY_DIR}/install.ChmodBPF.pkg")
3338 add_custom_command(OUTPUT "${install_chmodbpf_component_pkg}"
3340 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/root"
3342 -exec chmod 755 "{}" +
3344 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/root/Library/LaunchDaemons/org.wireshark.ChmodBPF.plist"
3346 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/root/Library/Application Support/Wireshark/ChmodBPF/ChmodBPF"
3347 COMMAND "${CMAKE_SOURCE_DIR}/packaging/macosx/osx-extras.sh"
3349 --identifier org.wireshark.ChmodBPF.pkg
3350 --version ${_chmodbpf_version}
3352 --root "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/root"
3353 --scripts "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/install-scripts"
3354 ${install_chmodbpf_component_pkg}
3356 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/root/Library/Application Support/Wireshark/ChmodBPF/ChmodBPF"
3357 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/root/Library/LaunchDaemons/org.wireshark.ChmodBPF.plist"
3358 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/install-scripts/postinstall"
3360 set (install_chmodbpf_pkg "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/Extras/Install ChmodBPF.pkg")
3361 add_custom_command(OUTPUT "${install_chmodbpf_pkg}"
3362 COMMAND productbuild
3363 --identifier org.wireshark.install.ChmodBPF.product
3364 --version ${_chmodbpf_version}
3365 --distribution "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/install-distribution.xml"
3366 --package-path "${CMAKE_BINARY_DIR}"
3367 ${install_chmodbpf_pkg}
3369 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/install-distribution.xml"
3370 ${install_chmodbpf_component_pkg}
3373 set (uninstall_chmodbpf_component_pkg "${CMAKE_BINARY_DIR}/uninstall.ChmodBPF.pkg")
3374 add_custom_command(OUTPUT "${uninstall_chmodbpf_component_pkg}"
3376 --identifier org.wireshark.uninstall.ChmodBPF.pkg
3377 --version ${_chmodbpf_version}
3379 --scripts "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/uninstall-scripts"
3380 ${uninstall_chmodbpf_component_pkg}
3382 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/uninstall-scripts/postinstall"
3384 set (uninstall_chmodbpf_pkg "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/Extras/Uninstall ChmodBPF.pkg")
3385 add_custom_command(OUTPUT "${uninstall_chmodbpf_pkg}"
3386 COMMAND productbuild
3387 --identifier org.wireshark.uninstall.ChmodBPF.product
3388 --version ${_chmodbpf_version}
3389 --distribution "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/uninstall-distribution.xml"
3390 --package-path "${CMAKE_BINARY_DIR}"
3391 ${uninstall_chmodbpf_pkg}
3393 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/uninstall-distribution.xml"
3394 ${uninstall_chmodbpf_component_pkg}
3397 add_custom_target(chmodbpf DEPENDS ${install_chmodbpf_pkg} ${uninstall_chmodbpf_pkg})
3399 set (_path_helper_version 1.1)
3400 set (install_path_helper_component_pkg "${CMAKE_BINARY_DIR}/install.path_helper.pkg")
3401 add_custom_command(OUTPUT "${install_path_helper_component_pkg}"
3403 "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/root"
3405 -exec chmod 755 "{}" +
3407 "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/root"
3409 -exec chmod 644 "{}" +
3411 --identifier org.wireshark.path_helper.pkg
3412 --version ${_path_helper_version}
3413 --root "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/root/etc"
3414 --install-location /private/etc
3415 ${install_path_helper_component_pkg}
3417 "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/root/etc/paths.d/Wireshark"
3418 "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/root/etc/manpaths.d/Wireshark"
3420 set (install_path_helper_pkg "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/Extras/Add Wireshark to the system path.pkg")
3421 add_custom_command(OUTPUT "${install_path_helper_pkg}"
3422 COMMAND productbuild
3423 --identifier org.wireshark.install.path_helper.product
3424 --version ${_path_helper_version}
3425 --distribution "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/install-distribution.xml"
3426 --package-path "${CMAKE_BINARY_DIR}"
3427 ${install_path_helper_pkg}
3429 "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/install-distribution.xml"
3430 ${install_path_helper_component_pkg}
3433 set (uninstall_path_helper_component_pkg "${CMAKE_BINARY_DIR}/uninstall.path_helper.pkg")
3434 add_custom_command(OUTPUT "${uninstall_path_helper_component_pkg}"
3436 --identifier org.wireshark.uninstall.path_helper.pkg
3437 --version ${_path_helper_version}
3439 --scripts "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/uninstall-scripts"
3440 ${uninstall_path_helper_component_pkg}
3442 "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/uninstall-scripts/postinstall"
3444 set (uninstall_path_helper_pkg "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/Extras/Remove Wireshark from the system path.pkg")
3445 add_custom_command(OUTPUT "${uninstall_path_helper_pkg}"
3446 COMMAND productbuild
3447 --identifier org.wireshark.uninstall.path_helper.product
3448 --version ${_path_helper_version}
3449 --distribution "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/uninstall-distribution.xml"
3450 --package-path "${CMAKE_BINARY_DIR}"
3451 ${uninstall_path_helper_pkg}
3453 ${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/uninstall-distribution.xml
3454 ${uninstall_path_helper_component_pkg}
3457 add_custom_target(path_helper DEPENDS ${install_path_helper_pkg} ${uninstall_path_helper_pkg})
3459 add_custom_target(wireshark_app_bundle)
3460 set_target_properties(wireshark_app_bundle PROPERTIES FOLDER "Copy Tasks")
3461 add_custom_command(TARGET wireshark_app_bundle
3463 COMMAND "${CMAKE_BINARY_DIR}/packaging/macosx/osx-app.sh"
3464 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/run"
3466 add_dependencies(wireshark_app_bundle ${PROGLIST} chmodbpf path_helper)
3468 add_custom_target(wireshark_dmg_prep DEPENDS wireshark_app_bundle)
3470 FILE(MAKE_DIRECTORY packaging/macosx/wireshark)
3472 set(_wireshark_read_me_first "packaging/macosx/wireshark/Read me first.html")
3475 ${_wireshark_read_me_first}
3476 COMMAND ${ASCIIDOCTOR_EXECUTABLE}
3478 --out-file ${_wireshark_read_me_first}
3479 --attribute include-dir=${CMAKE_SOURCE_DIR}/docbook
3480 --attribute min-macos-version=${MIN_MACOS_VERSION}
3481 ${CMAKE_CURRENT_SOURCE_DIR}/packaging/macosx/Wireshark_read_me_first.adoc
3483 ${CMAKE_CURRENT_SOURCE_DIR}/packaging/macosx/Wireshark_read_me_first.adoc
3486 set(_wireshark_donate "packaging/macosx/wireshark/Donate to the Wireshark Foundation.html")
3489 ${_wireshark_donate}
3490 COMMAND ${ASCIIDOCTOR_EXECUTABLE}
3492 --out-file ${_wireshark_donate}
3493 --attribute include-dir=${CMAKE_SOURCE_DIR}/docbook
3494 --attribute min-macos-version=${MIN_MACOS_VERSION}
3495 ${CMAKE_CURRENT_SOURCE_DIR}/packaging/macosx/Donate_to_the_Wireshark_Foundation.adoc
3497 ${CMAKE_CURRENT_SOURCE_DIR}/packaging/macosx/Donate_to_the_Wireshark_Foundation.adoc
3500 set(_wireshark_dsym_installation "packaging/macosx/wireshark/Debugging symbols installation.html")
3503 ${_wireshark_dsym_installation}
3504 COMMAND ${ASCIIDOCTOR_EXECUTABLE}
3506 --out-file ${_wireshark_dsym_installation}
3507 --attribute include-dir=${CMAKE_SOURCE_DIR}/docbook
3508 ${CMAKE_CURRENT_SOURCE_DIR}/packaging/macosx/Wireshark_dsym_installation.adoc
3510 ${CMAKE_CURRENT_SOURCE_DIR}/packaging/macosx/Wireshark_dsym_installation.adoc
3513 add_custom_target(wireshark_dmg_readmes DEPENDS ${_wireshark_read_me_first} ${_wireshark_donate} ${_wireshark_dsym_installation} )
3514 add_dependencies(wireshark_dmg_prep wireshark_dmg_readmes)
3516 ADD_CUSTOM_TARGET( wireshark_dmg
3517 COMMAND bash -x ${CMAKE_BINARY_DIR}/packaging/macosx/osx-dmg.sh
3518 # Unlike wireshark_nsis_prep + wireshark_nsis, we can add a direct
3520 DEPENDS wireshark_dmg_prep
3521 # We create Wireshark.app in "run". Do our work there.
3522 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/run
3527 if(ENABLE_APPLICATION_BUNDLE AND BUILD_logray)
3528 add_custom_target(logray_app_bundle)
3529 set_target_properties(logray_app_bundle PROPERTIES FOLDER "Copy Tasks")
3530 add_custom_command(TARGET logray_app_bundle
3532 COMMAND "${CMAKE_BINARY_DIR}/packaging/macosx/osx-app.sh" --bundle Logray.app
3533 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/run"
3536 add_custom_target(logray_dmg_prep DEPENDS logray_app_bundle)
3538 FILE(MAKE_DIRECTORY packaging/macosx/logray)
3540 set(_logray_read_me_first "packaging/macosx/logray/Read me first.html")
3543 ${_logray_read_me_first}
3544 COMMAND ${ASCIIDOCTOR_EXECUTABLE}
3546 --out-file ${_logray_read_me_first}
3547 --attribute include-dir=${CMAKE_SOURCE_DIR}/docbook
3548 --attribute min-macos-version=${MIN_MACOS_VERSION}
3549 ${CMAKE_CURRENT_SOURCE_DIR}/packaging/macosx/Logray_read_me_first.adoc
3551 ${CMAKE_CURRENT_SOURCE_DIR}/packaging/macosx/Logray_read_me_first.adoc
3554 set(_logray_dsym_installation "packaging/macosx/logray/Debugging symbols installation.html")
3557 ${_logray_dsym_installation}
3558 COMMAND ${ASCIIDOCTOR_EXECUTABLE}
3560 --out-file ${_logray_dsym_installation}
3561 --attribute include-dir=${CMAKE_SOURCE_DIR}/docbook
3562 ${CMAKE_CURRENT_SOURCE_DIR}/packaging/macosx/Logray_dsym_installation.adoc
3564 ${CMAKE_CURRENT_SOURCE_DIR}/packaging/macosx/Logray_dsym_installation.adoc
3567 add_custom_target(logray_dmg_readmes DEPENDS ${_logray_read_me_first} ${_logray_dsym_installation} )
3568 add_dependencies(logray_dmg_prep logray_dmg_readmes)
3570 ADD_CUSTOM_TARGET( logray_dmg
3571 COMMAND bash -x ${CMAKE_BINARY_DIR}/packaging/macosx/osx-dmg.sh --app-name Logray
3572 # Unlike wireshark_nsis_prep + wireshark_nsis, we can add a direct
3574 DEPENDS logray_dmg_prep
3575 # We create Wireshark.app in "run". Do our work there.
3576 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/run
3581 if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
3582 find_program(RPMBUILD_EXECUTABLE rpmbuild)
3583 find_program(GIT_EXECUTABLE git)
3584 # Should we add appimaged's monitored directories
3586 # https://github.com/AppImage/appimaged
3587 find_program(LINUXDEPLOY_EXECUTABLE NAMES linuxdeploy-x86_64.AppImage linuxdeploy)
3588 find_program(_linuxdeploy_plugin_qt NAMES linuxdeploy-plugin-qt-x86_64.AppImage linuxdeploy-plugin-qt)
3589 find_program(APPIMAGETOOL_EXECUTABLE NAMES appimagetool-x86_64.AppImage
3594 string(REPLACE "-" "_" RPM_VERSION "${PROJECT_VERSION}")
3595 configure_file(packaging/rpm/wireshark.spec.in ${CMAKE_BINARY_DIR}/packaging/rpm/SPECS/wireshark.spec)
3596 if(RPMBUILD_EXECUTABLE)
3597 foreach(_rpm_dir BUILD RPMS SOURCES SPECS SRPMS)
3598 file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/packaging/rpm/${_rpm_dir}")
3601 set(_rpmbuild_with_args)
3605 # At least some versions of rpmbuild define the cmake_build
3606 # macro to run "cmake --build" with the "--verbose" option,
3607 # with no obvious way to easily override that, so, if you
3608 # are doing a build with lots of source files, and with
3609 # lots of compiler options (for example, a log of -W flags),
3610 # you can get a lot of output from rpmbuild.
3612 # Wireshark is a program with lots of source files and
3613 # lots of compiler options.
3615 # GitLab's shared builders have a limit of 4MB on logs
3618 # Wireshark uses the shared builders, and can produce
3619 # more than 4MB with the Fedora RPM build; this causes
3620 # the builds to fail.
3622 # Forcibly overriding the cmake_build macro with a
3623 # version that lacks the --version file should
3624 # prevent ninja from being run with the -v flag,
3625 # so that it prints the compact output rather
3626 # than the raw command.
3628 # We don't do that by default; if the build has the
3629 # FORCE_CMAKE_NINJA_QUIET environment variable set,
3632 if(DEFINED ENV{FORCE_CMAKE_NINJA_NON_VERBOSE})
3634 # Get the output of a pipeline running
3635 # "rpmbuild --showrc", to find the settings
3636 # of all macros, piped to an awk script
3637 # to extract the value of the cmake_build
3641 COMMAND rpmbuild --showrc
3642 COMMAND awk "/: cmake_build/ { getline; print \$0; exit }"
3643 OUTPUT_VARIABLE CMAKE_BUILD_VALUE
3644 OUTPUT_STRIP_TRAILING_WHITESPACE)
3645 if (CMAKE_BUILD_VALUE MATCHES ".*--verbose.*")
3647 # OK, the setting contains "--verbose".
3650 string(REPLACE "--verbose" ""
3651 NON_VERBOSE_CMAKE_BUILD_VALUE
3652 ${CMAKE_BUILD_VALUE})
3653 list(APPEND _rpmbuild_with_args --define "cmake_build ${NON_VERBOSE_CMAKE_BUILD_VALUE}")
3656 if(CMAKE_VERBOSE_MAKEFILE)
3657 list(APPEND _rpmbuild_with_args -v)
3660 if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
3661 list(APPEND _rpmbuild_with_args --with toolchain_clang)
3663 if(CMAKE_GENERATOR STREQUAL "Ninja")
3664 list(APPEND _rpmbuild_with_args --with ninja)
3666 if(CCACHE_EXECUTABLE)
3667 list(APPEND _rpmbuild_with_args --with ccache)
3669 if(NOT BUILD_wireshark)
3670 list(APPEND _rpmbuild_with_args --without qt5 --without qt6)
3672 list(APPEND _rpmbuild_with_args --without qt5 --with qt6)
3674 list(APPEND _rpmbuild_with_args --with qt5 --without qt6)
3676 if (MAXMINDDB_FOUND)
3677 list(APPEND _rpmbuild_with_args --with mmdbresolve)
3680 list(APPEND _rpmbuild_with_args --with lua)
3682 if (LZ4_FOUND AND SNAPPY_FOUND)
3683 list(APPEND _rpmbuild_with_args --with lz4_and_snappy)
3686 list(APPEND _rpmbuild_with_args --with spandsp)
3689 list(APPEND _rpmbuild_with_args --with bcg729)
3692 list(APPEND _rpmbuild_with_args --with amrnb)
3695 list(APPEND _rpmbuild_with_args --with ilbc)
3698 list(APPEND _rpmbuild_with_args --with opus)
3701 list(APPEND _rpmbuild_with_args --with libxml2)
3704 list(APPEND _rpmbuild_with_args --with nghttp2)
3707 list(APPEND _rpmbuild_with_args --with sdjournal)
3710 list(APPEND _rpmbuild_with_args --with brotli)
3714 COMMAND ${PYTHON_EXECUTABLE}
3715 ${CMAKE_SOURCE_DIR}/tools/make-version.py
3719 add_custom_target(copy-dist
3720 COMMAND cp ${CMAKE_BINARY_DIR}/wireshark*tar* ${CMAKE_BINARY_DIR}/packaging/rpm/SOURCES/
3723 add_custom_target(wireshark_rpm
3724 COMMAND ${RPMBUILD_EXECUTABLE}
3725 --define "_topdir ${CMAKE_BINARY_DIR}/packaging/rpm"
3726 --define "_prefix ${CMAKE_INSTALL_PREFIX}"
3727 ${_rpmbuild_with_args}
3728 -ba SPECS/wireshark.spec
3730 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/packaging/rpm"
3731 COMMENT "Create a rpm from the current git commit."
3735 if(BUILD_wireshark AND QT_FOUND AND LINUXDEPLOY_EXECUTABLE AND _linuxdeploy_plugin_qt AND APPIMAGETOOL_EXECUTABLE)
3736 configure_file(packaging/appimage/Wireshark-AppRun.in ${CMAKE_BINARY_DIR}/packaging/appimage/Wireshark-AppRun @ONLY)
3737 # Require production builds (/usr + Release).
3738 if (CMAKE_BUILD_TYPE STREQUAL "Release" AND CMAKE_INSTALL_PREFIX STREQUAL "/usr" )
3739 add_custom_target(wireshark_appimage_prerequisites)
3740 add_dependencies(wireshark_appimage_prerequisites ${PROGLIST})
3742 add_custom_target(wireshark_appimage_prerequisites
3743 COMMAND echo "CMAKE_BUILD_TYPE isn't Release or CMAKE_INSTALL_PREFIX isn't /usr."
3747 set (_wireshark_ai_appdir ${CMAKE_BINARY_DIR}/packaging/appimage/wireshark.appdir)
3748 add_custom_target(wireshark_appimage_appdir
3749 COMMAND ${CMAKE_COMMAND} -E make_directory ${_wireshark_ai_appdir}
3750 COMMAND env DESTDIR=${_wireshark_ai_appdir}
3751 ${CMAKE_COMMAND} --build . --target install
3752 DEPENDS wireshark_appimage_prerequisites
3754 set(_wireshark_appimage_exe_args)
3755 foreach(_prog ${PROGLIST})
3756 # XXX This needs to be more robust.
3757 if (${_prog} STREQUAL "dftest" OR ${_prog} STREQUAL "logray")
3760 list(APPEND _wireshark_appimage_exe_args --executable=${_wireshark_ai_appdir}/usr/bin/${_prog})
3762 # It looks like linuxdeploy can't handle executables in nonstandard
3763 # locations, so use it to prep our staging directory here and use
3764 # appimagetool to to build the appimage.
3765 add_custom_target(wireshark_appimage_prep
3766 COMMAND env LD_LIBRARY_PATH=${_wireshark_ai_appdir}/${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} ${LINUXDEPLOY_EXECUTABLE}
3767 --appdir=${_wireshark_ai_appdir}
3768 ${_wireshark_appimage_exe_args}
3769 --desktop-file=${_wireshark_ai_appdir}/usr/share/applications/org.wireshark.Wireshark.desktop
3770 --icon-file=${CMAKE_SOURCE_DIR}/resources/icons/wsicon256.png
3771 --custom-apprun=${CMAKE_BINARY_DIR}/packaging/appimage/Wireshark-AppRun
3773 DEPENDS wireshark_appimage_appdir
3775 add_custom_target(wireshark_appimage
3776 COMMAND env VERSION=${PROJECT_VERSION} ${APPIMAGETOOL_EXECUTABLE} ${_wireshark_ai_appdir}
3777 DEPENDS wireshark_appimage_prep
3781 if(BUILD_logray AND QT_FOUND AND LINUXDEPLOY_EXECUTABLE AND _linuxdeploy_plugin_qt AND APPIMAGETOOL_EXECUTABLE)
3782 configure_file(packaging/appimage/Logray-AppRun.in ${CMAKE_BINARY_DIR}/packaging/appimage/Logray-AppRun @ONLY)
3783 # Require production builds (/usr + Release).
3784 if (CMAKE_BUILD_TYPE STREQUAL "Release" AND CMAKE_INSTALL_PREFIX STREQUAL "/usr" )
3785 add_custom_target(logray_appimage_prerequisites)
3786 add_dependencies(logray_appimage_prerequisites ${PROGLIST})
3788 add_custom_target(logray_appimage_prerequisites
3789 COMMAND echo "CMAKE_BUILD_TYPE isn't Release or CMAKE_INSTALL_PREFIX isn't /usr."
3793 set (_logray_ai_appdir ${CMAKE_BINARY_DIR}/packaging/appimage/logray.appdir)
3794 add_custom_target(logray_appimage_appdir
3795 COMMAND ${CMAKE_COMMAND} -E make_directory ${_logray_ai_appdir}
3796 COMMAND env DESTDIR=${_logray_ai_appdir}
3797 ${CMAKE_COMMAND} --build . --target install
3798 DEPENDS logray_appimage_prerequisites
3800 set(_logray_appimage_exe_args)
3801 foreach(_prog ${PROGLIST})
3802 # XXX This needs to be more robust.
3803 if (${_prog} STREQUAL "dftest" OR ${_prog} STREQUAL "logray")
3806 list(APPEND _logray_appimage_exe_args --executable=${_logray_ai_appdir}/usr/bin/${_prog})
3808 # It looks like linuxdeploy can't handle executables in nonstandard
3809 # locations, so use it to prep our staging directory here and use
3810 # appimagetool to to build the appimage.
3811 add_custom_target(logray_appimage_prep
3812 COMMAND env LD_LIBRARY_PATH=${_logray_ai_appdir}/${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} ${LINUXDEPLOY_EXECUTABLE}
3813 --appdir=${_logray_ai_appdir}
3814 ${_logray_appimage_exe_args}
3815 --desktop-file=${_logray_ai_appdir}/usr/share/applications/org.wireshark.Logray.desktop
3816 --icon-file=${CMAKE_SOURCE_DIR}/resources/icons/lricon256.png
3817 --custom-apprun=${CMAKE_BINARY_DIR}/packaging/appimage/Logray-AppRun
3819 DEPENDS logray_appimage_appdir
3821 add_custom_target(logray_appimage
3822 COMMAND env VERSION=${LOG_PROJECT_VERSION} ${APPIMAGETOOL_EXECUTABLE} ${_logray_ai_appdir}
3823 DEPENDS logray_appimage_prep
3836 ${randpktdump_FILES}
3846 ${mmdbresolve_FILES}
3851 # Make sure we don't pass /WX to rc.exe. Rc doesn't have a /WX flag,
3852 # but it does have /W (warn about invalid code pages) and /X (ignore
3853 # the INCLUDE environment variable).
3854 # This should apparently be handled for us via CMAKE_RC_FLAG_REGEX
3855 # in CMakeRCInformation.cmake but that doesn't appear to work.
3857 list(FILTER CLEAN_C_FILES EXCLUDE REGEX ".*\\.rc")
3860 # XXX This also contains object files ($<TARGET_OBJECTS:...>), is that an issue?
3861 set_source_files_properties(
3864 COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
3872 OWNER_WRITE OWNER_READ
3876 ${CMAKE_INSTALL_DATADIR}
3883 ${CMAKE_INSTALL_DOCDIR}
3886 if(ASCIIDOCTOR_FOUND AND XSLTPROC_EXECUTABLE)
3888 DIRECTORY "${CMAKE_BINARY_DIR}/docbook/wsug_html_chunked"
3889 DESTINATION "${CMAKE_INSTALL_DOCDIR}"
3890 COMPONENT "UserGuide"
3894 DIRECTORY "${CMAKE_BINARY_DIR}/docbook/wsdg_html_chunked"
3895 DESTINATION "${CMAKE_INSTALL_DOCDIR}"
3896 COMPONENT "DeveloperGuide"
3901 set(SHARK_PUBLIC_HEADERS
3905 include/ws_attributes.h
3906 include/ws_codepoints.h
3907 include/ws_compiler_tests.h
3908 include/ws_diag_control.h
3909 include/ws_exit_codes.h
3910 include/ws_log_defs.h
3911 include/ws_posix_compat.h
3912 include/ws_symbol_export.h
3914 ${CMAKE_BINARY_DIR}/ws_version.h
3917 install(FILES ${SHARK_PUBLIC_HEADERS}
3918 DESTINATION ${PROJECT_INSTALL_INCLUDEDIR}
3919 COMPONENT "Development"
3923 # Install icons and other desktop files for Freedesktop.org-compliant desktops.
3924 if(BUILD_wireshark AND QT_FOUND AND NOT APPLE AND (NOT WIN32 OR USE_MSYSTEM))
3925 install(FILES resources/freedesktop/org.wireshark.Wireshark-mime.xml
3926 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/mime/packages"
3927 RENAME org.wireshark.Wireshark.xml
3929 install(FILES resources/freedesktop/org.wireshark.Wireshark.metainfo.xml
3930 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo"
3932 if(BUILD_wireshark AND QT_FOUND)
3933 install(FILES resources/freedesktop/org.wireshark.Wireshark.desktop
3934 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
3936 foreach(size 16 24 32 48 64 128 256)
3937 install(FILES resources/icons/wsicon${size}.png
3938 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${size}x${size}/apps"
3939 RENAME org.wireshark.Wireshark.png)
3940 install(FILES resources/icons/WiresharkDoc-${size}.png
3941 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${size}x${size}/mimetypes"
3942 RENAME org.wireshark.Wireshark-mimetype.png)
3946 if(BUILD_logray AND QT_FOUND AND NOT APPLE AND (NOT WIN32 OR USE_MSYSTEM))
3947 install(FILES resources/freedesktop/org.wireshark.Logray-mime.xml
3948 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/mime/packages"
3949 RENAME org.wireshark.Logray.xml
3951 install(FILES resources/freedesktop/org.wireshark.Logray.metainfo.xml
3952 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo"
3954 if(BUILD_wireshark AND QT_FOUND)
3955 install(FILES resources/freedesktop/org.wireshark.Logray.desktop
3956 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
3958 foreach(size 16 32 48 64 128 256)
3959 install(FILES resources/icons/lricon${size}.png
3960 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${size}x${size}/apps"
3961 RENAME org.wireshark.Logray.png)
3962 install(FILES resources/icons/WiresharkDoc-${size}.png
3963 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${size}x${size}/mimetypes"
3964 RENAME org.wireshark.Logray-mimetype.png)
3966 install(FILES resources/icons/lricon.svg
3967 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps"
3968 RENAME org.wireshark.Logray.svg)
3973 "${CMAKE_BINARY_DIR}/wireshark.pc"
3975 ${CMAKE_INSTALL_LIBDIR}/pkgconfig
3985 ${CMAKE_INSTALL_DATADIR}
3987 OWNER_WRITE OWNER_READ
3990 DIRECTORY_PERMISSIONS
3991 OWNER_EXECUTE OWNER_WRITE OWNER_READ
3992 GROUP_EXECUTE GROUP_READ
3993 WORLD_EXECUTE WORLD_READ
3994 PATTERN ".git" EXCLUDE
3995 PATTERN ".svn" EXCLUDE
3996 PATTERN "Makefile.*" EXCLUDE
3999 if(WIN32 AND NOT USE_MSYSTEM)
4000 # Note: CMake export mechanism misbehaves with a '.' in the
4001 # path (incorrect relative path computation).
4002 set(WIRESHARK_INSTALL_CMAKEDIR "cmake")
4004 set(WIRESHARK_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/cmake")
4007 include(CMakePackageConfigHelpers)
4009 configure_package_config_file(WiresharkConfig.cmake.in
4010 ${CMAKE_BINARY_DIR}/WiresharkConfig.cmake
4011 INSTALL_DESTINATION ${WIRESHARK_INSTALL_CMAKEDIR}
4013 CMAKE_INSTALL_LIBDIR
4014 CMAKE_INSTALL_INCLUDEDIR
4015 PLUGIN_INSTALL_VERSION_LIBDIR
4016 EXTCAP_INSTALL_LIBDIR
4019 write_basic_package_version_file(
4020 ${CMAKE_BINARY_DIR}/WiresharkConfigVersion.cmake
4021 COMPATIBILITY AnyNewerVersion
4026 ${CMAKE_BINARY_DIR}/WiresharkConfig.cmake
4027 ${CMAKE_BINARY_DIR}/WiresharkConfigVersion.cmake
4029 ${WIRESHARK_INSTALL_CMAKEDIR}
4035 install(EXPORT WiresharkTargets
4036 DESTINATION ${WIRESHARK_INSTALL_CMAKEDIR}
4037 COMPONENT "Development"
4041 # This isn't strictly needed but it makes working around debhelper's
4042 # cleverness a lot easier.
4043 add_custom_target(install-headers
4044 COMMAND ${CMAKE_COMMAND} -DCOMPONENT=Development -P cmake_install.cmake
4047 if (DOXYGEN_EXECUTABLE)
4049 # We don't have a good way of tracking dependencies, so we simply
4050 # recreate the whole thing from scratch each time.
4051 add_custom_target(wsar_html
4052 COMMAND ${CMAKE_COMMAND} -E remove_directory wsar_html
4053 COMMAND ${DOXYGEN_EXECUTABLE} doxygen.cfg
4056 if(WIN32 AND NOT USE_MSYSTEM)
4057 add_custom_target(wsar_html_perms DEPENDS wsar_html)
4059 add_custom_target(wsar_html_perms
4060 COMMAND find wsar_html
4062 -exec chmod 755 "{}" +
4063 COMMAND find wsar_html
4065 -exec chmod 644 "{}" +
4069 add_custom_target(wsar_html_zip
4070 COMMAND ${CMAKE_COMMAND} -E tar "cfv" "wsar_html.zip" --format=zip wsar_html
4071 DEPENDS wsar_html_perms
4073 set_target_properties(wsar_html wsar_html_zip PROPERTIES
4074 FOLDER "Documentation"
4075 EXCLUDE_FROM_DEFAULT_BUILD True
4077 endif(DOXYGEN_EXECUTABLE)
4079 add_custom_target(test-programs
4088 COMMENT "Building unit test programs and wrapper"
4090 set_target_properties(test-programs PROPERTIES
4092 EXCLUDE_FROM_DEFAULT_BUILD True
4095 # Add target to enable capturing from the build directory. Requires Linux capabilities
4096 # and running with sudo.
4097 if(TARGET dumpcap AND SETCAP_EXECUTABLE)
4098 add_custom_target(test-capture
4099 COMMAND ${SETCAP_EXECUTABLE} cap_net_raw,cap_net_admin+ep $<TARGET_FILE:dumpcap>
4103 add_custom_target(test
4104 COMMAND ${CMAKE_COMMAND} -E env PYTHONIOENCODING=UTF-8
4105 ${PYTHON_EXECUTABLE} -m pytest
4106 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
4107 DEPENDS test-programs
4111 # Make it possible to run pytest without passing the full path as argument.
4112 if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
4113 file(READ "${CMAKE_CURRENT_SOURCE_DIR}/pytest.ini" pytest_ini)
4114 string(REGEX REPLACE "\naddopts = ([^\n]+)"
4115 "\naddopts = ${CMAKE_CURRENT_SOURCE_DIR}/test \\1"
4116 pytest_ini "${pytest_ini}")
4117 file(WRITE "${CMAKE_BINARY_DIR}/pytest.ini" "${pytest_ini}")
4121 # Update AUTHORS file with entries from git shortlog
4124 COMMAND ${PYTHON_EXECUTABLE} tools/generate_authors.py AUTHORS
4125 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
4127 else (GIT_EXECUTABLE)
4128 add_custom_target( gen-authors COMMAND ${CMAKE_COMMAND} -E echo "Git not found." )
4129 endif (GIT_EXECUTABLE)
4130 set_target_properties(gen-authors PROPERTIES FOLDER "Documentation")
4132 if(WIN32 AND NOT USE_MSYSTEM)
4133 file (TO_NATIVE_PATH ${CMAKE_SOURCE_DIR}/tools/Get-HardenFlags.ps1 _win_harden_flags)
4134 add_custom_target(hardening-check
4135 COMMAND ${POWERSHELL_COMMAND} "${_win_harden_flags}" "${_dll_output_dir_win}"
4137 COMMENT "Checking binaries for security features"
4139 set_target_properties(hardening-check PROPERTIES FOLDER "Tests")
4141 find_program(HARDENING_CHECK_EXECUTABLE hardening-check
4142 DOC "Path to the hardening-check utility."
4144 if(HARDENING_CHECK_EXECUTABLE)
4145 foreach(_prog ${PROGLIST})
4146 get_target_property(_prog_dir ${_prog} RUNTIME_OUTPUT_DIRECTORY)
4148 set(_prog_dir "${CMAKE_BINARY_DIR}/run")
4150 set(_prog_paths ${_prog_paths} "${_prog_dir}/${_prog}")
4152 add_custom_target(hardening-check
4153 COMMAND ${HARDENING_CHECK_EXECUTABLE} ${_prog_paths}
4155 COMMENT "Checking binaries for security features"
4169 find_program(SHELLCHECK_EXECUTABLE shellcheck
4170 DOC "Path to the shellcheck utility."
4172 if(SHELLCHECK_EXECUTABLE)
4173 add_custom_target(shellcheck)
4174 set_target_properties(shellcheck PROPERTIES FOLDER "Tests")
4175 # --external-sources requires 0.4.0 or later.
4176 # ChmodBPF uses "shellcheck shell=bash". Not sure which version
4177 # added support for that.
4178 add_custom_command(TARGET shellcheck POST_BUILD
4179 COMMAND shellcheck --external-sources
4180 resources/stock_icons/svg-to-png.sh
4181 packaging/appimage/Logray-AppRun.in
4182 packaging/appimage/Wireshark-AppRun.in
4183 "packaging/macosx/ChmodBPF/root/Library/Application Support/Wireshark/ChmodBPF/ChmodBPF"
4184 packaging/macosx/osx-app.sh.in
4185 packaging/macosx/osx-dmg.sh.in
4186 packaging/source/git-export-release.sh.in
4187 tools/debian-setup.sh
4191 tools/randpkt-test.sh
4192 tools/release-update-debian-soversions.sh
4193 tools/test-captures.sh
4195 tools/valgrind-wireshark.sh
4196 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
4202 "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
4203 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
4206 add_custom_target(uninstall
4207 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
4209 # Break on programmer errors when debugging in Visual Studio
4211 get_property(_targets DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS)
4212 foreach(_target ${_targets})
4213 set_target_properties(${_target} PROPERTIES VS_DEBUGGER_ENVIRONMENT "G_DEBUG=fatal-criticals")
4218 # Editor modelines - https://www.wireshark.org/tools/modelines.html
4223 # indent-tabs-mode: t
4226 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
4227 # :indentSize=8:tabSize=8:noTabs=false: