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
11 # Needed for add_custom_command() WORKING_DIRECTORY generator expressions
12 cmake_minimum_required(VERSION 3.13)
14 cmake_minimum_required(VERSION 3.5)
17 cmake_policy(SET CMP0074 NEW)
20 cmake_policy(SET CMP0083 NEW)
24 set(_project_name Wireshark)
26 set(_project_name wireshark)
29 project(${_project_name} C CXX)
31 # Updated by tools/make-version.pl
33 set(PROJECT_MAJOR_VERSION 3)
34 set(PROJECT_MINOR_VERSION 3)
35 set(PROJECT_PATCH_VERSION 0)
36 set(PROJECT_BUILD_VERSION ${GIT_REVISION})
37 set(PROJECT_VERSION_EXTENSION "")
39 if(DEFINED ENV{WIRESHARK_VERSION_EXTRA})
40 set(PROJECT_VERSION_EXTENSION "$ENV{WIRESHARK_VERSION_EXTRA}")
43 set(PROJECT_VERSION "${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}.${PROJECT_PATCH_VERSION}${PROJECT_VERSION_EXTENSION}")
45 set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
47 include( CMakeOptions.txt )
49 # We require minimum C++11
50 set(CMAKE_CXX_STANDARD 11)
51 set(CMAKE_CXX_STANDARD_REQUIRED ON)
52 set(CMAKE_CXX_EXTENSIONS OFF)
54 message(STATUS "Generating build using CMake ${CMAKE_VERSION}")
56 #Where to find local cmake scripts
57 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
59 # If our target platform is enforced by our generator, set
60 # WIRESHARK_TARGET_PLATFORM accordingly. Otherwise use
61 # %WIRESHARK_TARGET_PLATFORM%.
64 find_package(PowerShell REQUIRED)
66 if(CMAKE_CL_64 OR CMAKE_GENERATOR MATCHES "Win64")
67 set(WIRESHARK_TARGET_PLATFORM win64)
68 elseif(CMAKE_GENERATOR MATCHES "Visual Studio")
69 set(WIRESHARK_TARGET_PLATFORM win32)
71 set(WIRESHARK_TARGET_PLATFORM $ENV{WIRESHARK_TARGET_PLATFORM})
74 if(WIRESHARK_TARGET_PLATFORM MATCHES "win64")
75 set(WIRESHARK_TARGET_PROCESSOR_ARCHITECTURE amd64)
77 set(WIRESHARK_TARGET_PROCESSOR_ARCHITECTURE x86)
81 if(DEFINED ENV{PLATFORM})
82 string(TOLOWER $ENV{PLATFORM} _vs_platform)
84 set(_vs_platform "[undefined]") # x86
87 (_vs_platform STREQUAL "x64" AND NOT WIRESHARK_TARGET_PLATFORM STREQUAL "win64")
89 (_vs_platform STREQUAL "[undefined]" AND NOT WIRESHARK_TARGET_PLATFORM STREQUAL "win32")
91 message(FATAL_ERROR "The PLATFORM environment variable (${_vs_platform})"
92 " doesn't match the generator platform (${WIRESHARK_TARGET_PLATFORM})")
94 message(STATUS "Building for ${WIRESHARK_TARGET_PLATFORM} using ${CMAKE_GENERATOR}")
96 # Determine where the 3rd party libraries will be
97 if( DEFINED ENV{WIRESHARK_LIB_DIR} )
98 # The buildbots set WIRESHARK_LIB_DIR but not WIRESHARK_BASE_DIR.
99 file( TO_CMAKE_PATH "$ENV{WIRESHARK_LIB_DIR}" _PROJECT_LIB_DIR )
100 elseif( DEFINED ENV{WIRESHARK_BASE_DIR} )
101 file( TO_CMAKE_PATH "$ENV{WIRESHARK_BASE_DIR}" _WS_BASE_DIR )
102 set( _PROJECT_LIB_DIR "${_WS_BASE_DIR}/wireshark-${WIRESHARK_TARGET_PLATFORM}-libs" )
104 # Don't know what to do
105 message(FATAL_ERROR "Neither WIRESHARK_BASE_DIR or WIRESHARK_LIB_DIR are defined")
108 # Download third-party libraries
109 file (TO_NATIVE_PATH ${CMAKE_SOURCE_DIR}/tools/win-setup.ps1 _win_setup)
110 file (TO_NATIVE_PATH ${_PROJECT_LIB_DIR} _ws_lib_dir)
112 # Is it possible to have a one-time, non-cached option in CMake? If
113 # so, we could add a "-DFORCE_WIN_SETUP" which passes -Force to
116 COMMAND ${POWERSHELL_COMMAND} "\"${_win_setup}\"" -Destination "${_ws_lib_dir}" -Platform ${WIRESHARK_TARGET_PLATFORM}
117 RESULT_VARIABLE _win_setup_failed
119 if(_win_setup_failed)
120 message(FATAL_ERROR "Windows setup (win-setup.ps1) failed.")
123 set(EXTRA_INSTALLER_DIR ${_ws_lib_dir})
125 # XXX Add a dependency on ${_ws_lib_dir}/current_tag.txt?
127 # Prepopulate some ConfigureChecks values. Compilation checks
128 # on Windows can be slow.
129 set(HAVE_FCNTL_H TRUE)
130 set(HAVE_FLOORL TRUE)
133 include(UseCustomIncludes)
134 ADD_CUSTOM_CMAKE_INCLUDE()
136 # This cannot be implemented via option(...)
137 if( NOT CMAKE_BUILD_TYPE )
138 set( CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
139 "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
142 message(STATUS "CMake build type: ${CMAKE_BUILD_TYPE}")
144 # Ensure that all executables and libraries end up in the same directory. Actual
145 # files might end up in a configuration subdirectory, e.g. run/Debug or
146 # run/Release. We try to set DATAFILE_DIR to actual location below.
147 if(NOT ARCHIVE_OUTPUT_PATH)
148 set(ARCHIVE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/run CACHE INTERNAL
149 "Single output directory for building all archives.")
151 if(NOT EXECUTABLE_OUTPUT_PATH)
152 set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/run CACHE INTERNAL
153 "Single output directory for building all executables.")
155 if(NOT LIBRARY_OUTPUT_PATH)
156 set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/run CACHE INTERNAL
157 "Single output directory for building all libraries.")
161 # The release mode (CMAKE_BUILD_TYPE=release) defines NDEBUG for
162 # the Unix Makefile generator.
165 # Defines CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_DATADIR, etc ...
167 # Override some values on Windows, to match the existing
168 # convention of installing everything to a single root folder.
169 set(CMAKE_INSTALL_BINDIR ".")
170 set(CMAKE_INSTALL_LIBDIR ".")
171 set(CMAKE_INSTALL_INCLUDEDIR "include")
172 set(CMAKE_INSTALL_DATADIR ".")
173 set(CMAKE_INSTALL_DOCDIR ".")
175 # By default INSTALL_DATADIR is set to INSTALL_DATAROOTDIR, set the
177 set(CMAKE_INSTALL_DATADIR "share/${PROJECT_NAME}"
178 CACHE PATH "Read-only architecture-independent data"
181 include(GNUInstallDirs)
183 set(PROJECT_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}")
185 # Make sure our executables can can load our libraries if we install into
186 # a non-default directory on Unix-like systems other than macOS.
187 # https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
188 set(LIBRARY_INSTALL_RPATH "")
189 set(EXECUTABLE_INSTALL_RPATH "")
190 set(EXTCAP_INSTALL_RPATH "")
191 if(NOT (WIN32 OR APPLE OR USE_STATIC))
192 # Try to set a RPATH for installed binaries if the library directory is
193 # not already included in the default search list.
194 list(FIND CMAKE_C_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_FULL_LIBDIR}" IS_SYSTEM_DIR)
195 if(IS_SYSTEM_DIR EQUAL -1)
196 # Some systems support $ORIGIN in RPATH to enable relocatable
197 # binaries. In other cases, only absolute paths can be used.
198 # https://www.lekensteyn.nl/rpath.html
199 if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|SunOS|FreeBSD)$")
200 set(_enable_rpath_origin TRUE)
201 if(BUILD_dumpcap AND ENABLE_PCAP)
202 # dumpcap will most likely be installed with
203 # capabilities or setuid. Relative RPATHs that
204 # resolve to non-standard library directories
205 # are ignored for such binaries and since we
206 # cannot achieve relocatable builds, just
207 # disable it by default.
208 set(_enable_rpath_origin FALSE)
210 # Provide a knob to optionally force absolute rpaths,
211 # to support old/buggy systems and as a user preference
213 set(ENABLE_RPATH_ORIGIN ${_enable_rpath_origin} CACHE BOOL
214 "Use $ORIGIN with INSTALL_RPATH")
215 mark_as_advanced(ENABLE_RPATH_ORIGIN)
217 set(ENABLE_RPATH_ORIGIN FALSE)
219 if(ENABLE_RPATH_ORIGIN)
220 set(LIBRARY_INSTALL_RPATH "$ORIGIN")
221 set(EXECUTABLE_INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
222 set(EXTCAP_INSTALL_RPATH "$ORIGIN/../..")
224 set(LIBRARY_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
225 set(EXECUTABLE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
226 set(EXTCAP_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
228 # Include non-standard external libraries by default in RPATH.
229 if(NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH)
230 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
235 # Ensure that executables in the build directory always have the same RPATH.
236 # This ensures relocatable binaries and reproducible builds (invariant of the
237 # build directory location). (Requires CMake 3.14)
238 set(CMAKE_BUILD_RPATH_USE_ORIGIN ON)
241 # Linking with wsetargv.obj enables "wildcard expansion" of
242 # command-line arguments.
243 set(WILDCARD_OBJ wsetargv.obj)
246 # Banner shown at top right of Qt welcome screen.
247 if(DEFINED ENV{WIRESHARK_VERSION_FLAVOR})
248 set(VERSION_FLAVOR "$ENV{WIRESHARK_VERSION_FLAVOR}")
250 set(VERSION_FLAVOR "Development Build")
253 # These are required in .rc files and manifests
254 set(VERSION_MAJOR ${PROJECT_MAJOR_VERSION})
255 set(VERSION_MINOR ${PROJECT_MINOR_VERSION})
256 set(VERSION_MICRO ${PROJECT_PATCH_VERSION})
257 set(VERSION_BUILD ${PROJECT_BUILD_VERSION})
258 set(RC_VERSION ${PROJECT_MAJOR_VERSION},${PROJECT_MINOR_VERSION},${PROJECT_PATCH_VERSION},${PROJECT_BUILD_VERSION})
260 message(STATUS "V: ${PROJECT_VERSION}, MaV: ${PROJECT_MAJOR_VERSION}, MiV: ${PROJECT_MINOR_VERSION}, PL: ${PROJECT_PATCH_VERSION}, EV: ${PROJECT_VERSION_EXTENSION}.")
263 include(UseMakePluginReg)
265 include(UseExecutableResources)
268 # The following snippet has been taken from
269 # https://github.com/USESystemEngineeringBV/cmake-eclipse-helper/wiki/HowToWorkaroundIndexer
270 # The eclipse indexer otherwise assumes __cplusplus=199711L which will lead to broken
271 # lookup tables for the epan libraries
272 # Check if CXX flags have been set to c++11 -> Setup Eclipse Indexer correctly!
273 # Also setup the project slightly different
274 if(CMAKE_EXTRA_GENERATOR MATCHES "Eclipse CDT4")
276 LIST(LENGTH CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS LIST_LEN)
277 if(LIST_LEN GREATER 0)
281 LIST(LENGTH CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS LIST_LEN)
282 if(LIST_LEN GREATER 0)
285 if(C_ENABLED EQUAL 1 AND CXX_ENABLED EQUAL 1)
286 # Combined project (C and CXX). This will confuse the indexer. For that reason
287 # we unsert set the __cplusplus variable for the indexer
288 list(FIND CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS "__cplusplus" GEN_MACRO_INDEX)
289 if(GEN_MACRO_INDEX GREATER -1)
290 list(REMOVE_AT CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${GEN_MACRO_INDEX})
291 list(REMOVE_AT CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${GEN_MACRO_INDEX})
293 SET(CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS} CACHE INTERNAL "")
294 elseif((CXX_ENABLED EQUAL 1) AND (CMAKE_CXX_FLAGS MATCHES ".*-std=c\\+\\+11.*"))
295 #add_definitions (-D__cplusplus=201103L)
296 # CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS
297 list(FIND CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS "199711L" GEN_MACRO_INDEX)
298 if(GEN_MACRO_INDEX GREATER -1)
299 list(REMOVE_AT CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${GEN_MACRO_INDEX})
300 list(INSERT CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${GEN_MACRO_INDEX} "201103L")
301 SET(CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS ${CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS} CACHE INTERNAL "")
311 if( DUMPCAP_INSTALL_OPTION STREQUAL "suid" )
312 set( DUMPCAP_SETUID "SETUID" )
314 set( DUMPCAP_SETUID )
316 if( NOT CMAKE_SYSTEM_NAME STREQUAL "Linux" AND
317 DUMPCAP_INSTALL_OPTION STREQUAL "capabilities" )
318 message( WARNING "Capabilities are only supported on Linux" )
319 set( DUMPCAP_INSTALL_OPTION )
322 set(OSS_FUZZ OFF CACHE BOOL "Whether building for oss-fuzz")
323 mark_as_advanced(OSS_FUZZ)
326 # In oss-fuzz mode, the fuzzing engine can be afl or libFuzzer.
327 message(FATAL_ERROR "Cannot force libFuzzer when using oss-fuzz")
329 # Must not depend on external dependencies so statically link all libs.
334 set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
338 # Linking can consume a lot of memory, especially when built with ASAN and
339 # static libraries (like oss-fuzz) or Debug mode. With Ninja, the number of
340 # parallel linker processes is constrained by job parallelism (-j), but this can
341 # be reduced further by setting "job pools" to a lower number.
343 if(CMAKE_MAKE_PROGRAM MATCHES "ninja" AND OSS_FUZZ)
344 # Assume oss-fuzz linker jobs do not require more than 1.2G per task
345 set(per_job_memory_mb 1200)
346 cmake_host_system_information(RESULT total_memory_mb QUERY TOTAL_PHYSICAL_MEMORY)
347 math(EXPR parallel_link_jobs "${total_memory_mb} / ${per_job_memory_mb}")
348 if(parallel_link_jobs LESS 1)
349 set(parallel_link_jobs 1)
351 set_property(GLOBAL APPEND PROPERTY JOB_POOLS link_job_pool=${parallel_link_jobs})
352 set(CMAKE_JOB_POOL_LINK link_job_pool)
353 message(STATUS "Ninja job pool size: ${parallel_link_jobs}")
356 # Always enable position-independent code when compiling, even for
357 # executables, so you can build position-independent executables.
358 # -pie is added below for non-MSVC, but requires objects to be built with
359 # -fPIC/-fPIE (so set CMAKE_POSITION_INDEPENDENT_CODE to enable that).
360 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
362 # Path to our generated executables (or wrapper scripts)
364 set(WS_PROGRAM_PATH ./run/$<CONFIG>)
366 set(WS_PROGRAM_PATH ./run)
369 if( CMAKE_C_COMPILER_ID MATCHES "MSVC")
370 if ((MSVC_VERSION LESS "1900") OR (MSVC_VERSION GREATER_EQUAL "2000"))
371 message(FATAL_ERROR "You are using an unsupported version of MSVC")
375 /DWIN32_LEAN_AND_MEAN
376 /D_CRT_SECURE_NO_DEPRECATE
377 # NOMINMAX keeps windows.h from defining "min" and "max" via windef.h.
378 # This avoids conflicts with the C++ standard library.
380 # -DPSAPI_VERSION=1 Programs that must run on earlier versions of Windows as well as Windows 7 and later
381 # versions should always call this function as GetProcessMemoryInfo. To ensure correct
382 # resolution of symbols, add Psapi.lib to the TARGETLIBS macro and compile the program
383 # with -DPSAPI_VERSION=1.To use run-time dynamic linking, load Psapi.dll.
384 # https://docs.microsoft.com/en-us/windows/win32/api/psapi/nf-psapi-getprocessmemoryinfo
385 # -D_ALLOW_KEYWORD_MACROS For VS2012 onwards the, C++ STL does not permit macro redefinitions of keywords
386 # (see https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/bb531344(v=vs.110))
387 # This definition prevents the complaint about the redefinition of inline by WinPCap
388 # in pcap-stdinc.h when compiling C++ files, e.g. the Qt UI
390 /D_ALLOW_KEYWORD_MACROS
393 if(NOT WIRESHARK_TARGET_PLATFORM STREQUAL "win64")
394 add_definitions("/D_BIND_TO_CURRENT_CRT_VERSION=1")
401 set(WS_LINK_FLAGS "/LARGEADDRESSAWARE /MANIFEST:NO /INCREMENTAL:NO /RELEASE")
403 # To do: Add /external:... See https://devblogs.microsoft.com/cppblog/broken-warnings-theory/
405 # /Zo Enhanced debugging of optimised code
406 # /utf-8 Set Source and Executable character sets to UTF-8
407 # VS2015(MSVC14): On by default when /Zi or /Z7 used.
408 # /guard:cf Control Flow Guard (compile and link).
409 # See https://docs.microsoft.com/en-us/windows/win32/secbp/control-flow-guard
410 # Note: This requires CMake 3.9.0 or newer.
411 # https://gitlab.kitware.com/cmake/cmake/commit/f973d49ab9d4c59b93f6dac812a94bb130200836
412 # /Qspectre Speculative execution attack mitigation
413 # See https://devblogs.microsoft.com/cppblog/spectre-mitigations-in-msvc/
414 list(APPEND LOCAL_CFLAGS /Zo /utf-8 /guard:cf)
415 set(WS_LINK_FLAGS "${WS_LINK_FLAGS} /guard:cf")
416 # /Qspectre is not available for VS2015 or older VS2017. Test for its availability.
417 set(WIRESHARK_COMMON_FLAGS /Qspectre)
419 if(ENABLE_CODE_ANALYSIS)
420 list(APPEND LOCAL_CFLAGS /analyze:WX-)
423 # Additional compiler warnings to be treated as "Level 3"
424 # when compiling Wireshark sources. (Selected from "level 4" warnings).
425 ## 4295: array is too small to include a terminating null character
426 ## 4100: unreferenced formal parameter
427 ## 4189: local variable is initialized but not referenced
428 # Disable warnings about about use of flexible array members:
429 ## 4200: nonstandard extension used : zero-sized array in struct/union
430 list(APPEND LOCAL_CFLAGS /w34295 /w34100 /w34189 /wd4200)
432 # We've matched these to specific compiler versions using the
433 # checks above. There's no need to pass them to check_c_compiler_flag
434 # or check_cxx_compiler_flag, which can be slow.
435 string(REPLACE ";" " " _flags "${LOCAL_CFLAGS}")
436 set(CMAKE_C_FLAGS "${_flags} ${CMAKE_C_FLAGS}")
437 set(CMAKE_CXX_FLAGS "${_flags} ${CMAKE_CXX_FLAGS}")
441 set(MIN_MACOS_VERSION 10.6) # Arbitrary.
442 if(CMAKE_OSX_DEPLOYMENT_TARGET)
443 if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS MIN_MACOS_VERSION)
444 message(FATAL_ERROR "We don't support building for macOS < ${MIN_MACOS_VERSION}")
446 set(MIN_MACOS_VERSION ${CMAKE_OSX_DEPLOYMENT_TARGET})
447 message(STATUS "Building for Mac OS X/OS X/macOS ${CMAKE_OSX_DEPLOYMENT_TARGET}")
449 elseif(CMAKE_OSX_DEPLOYMENT_TARGET)
450 message(FATAL_ERROR "CMAKE_OSX_DEPLOYMENT_TARGET only applies when building for macOS")
454 # Do whatever is necessary to enable as much C99 support as
455 # possible in the C compiler. Newer versions of compilers
456 # might default to supporting C99, but older versions may
457 # require a special flag.
459 # We do not want strict C99 support, as we may also want to
460 # use compiler extensions.
462 # Prior to CMake 3.1, setting CMAKE_C_STANDARD will not have
463 # any effect, so, unless and until we require CMake 3.1 or
464 # later, we have to do it ourselves on pre-3.1 CMake, so we
465 # just do it ourselves on all versions of CMake.
467 # Note: with CMake 3.1 through 3.5, the only compilers for
468 # which CMake handles CMAKE_C_STANDARD are GCC and Clang.
469 # 3.6 adds support only for Intel C; 3.9 adds support for
470 # PGI C, Sun C, and IBM XL C, and 3.10 adds support for
471 # Cray C and IAR C, but no version of CMake has support for
472 # HP C. Therefore, even if we use CMAKE_C_STANDARD with
473 # compilers for which CMake supports it, we may still have
474 # to do it ourselves on other compilers.
476 # In addition, CMake 3.5.2 seems to think that GCC versions
477 # less than 4.4 don't support -std=gnu99, which we need in
478 # order to get support for "for (int i = 0; i < n; i++) ;",
479 # which is another reason not to rely on CMake's CMAKE_C_STANDARD
482 # See the CMake documentation for the CMAKE_<LANG>_COMPILER_ID
483 # variables for a list of compiler IDs.
485 # We don't worry about MSVC; it doesn't have such a flag -
486 # either it doesn't support the C99 features we need at all,
487 # or it supports them regardless of the compiler flag.
489 # XXX - we add the flag for a given compiler to CMAKE_C_FLAGS,
490 # so we test whether it works and add it if we do. We don't
491 # test whether it's necessary in order to get the C99 features
492 # that we use; if we ever have a user who tries to compile with
493 # a compiler that can't be made to support those features, we
494 # can add a test to make sure we actually *have* C99 support.
496 if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR
497 CMAKE_C_COMPILER_ID MATCHES "Clang")
499 # We use -std=gnu99 rather than -std=c99 because, for
500 # some older compilers such as GCC 4.4.7, -std=gnu99
501 # is required to avoid errors about C99 constructs
502 # such as "for (int i = 0; i < n; i++) ;".
504 set(CMAKE_C_FLAGS "-std=gnu99 ${CMAKE_C_FLAGS}")
505 elseif(CMAKE_C_COMPILER_ID MATCHES "XL")
507 # We want support for extensions picked up for
508 # GNU C compatibility, so we use -qlanglvl=extc99.
510 set(CMAKE_C_FLAGS "-qlanglvl=extc99 ${CMAKE_C_FLAGS}")
511 elseif(CMAKE_C_COMPILER_ID MATCHES "HP")
513 # We also need to add -Wp,-H200000 to handle some large
514 # #defines we have; that flag is not necessary for the
515 # C++ compiler unless the "legacy" C++ preprocessor is
516 # being used (+legacy_cpp). We don't want the legacy
517 # preprocessor if it's not the default, so we just add
518 # -Wp,-H200000 to the C flags. (If there are older
519 # versions of aC++ that only support the legacy
520 # preprocessor, and require that we boost the table
521 # size, we'd have to check whether -Wp,-H200000 is
522 # supported by the C++ compiler and add it only if it is.)
524 set(CMAKE_C_FLAGS "-AC99 -Wp,-H200000 $WS_CFLAGS ${CMAKE_C_FLAGS}")
525 elseif(CMAKE_C_COMPILER_ID MATCHES "Sun")
527 # We also crank up the warning level.
529 set(CMAKE_C_FLAGS "-xc99 -v ${CMAKE_C_FLAGS}")
530 elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
531 set(CMAKE_C_FLAGS "-c99 ${CMAKE_C_FLAGS}")
534 if(CMAKE_C_COMPILER_ID MATCHES "Clang")
535 set(WIRESHARK_COMMON_FLAGS ${WIRESHARK_COMMON_FLAGS}
536 # avoid "argument unused during compilation" warnings
537 # (for example, when getting the -gsplit-dwarf option or
538 # when combining -fwrapv with -fno-strict-overflow)
542 set(WIRESHARK_COMMON_FLAGS ${WIRESHARK_COMMON_FLAGS}
543 -fexcess-precision=fast
547 list(APPEND WIRESHARK_COMMON_FLAGS
548 # The following are for C and C++
549 # -O<X> and -g get set by the CMAKE_BUILD_TYPE
563 -Wno-overlength-strings
571 # Code that may be worth looking into (coding practices)
573 if((NOT ENABLE_ASAN) AND (NOT ENABLE_TSAN) AND (NOT ENABLE_UBSAN) AND (NOT DISABLE_FRAME_LARGER_THAN_WARNING))
575 # Only do this if none of ASan, TSan, and UBSan are
576 # enabled; the instrumentation they add increases
577 # the stack usage - we only care about stack
578 # usage in normal operation.
580 set(WIRESHARK_COMMON_FLAGS ${WIRESHARK_COMMON_FLAGS}
581 -Wframe-larger-than=32768
585 list(APPEND WIRESHARK_C_ONLY_FLAGS
586 # The following are C only, not C++
588 -Wunused-const-variable
590 # XXX - some versions of GCC, including the one in at
591 # least some Xcode versions that come with Mac OS X
592 # 10.5, complain about variables in function and
593 # function pointer *declarations* shadowing other
594 # variables. The autoconf script checked for that; we
597 -Wold-style-definition
600 # Some versions of GCC, such as 4.3.2 and 4.4.5,
601 # generate logical-op warnings when strchr() is given a
602 # constant string. The autoconf script checked for that;
608 # Implicit function declarations are an error in C++ and most
609 # likely a programming error in C. Turn -Wimplicit-int and
610 # -Wimplicit-function-declaration into an error by default.
616 # The universal zero initializer (in C: struct s x = { 0 };) for
617 # structures with multiple members is perfectly legal, but some older
618 # compilers warn about it. Silence those older compilers.
620 if((CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "5.1") OR
621 (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "6.0") OR
622 (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "10.0"))
623 if(NOT CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_VERSION VERSION_LESS "4.7")
624 list(APPEND WIRESHARK_C_ONLY_FLAGS -Wno-missing-field-initializers)
626 # Silence warnings for initialization of nested structs like
627 # struct { struct { int a, b; } s; int c; } v = { 0 };
628 list(APPEND WIRESHARK_C_ONLY_FLAGS -Wno-missing-braces)
632 list(APPEND WIRESHARK_CXX_ONLY_FLAGS
637 # These are not enabled by default, because the warnings they
638 # produce are very hard or impossible to eliminate.
640 if(ENABLE_EXTRA_COMPILER_WARNINGS) # This overrides -Werror
641 list(APPEND WIRESHARK_COMMON_FLAGS
642 # The following are for C and C++
645 # As we use variadic macros, we don't want warnings
646 # about them, even with -Wpedantic.
650 # Various code blocks this one.
653 -fstrict-overflow -Wstrict-overflow=4
655 # Due to various places where APIs we don't control
656 # require us to cast away constness, we can probably
657 # never enable this one with -Werror.
661 # Some generated ASN.1 dissectors block this one;
662 # multiple function declarations for the same
663 # function are being generated.
667 # All the registration functions block these for now.
670 -Wmissing-declarations
672 # A bunch of "that might not work on SPARC" code blocks
673 # this one for now; some of it is code that *will* work
674 # on SPARC, such as casts of "struct sockaddr *" to
675 # "struct sockaddr_in *", which are required by some
676 # APIs such as getifaddrs().
680 # Works only with Clang
684 # Works only with Clang but generates a lot of warnings
685 # (about glib library not using Doxygen)
689 # Works only with GCC 7
691 -Wduplicated-branches
693 # No longer supported by El Capitan clang on C++
694 # XXX - is this one of those where CMake's check
695 # doesn't fail, so it won't reject this?
697 -fno-delete-null-pointer-checks
701 # Some loops are safe, but it's hard to convince the compiler of
702 # that. Always disable the warning on GCC 7 due to a bug that
703 # cause lots of false positives.
704 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81408
706 if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION MATCHES "^7\\.")
707 list(APPEND WIRESHARK_COMMON_FLAGS -Wunsafe-loop-optimizations)
710 list(APPEND WIRESHARK_C_ONLY_FLAGS
711 # The following are C only, not C++
713 # Due to various places where APIs we don't control
714 # require us to cast away constness, we can probably
715 # never enable this one with -Werror.
720 list(APPEND WIRESHARK_CXX_ONLY_FLAGS
724 # -Wpointer-sign is a default test we get with -Wall and
725 # -W, but for some reason we were suppressing it -
726 # unconditionally. Suppress it only without the extra
727 # warnings, so we can at least see how much we get.
728 # (This would have caught at least one error - the one
729 # in change https://code.wireshark.org/review/33234,
730 # which would have suggested that the wrong
731 # proto_tree_add_ret_ call was being used.)
733 list(APPEND WIRESHARK_C_ONLY_FLAGS
739 -DG_DISABLE_DEPRECATED
740 -DG_DISABLE_SINGLE_INCLUDES
743 set(WIRESHARK_LD_FLAGS
744 # See also CheckCLinkerFlag.cmake
752 # Counterhack to work around some cache magic in CHECK_C_SOURCE_COMPILES
753 include(CheckCCompilerFlag)
754 include(CheckCXXCompilerFlag)
757 set(BUILD_SHARED_LIBS 0)
759 set(BUILD_SHARED_LIBS 1)
762 function(test_compiler_flag _lang _this_flag _valid_flags_var)
763 string(MAKE_C_IDENTIFIER "${_lang}${_this_flag}_VALID" _flag_var)
764 set(_test_flags "${${_valid_flags_var}} ${_this_flag}")
765 if(_lang STREQUAL "C")
766 check_c_compiler_flag("${_test_flags}" ${_flag_var})
767 elseif(_lang STREQUAL "CXX")
768 check_cxx_compiler_flag("${_test_flags}" ${_flag_var})
770 message(FATAL_ERROR "Language must be C or CXX")
773 set(${_valid_flags_var} "${_test_flags}" PARENT_SCOPE)
777 foreach(THIS_FLAG ${WIRESHARK_COMMON_FLAGS} ${WIRESHARK_C_ONLY_FLAGS})
778 test_compiler_flag(C ${THIS_FLAG} ADDED_CMAKE_C_FLAGS)
780 set(CMAKE_C_FLAGS "${ADDED_CMAKE_C_FLAGS} ${CMAKE_C_FLAGS}")
782 foreach(THIS_FLAG ${WIRESHARK_COMMON_FLAGS} ${WIRESHARK_CXX_ONLY_FLAGS})
783 test_compiler_flag(CXX ${THIS_FLAG} ADDED_CMAKE_CXX_FLAGS)
785 set(CMAKE_CXX_FLAGS "${ADDED_CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
787 # Strips the source and build directory prefix from the __FILE__ macro to ensure
788 # reproducible builds. Supported since GCC 8, Clang support is pending.
789 if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
790 # If the build dir is within the source dir, CMake will use something
791 # like ../epan/dfilter/semcheck.c. Map these relative paths in addition
792 # to CMAKE_BINARY_DIR since compile_commands.json uses absolute paths.
793 file(RELATIVE_PATH _relative_source_dir "${CMAKE_BINARY_DIR}" "${CMAKE_SOURCE_DIR}")
794 string(REGEX REPLACE "/$" "" _relative_source_dir "${_relative_source_dir}")
796 check_c_compiler_flag(-fmacro-prefix-map=old=new C_fmacro_prefix_map_old_new_VALID)
797 check_cxx_compiler_flag(-fmacro-prefix-map=old=new CXX_fmacro_prefix_map_old_new_VALID)
799 if(${_lang}_fmacro_prefix_map_old_new_VALID)
800 set(_flags CMAKE_${_lang}_FLAGS)
801 set(${_flags} "${${_flags}} -fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=")
802 set(${_flags} "${${_flags}} -fmacro-prefix-map=${CMAKE_BINARY_DIR}/=")
803 if(_relative_source_dir MATCHES "\\.\\.$")
804 set(${_flags} "${${_flags}} -fmacro-prefix-map=${_relative_source_dir}/=")
810 include(CMakePushCheckState)
813 cmake_push_check_state()
814 set(CMAKE_REQUIRED_LIBRARIES "-fsanitize=address")
815 check_c_compiler_flag(-fsanitize=address C__fsanitize_address_VALID)
816 check_cxx_compiler_flag(-fsanitize=address CXX__fsanitize_address_VALID)
817 cmake_pop_check_state()
818 if(NOT C__fsanitize_address_VALID OR NOT CXX__fsanitize_address_VALID)
819 message(FATAL_ERROR "ENABLE_ASAN was requested, but not supported!")
821 set(CMAKE_C_FLAGS "-fsanitize=address ${CMAKE_C_FLAGS}")
822 set(CMAKE_CXX_FLAGS "-fsanitize=address ${CMAKE_CXX_FLAGS}")
823 # Disable ASAN for build-time tools, e.g. lemon
824 check_c_compiler_flag(-fno-sanitize=all C__fno_sanitize_all_VALID)
825 if(C__fno_sanitize_all_VALID)
826 set(NO_SANITIZE_CFLAGS "-fno-sanitize=all")
827 set(NO_SANITIZE_LDFLAGS "-fno-sanitize=all")
832 # Available since Clang >= 3.2 and GCC >= 4.8
833 cmake_push_check_state()
834 set(CMAKE_REQUIRED_LIBRARIES "-fsanitize=thread")
835 check_c_compiler_flag(-fsanitize=thread C__fsanitize_thread_VALID)
836 check_cxx_compiler_flag(-fsanitize=thread CXX__fsanitize_thread_VALID)
837 cmake_pop_check_state()
838 if(NOT C__fsanitize_thread_VALID OR NOT CXX__fsanitize_thread_VALID)
839 message(FATAL_ERROR "ENABLE_TSAN was requested, but not supported!")
841 set(CMAKE_C_FLAGS "-fsanitize=thread ${CMAKE_C_FLAGS}")
842 set(CMAKE_CXX_FLAGS "-fsanitize=thread ${CMAKE_CXX_FLAGS}")
843 set(WS_LINK_FLAGS "-fsanitize=thread ${WS_LINK_FLAGS}")
847 # Available since Clang >= 3.3 and GCC >= 4.9
848 cmake_push_check_state()
849 set(CMAKE_REQUIRED_LIBRARIES "-fsanitize=undefined")
850 check_c_compiler_flag(-fsanitize=undefined C__fsanitize_undefined_VALID)
851 check_cxx_compiler_flag(-fsanitize=undefined CXX__fsanitize_undefined_VALID)
852 cmake_pop_check_state()
853 if(NOT C__fsanitize_undefined_VALID OR NOT CXX__fsanitize_undefined_VALID)
854 message(FATAL_ERROR "ENABLE_UBSAN was requested, but not supported!")
856 set(CMAKE_C_FLAGS "-fsanitize=undefined ${CMAKE_C_FLAGS}")
857 set(CMAKE_CXX_FLAGS "-fsanitize=undefined ${CMAKE_CXX_FLAGS}")
861 # Available since Clang >= 6
862 # Will enable coverage flags which can be used by the fuzzshark target.
863 cmake_push_check_state()
864 set(CMAKE_REQUIRED_LIBRARIES "-fsanitize=fuzzer-no-link")
865 check_c_compiler_flag(-fsanitize=fuzzer C__fsanitize_fuzzer_no_link_VALID)
866 check_cxx_compiler_flag(-fsanitize=fuzzer CXX__fsanitize_fuzzer_no_link_VALID)
867 cmake_pop_check_state()
868 if(NOT C__fsanitize_fuzzer_no_link_VALID OR NOT CXX__fsanitize_fuzzer_no_link_VALID)
869 message(FATAL_ERROR "ENABLE_FUZZER was requested, but not supported!")
871 set(CMAKE_C_FLAGS "-fsanitize=fuzzer-no-link ${CMAKE_C_FLAGS}")
872 set(CMAKE_CXX_FLAGS "-fsanitize=fuzzer-no-link ${CMAKE_CXX_FLAGS}")
875 set(WERROR_COMMON_FLAGS "")
876 if(NOT DISABLE_WERROR AND NOT ENABLE_EXTRA_COMPILER_WARNINGS)
877 if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
878 set(WERROR_COMMON_FLAGS "/WX")
881 # If a warning has been enabled by -Wall or -W,
882 # and have specified -Werror, there appears to be
883 # no way, in Apple's llvm-gcc, to prevent that
884 # particular warning from giving an error - not
885 # with a pragma, not with -Wno-{warning}, and not
886 # with -Wno-error={warning}.
888 # Therefore, with that compiler, we just disable
891 if ((NOT APPLE) OR CMAKE_C_COMPILER_ID MATCHES "Clang")
892 check_c_compiler_flag(-Werror WERROR)
894 set(WERROR_COMMON_FLAGS "-Werror")
901 # Try to have the compiler default to hiding symbols, so that only
902 # symbols explicitly exported with WS_DLL_PUBLIC will be visible
903 # outside (shared) libraries; that way, more UN*X builds will catch
904 # failures to export symbols, rather than having that fail only on
907 # We don't need that with MSVC, as that's the default.
909 if( NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
911 # Try the GCC-and-compatible -fvisibility-hidden first.
913 check_c_compiler_flag(-fvisibility=hidden FVHIDDEN)
915 set(CMAKE_C_FLAGS "-fvisibility=hidden ${CMAKE_C_FLAGS}")
918 # OK, try the Sun^WOracle C -xldscope=hidden
920 check_c_compiler_flag(-xldscope=hidden XLDSCOPEHIDDEN)
922 set(CMAKE_C_FLAGS "-xldscope=hidden ${CMAKE_C_FLAGS}")
926 # If there is anything else, we might want to
927 # make a list of options to try, and try them
930 message(WARNING "Hiding shared library symbols is not supported by the compiler."
931 " All shared library symbols will be exported.")
936 include(CheckCLinkerFlag)
938 if(NOT CMAKE_C_COMPILER_ID MATCHES "MSVC" AND NOT OSS_FUZZ)
940 # The -pie linker option produces a position-independent executable.
941 # Some Linux distributions have this enabled by default in the compiler,
942 # so setting it here will be superfluous though.
944 # Note that linking with static libraries that are not position
945 # independent may fail, the user can set CMAKE_EXE_LINKER_FLAGS=-no-pie
948 if(CMAKE_VERSION VERSION_LESS "3.14")
949 check_c_linker_flag(-pie LINK_pie_VALID)
951 set(CMAKE_EXE_LINKER_FLAGS "-pie ${CMAKE_EXE_LINKER_FLAGS}")
954 include(CheckPIESupported)
955 check_pie_supported()
959 foreach(THIS_FLAG ${WIRESHARK_LD_FLAGS})
960 string(MAKE_C_IDENTIFIER "LINK${THIS_FLAG}_VALID" _flag_var)
961 check_c_linker_flag(${THIS_FLAG} ${_flag_var})
963 set(WS_LINK_FLAGS "${WS_LINK_FLAGS} ${THIS_FLAG}")
966 message(STATUS "Linker flags: ${WS_LINK_FLAGS}")
968 if(APPLE AND EXISTS /usr/local/opt/gettext)
969 # GLib on macOS requires libintl. Homebrew installs gettext (and
970 # libintl) in /usr/local/opt/gettext
971 include_directories(/usr/local/opt/gettext/include)
972 link_directories(/usr/local/opt/gettext/lib)
975 # Resets cache variables if the <PackageName>_LIBRARY has become invalid.
976 # Call it before a find_package(<PackageName> ...) invocation that uses
977 # find_library(<PackageName>_LIBRARY ...).
979 # Usage: reset_find_package(<PackageName> [<extra variables to clear>])
980 function(reset_find_package _package_name)
982 # find_library / find_package
983 ${_package_name}_LIBRARY
984 ${_package_name}_INCLUDE_DIR
986 ${_package_name}_LIBRARIES
987 ${_package_name}_INCLUDE_DIRS
989 ${_package_name}_DLL_DIR
990 ${_package_name}_DLLS
995 if(NOT ${_package_name}_LIBRARY OR EXISTS ${${_package_name}_LIBRARY})
996 # Cache variable is already missing or cache entry is valid.
999 message(STATUS "Package ${_package_name} has changed, clearing cache.")
1000 foreach(_var IN LISTS variables)
1001 unset(${_var} CACHE)
1005 # ws_find_package(<PackageName>
1006 # <CMakeOptions.txt boolean variable>
1007 # <cmakeconfig.h.in macro definition>
1008 # [remaining find_package() arguments])
1009 macro(ws_find_package _package_name _enable_package _package_cmakedefine)
1010 if(${_enable_package})
1011 # Clear outdated cache variables if not already.
1012 reset_find_package(${_package_name})
1013 find_package(${_package_name} ${ARGN})
1014 if(${_package_name}_FOUND)
1015 set(${_package_cmakedefine} 1)
1020 # The minimum package list
1022 reset_find_package(GLIB2 GLIB2_MAIN_INCLUDE_DIR GLIB2_INTERNAL_INCLUDE_DIR)
1023 find_package(GLIB2 "2.32.0" REQUIRED)
1024 include_directories(SYSTEM ${GLIB2_INCLUDE_DIRS})
1025 reset_find_package(GMODULE2)
1026 find_package(GMODULE2)
1027 reset_find_package(GTHREAD2)
1028 find_package(GTHREAD2 REQUIRED)
1029 reset_find_package(GCRYPT GCRYPT_ERROR_LIBRARY)
1030 find_package(GCRYPT "1.4.2" REQUIRED)
1031 # C Asynchronous resolver
1032 reset_find_package(CARES)
1033 find_package(CARES "1.5.0" REQUIRED)
1034 find_package(LEX REQUIRED)
1035 find_package(YACC REQUIRED)
1036 find_package(Perl REQUIRED)
1038 if(CMAKE_VERSION VERSION_LESS "3.12")
1039 # Locate the Python interpreter. Finds the wrong (Python 2) version if:
1040 # - PATH contains python3.6, but not python3 (3.4). Affects RHEL7+EPEL.
1041 # - Path contains C:\Python27 but not C:\Python37 (which is installed,
1042 # but not present in PATH).
1043 find_package(PythonInterp 3.4 REQUIRED)
1045 find_package(Python3 3.4 REQUIRED)
1046 # Several files (including LocatePythonModule) still use the old name
1047 # from FindPythonInterp, let's stick to it for now.
1048 set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
1052 find_package(Gettext)
1053 find_package(M REQUIRED)
1056 if(BUILD_sshdump OR BUILD_ciscodump)
1057 set(ENABLE_LIBSSH ON)
1059 set(ENABLE_LIBSSH OFF)
1061 ws_find_package(LIBSSH ENABLE_LIBSSH HAVE_LIBSSH "0.6")
1063 ws_find_package(PCAP ENABLE_PCAP HAVE_LIBPCAP)
1064 ws_find_package(AIRPCAP ENABLE_AIRPCAP HAVE_AIRPCAP)
1065 ws_find_package(Systemd BUILD_sdjournal HAVE_SYSTEMD)
1069 # Untested, may not work if CMAKE_PREFIX_PATH gets overwritten
1070 # somewhere. The if WIN32 in this place is annoying as well.
1072 set(QT5_BASE_PATH "$ENV{QT5_BASE_DIR}")
1073 set(CMAKE_PREFIX_PATH "${QT5_BASE_PATH}")
1075 if(APPLE AND EXISTS /usr/local/opt/qt5)
1076 # Homebrew installs Qt5 (up to at least 5.11.0) in
1077 # /usr/local/qt5. Ensure that it can be found by CMake
1078 # since it is not in the default /usr/local prefix.
1079 # Add it to PATHS so that it doesn't override the
1080 # CMAKE_PREFIX_PATH environment variable.
1081 # QT_FIND_PACKAGE_OPTIONS should be passed to find_package,
1082 # e.g. find_package(Qt5Core ${QT_FIND_PACKAGE_OPTIONS})
1083 list(APPEND QT_FIND_PACKAGE_OPTIONS PATHS /usr/local/opt/qt5)
1094 list(APPEND QT_PACKAGELIST Qt5MacExtras)
1095 ws_find_package(Sparkle ENABLE_SPARKLE HAVE_SOFTWARE_UPDATE)
1098 list(APPEND QT_PACKAGELIST Qt5WinExtras)
1100 foreach(_qt_package IN LISTS QT_PACKAGELIST)
1101 find_package(${_qt_package} REQUIRED ${QT_FIND_PACKAGE_OPTIONS})
1102 list(APPEND QT_LIBRARIES ${${_qt_package}_LIBRARIES})
1103 list(APPEND QT_INCLUDE_DIRS ${${_qt_package}_INCLUDE_DIRS})
1104 list(APPEND QT_COMPILE_DEFINITIONS ${${_qt_package}_COMPILE_DEFINITIONS})
1107 if(Qt5MacExtras_FOUND)
1108 set(QT_MACEXTRAS_LIB 1)
1112 # MaxMind DB address resolution
1113 ws_find_package(MaxMindDB BUILD_mmdbresolve HAVE_MAXMINDDB)
1116 reset_find_package(SMI SMI_SHARE_DIR)
1117 ws_find_package(SMI ENABLE_SMI HAVE_LIBSMI)
1119 # Support for TLS decryption using RSA private keys.
1120 ws_find_package(GNUTLS ENABLE_GNUTLS HAVE_LIBGNUTLS "3.2.0")
1123 ws_find_package(KERBEROS ENABLE_KERBEROS HAVE_KERBEROS)
1126 ws_find_package(ZLIB ENABLE_ZLIB HAVE_ZLIB)
1128 # Minizip compression
1129 ws_find_package(Minizip ENABLE_MINIZIP HAVE_MINIZIP)
1131 # Brotli compression
1132 ws_find_package(BROTLI ENABLE_BROTLI HAVE_BROTLI)
1135 ws_find_package(LZ4 ENABLE_LZ4 HAVE_LZ4)
1137 # Snappy compression
1138 ws_find_package(SNAPPY ENABLE_SNAPPY HAVE_SNAPPY)
1141 ws_find_package(ZSTD ENABLE_ZSTD HAVE_ZSTD "1.0.0")
1143 # Enhanced HTTP/2 dissection
1144 ws_find_package(NGHTTP2 ENABLE_NGHTTP2 HAVE_NGHTTP2)
1146 # Embedded Lua interpreter
1147 ws_find_package(LUA ENABLE_LUA HAVE_LUA "5.1")
1149 ws_find_package(NL ENABLE_NETLINK HAVE_LIBNL)
1151 ws_find_package(SBC ENABLE_SBC HAVE_SBC)
1153 ws_find_package(SPANDSP ENABLE_SPANDSP HAVE_SPANDSP)
1155 ws_find_package(BCG729 ENABLE_BCG729 HAVE_BCG729)
1157 # CMake 3.9 and below used 'LIBXML2_LIBRARIES' as the name of the cache entry
1158 # storing the find_library result. Transfer it to the new cache variable such
1159 # that reset_find_package can detect and clear outdated cache variables.
1160 if(DEFINED LIBXML2_LIBRARIES AND NOT DEFINED LIBXML2_LIBRARY)
1161 set(LIBXML2_LIBRARY ${LIBXML2_LIBRARIES} CACHE FILEPATH "")
1163 # Call reset_find_package explicitly since variables are in upper case.
1164 reset_find_package(LIBXML2)
1165 ws_find_package(LibXml2 ENABLE_LIBXML2 HAVE_LIBXML2)
1166 if(NOT LIBXML2_FOUND)
1167 # CMake 3.9 and below used LIBXML2_LIBRARIES as the name of
1168 # the cache entry storing the find_library result.
1169 # Current CMake (3.13) and below sets LIBXML2_LIBRARIES and LIBXML2_INCLUDE_DIRS
1170 # to a non-empty value, be sure to clear it when not found.
1171 set(LIBXML2_LIBRARIES "")
1172 set(LIBXML2_INCLUDE_DIRS "")
1176 ws_find_package(CAP ENABLE_CAP HAVE_LIBCAP)
1178 find_package(SETCAP)
1181 # Include minizip include directories
1183 include_directories(
1184 ${MINIZIP_INCLUDE_DIRS}
1187 set(MINIZIP_LIBRARY "")
1190 # Windows version updates
1191 ws_find_package(WINSPARKLE ENABLE_WINSPARKLE HAVE_SOFTWARE_UPDATE)
1193 find_package( Asciidoctor 1.5 )
1195 find_package(POD REQUIRED)
1197 find_package(DOXYGEN)
1199 # The SpeexDSP resampler is required iff building wireshark or sharkd.
1200 if(BUILD_wireshark OR BUILD_sharkd)
1201 find_package(SpeexDSP)
1203 set(HAVE_SPEEXDSP 1)
1205 add_subdirectory(speexdsp)
1206 set(SPEEXDSP_INCLUDE_DIRS "")
1207 set(SPEEXDSP_LIBRARIES "speexresampler")
1211 # dist target that prepares source dir
1212 # XXX Duplicated in the RPM section below.
1213 add_custom_target(dist
1214 COMMAND ${CMAKE_BINARY_DIR}/packaging/source/git-export-release.sh -d "${CMAKE_BINARY_DIR}"
1215 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
1218 if(GNUTLS_FOUND AND NOT GNUTLS_VERSION VERSION_LESS "3.4.0")
1219 # While all Linux and Windows builds have PKCS #11 support enabled,
1220 # macos-setup.sh explicitly disables it using --without-p11-kit.
1222 # Require at least GnuTLS 3.4.0 such that public keys can be calculated
1223 # from PKCS #11 private keys.
1224 include(CheckSymbolExists)
1225 cmake_push_check_state()
1227 set(CMAKE_REQUIRED_DEFINITIONS -Dssize_t=int)
1229 set(CMAKE_REQUIRED_INCLUDES ${GNUTLS_INCLUDE_DIRS})
1230 set(CMAKE_REQUIRED_LIBRARIES ${GNUTLS_LIBRARIES})
1231 check_symbol_exists(gnutls_pkcs11_obj_list_import_url4 gnutls/pkcs11.h HAVE_GNUTLS_PKCS11)
1232 cmake_pop_check_state()
1236 if (Qt5Widgets_VERSION VERSION_LESS 5.2)
1237 message(FATAL_ERROR "Qt 5.2 or later is required.")
1239 if (Qt5Widgets_VERSION VERSION_GREATER 5.6
1240 AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang"))
1241 # Qt 5.7 and later require C++ 11.
1242 set(CMAKE_CXX_STANDARD 11)
1243 set(CMAKE_CXX_STANDARD_REQUIRED ON)
1245 if(NOT DEFINED MOC_OPTIONS)
1246 # Squelch moc verbose "nothing to do" output
1247 set(MOC_OPTIONS -nn)
1250 # CMake uses qmake to find Qt4. It relies on Qt's CMake modules
1251 # to find Qt5. This means that we can't assume that the qmake
1252 # in our PATH is the correct one. We can fetch qmake's location
1253 # from Qt5::qmake, which is is defined in Qt5CoreConfigExtras.cmake.
1254 get_target_property(QT_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION)
1255 get_filename_component(_qt_bin_path "${QT_QMAKE_EXECUTABLE}" DIRECTORY)
1256 set(QT_BIN_PATH "${_qt_bin_path}" CACHE INTERNAL
1257 "Path to qmake, macdeployqt, windeployqt, and other Qt utilities."
1259 # Use qmake to find windeployqt and macdeployqt. Ideally one of
1260 # the modules in ${QTDIR}/lib/cmake would do this for us.
1262 find_program(QT_WINDEPLOYQT_EXECUTABLE windeployqt
1263 HINTS "${QT_BIN_PATH}"
1264 DOC "Path to the windeployqt utility."
1266 if(Qt5Widgets_VERSION VERSION_GREATER "5.5.999")
1267 set(QT_WINDEPLOYQT_EXTRA_OPTS --pdb)
1271 find_program(QT_MACDEPLOYQT_EXECUTABLE macdeployqt
1272 HINTS "${QT_BIN_PATH}"
1273 DOC "Path to the macdeployqt utility."
1275 find_program(DMGBUILD_EXECUTABLE dmgbuild
1276 DOC "Path to the dmgbuild utility"
1278 # https://doc.qt.io/qt-5.11/supported-platforms-and-configurations.html
1279 # CMake < 3.7 doesn't support VERSION_GREATER_EQUAL.
1280 if(Qt5Widgets_VERSION VERSION_GREATER "5.11.999")
1281 set(MIN_MACOS_VERSION 10.12)
1282 elseif(Qt5Widgets_VERSION VERSION_GREATER "5.9.999")
1283 set(MIN_MACOS_VERSION 10.11)
1284 elseif(Qt5Widgets_VERSION VERSION_GREATER "5.8.999")
1285 set(MIN_MACOS_VERSION 10.10)
1286 elseif(Qt5Widgets_VERSION VERSION_GREATER "5.7.999")
1287 set(MIN_MACOS_VERSION 10.9)
1288 elseif(Qt5Widgets_VERSION VERSION_GREATER "5.4.999")
1289 set(MIN_MACOS_VERSION 10.8)
1291 if(CMAKE_OSX_DEPLOYMENT_TARGET AND CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS MIN_MACOS_VERSION)
1292 message(FATAL_ERROR "Qt version ${Qt5Widgets_VERSION} requires CMAKE_OSX_DEPLOYMENT_TARGET (${CMAKE_OSX_DEPLOYMENT_TARGET}) >= ${MIN_MACOS_VERSION}")
1298 if(ENABLE_CHECKHF_CONFLICT)
1299 set(ENABLE_CHECK_FILTER 1)
1303 # Platform-specific additional libraries.
1306 set(WIN_PSAPI_LIBRARY psapi.lib)
1307 set(WIN_WS2_32_LIBRARY ws2_32.lib)
1308 set(WIN_COMCTL32_LIBRARY comctl32.lib )
1309 set(WIN_VERSION_LIBRARY version.lib)
1314 # We assume that APPLE means macOS so that we have the macOS
1317 set(HAVE_MACOS_FRAMEWORKS 1)
1318 FIND_LIBRARY (APPLE_APPLICATION_SERVICES_LIBRARY ApplicationServices)
1319 FIND_LIBRARY (APPLE_APPKIT_LIBRARY AppKit)
1320 FIND_LIBRARY (APPLE_CORE_FOUNDATION_LIBRARY CoreFoundation)
1321 FIND_LIBRARY (APPLE_SYSTEM_CONFIGURATION_LIBRARY SystemConfiguration)
1324 include(ConfigureChecks.cmake)
1327 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1329 if(ENABLE_CCACHE AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang"))
1330 # https://stackoverflow.com/questions/1815688/how-to-use-ccache-with-cmake/24305849#24305849
1331 find_program(CCACHE_EXECUTABLE ccache)
1332 if(CCACHE_EXECUTABLE)
1333 set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_EXECUTABLE}")
1334 set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_EXECUTABLE}")
1338 # The top level checkAPIs target, add before subdirectory calls so it's avaiable to all
1339 add_custom_target(checkAPI)
1340 set_target_properties(checkAPI
1343 EXCLUDE_FROM_ALL True
1344 EXCLUDE_FROM_DEFAULT_BUILD True
1347 include( UseCheckAPI )
1349 # Target platform locations
1350 # UN*X in general, including macOS if not building an app bundle:
1351 # $DESTDIR/lib/wireshark/extcap
1352 # Windows: $DESTDIR/extcap
1353 # macOS app bundle: Wireshark.app/Contents/Resources/share/wireshark/extcap
1354 # If you change the nesting level be sure to check also the INSTALL_RPATH
1357 set(EXTCAP_INSTALL_LIBDIR "extcap" CACHE INTERNAL "The extcap dir")
1359 set(EXTCAP_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/extcap" CACHE INTERNAL "The extcap dir")
1364 # As https://developer.apple.com/library/archive/technotes/tn2206/_index.html
1367 # "Note that a location where code is expected to reside cannot generally
1368 # contain directories full of nested code, because those directories tend
1369 # to be interpreted as bundles. So this occasional practice is not
1370 # recommended and not officially supported. If you do do this, do not use
1371 # periods in the directory names. The code signing machinery interprets
1372 # directories with periods in their names as code bundles and will reject
1373 # them if they don't conform to the expected code bundle layout."
1375 set(PLUGIN_PATH_ID "${PROJECT_MAJOR_VERSION}-${PROJECT_MINOR_VERSION}")
1377 set(PLUGIN_PATH_ID "${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}")
1380 # Directory where plugins and Lua dissectors can be found.
1382 set(PLUGIN_INSTALL_LIBDIR "plugins" CACHE INTERNAL "The plugin dir")
1384 set(PLUGIN_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/plugins" CACHE INTERNAL "The plugin dir")
1386 set(PLUGIN_INSTALL_VERSION_LIBDIR "${PLUGIN_INSTALL_LIBDIR}/${PLUGIN_PATH_ID}")
1387 set(PLUGIN_VERSION_DIR "plugins/${PLUGIN_PATH_ID}")
1389 add_subdirectory( capchild )
1390 add_subdirectory( caputils )
1391 add_subdirectory( doc )
1392 add_subdirectory( docbook EXCLUDE_FROM_ALL )
1393 add_subdirectory( epan )
1394 add_subdirectory( extcap )
1395 add_subdirectory( randpkt_core )
1396 add_subdirectory( tools/lemon )
1397 add_subdirectory( ui )
1398 add_subdirectory( wiretap )
1399 add_subdirectory( writecap )
1401 # Location of our data files. This should be set to a value that allows
1402 # running from the build directory on Windows, on macOS when building an
1403 # application bundle, and on UNIX in general if
1404 # WIRESHARK_RUN_FROM_BUILD_DIRECTORY is set.
1405 if(ENABLE_APPLICATION_BUNDLE)
1406 if(CMAKE_CFG_INTDIR STREQUAL ".")
1407 set(_datafile_dir "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/share/wireshark")
1410 set(_datafile_dir "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}/Wireshark.app/Contents/Resources/share/wireshark")
1412 elseif(NOT CMAKE_CFG_INTDIR STREQUAL ".")
1413 # Visual Studio, Xcode, etc.
1414 set(_datafile_dir "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}")
1416 # Makefile, Ninja, etc.
1417 set(_datafile_dir "${CMAKE_BINARY_DIR}/run")
1420 set(DATAFILE_DIR ${_datafile_dir} CACHE INTERNAL "Build time data file location.")
1422 # wsutil must be added after DATAFILE_DIR is set such that filesystem.c can
1423 # learn about the directory location.
1424 add_subdirectory( wsutil )
1426 if(BUILD_wireshark AND QT_FOUND)
1427 add_subdirectory( ui/qt )
1430 # Location of our plugins. PLUGIN_DIR should allow running
1431 # from the build directory similar to DATAFILE_DIR above.
1433 # Target platform locations
1434 # UN*X in general, including macOS if not building an app bundle:
1435 # $DESTDIR/lib/wireshark/plugins/$VERSION
1436 # Windows: $DESTDIR/wireshark/plugins/$VERSION
1437 # macOS app bundle: Wireshark.app/Contents/PlugIns/wireshark
1439 add_custom_target(plugins)
1440 set_target_properties(plugins PROPERTIES FOLDER "Plugins")
1442 plugins/epan/ethercat
1443 plugins/epan/gryphon
1447 plugins/epan/profinet
1448 plugins/epan/stats_tree
1449 plugins/epan/transum
1450 plugins/epan/unistim
1452 plugins/epan/wimaxasncp
1453 plugins/epan/wimaxmacphy
1454 plugins/wiretap/usbdump
1456 plugins/codecs/l16_mono
1457 ${CUSTOM_PLUGIN_SRC_DIR}
1460 list(APPEND PLUGIN_SRC_DIRS
1466 list(APPEND PLUGIN_SRC_DIRS
1471 list(APPEND PLUGIN_SRC_DIRS
1476 # Build demo plugin, only if asked explicitly
1477 if(ENABLE_PLUGIN_IFDEMO)
1480 plugins/epan/pluginifdemo
1485 set(PLUGIN_SRC_DIRS )
1488 if(ENABLE_APPLICATION_BUNDLE)
1489 if(CMAKE_CFG_INTDIR STREQUAL ".")
1490 set(_plugin_dir "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/PlugIns/wireshark/${PLUGIN_PATH_ID}")
1493 set(_plugin_dir "${CMAKE_BINARY_DIR}/run/$<CONFIG>/Wireshark.app/Contents/PlugIns/wireshark/${PLUGIN_PATH_ID}")
1495 elseif(WIN32 AND NOT CMAKE_CFG_INTDIR STREQUAL ".")
1496 set(_plugin_dir "${CMAKE_BINARY_DIR}/run/$<CONFIG>/${PLUGIN_VERSION_DIR}")
1498 set(_plugin_dir "${DATAFILE_DIR}/${PLUGIN_VERSION_DIR}")
1500 set (PLUGIN_DIR ${_plugin_dir} CACHE INTERNAL "Build time plugin location.")
1502 foreach(_plugin_src_dir ${PLUGIN_SRC_DIRS})
1503 add_subdirectory( ${_plugin_src_dir} )
1506 if(ENABLE_PCAP_NG_DEFAULT)
1507 set(PCAP_NG_DEFAULT 1)
1510 # Large file support (e.g. make off_t 64 bit if supported)
1511 include(gmxTestLargeFiles)
1512 gmx_test_large_files(GMX_LARGEFILES)
1514 set( VERSION ${PROJECT_VERSION} )
1515 if(VCSVERSION_OVERRIDE)
1516 # Allow distributors to override detection of the Git tag and version.
1517 string(CONFIGURE "#define VCSVERSION \"@VCSVERSION_OVERRIDE@\"\n"
1518 _version_h_contents ESCAPE_QUOTES)
1519 file(WRITE "${CMAKE_BINARY_DIR}/version.h" "${_version_h_contents}")
1520 message(STATUS "VCSVERSION_OVERRIDE: ${VCSVERSION_OVERRIDE}")
1522 add_custom_target(version
1523 BYPRODUCTS version.h
1524 COMMAND ${PERL_EXECUTABLE}
1525 ${CMAKE_SOURCE_DIR}/tools/make-version.pl
1528 set_target_properties(version PROPERTIES FOLDER "Auxiliary")
1531 set( configure_input "Built with CMake ${CMAKE_VERSION}" )
1532 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
1534 configure_file(${CMAKE_SOURCE_DIR}/ws_version.h.in ${CMAKE_BINARY_DIR}/ws_version.h)
1536 set( prefix "${CMAKE_INSTALL_PREFIX}" )
1537 set( exec_prefix "\${prefix}" )
1538 set( libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}" )
1539 set( includedir "\${prefix}/include" )
1540 set( plugindir "\${libdir}/wireshark/${PLUGIN_VERSION_DIR}" )
1543 file(GLOB TOP_LEVEL_SOURCE_LIST *.c *.cpp *.h)
1544 string (REPLACE ";" " " DOXYGEN_TOP_LEVEL_SOURCES "${TOP_LEVEL_SOURCE_LIST}")
1545 set(DOXYGEN_INPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
1546 set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
1550 image/libwireshark.rc
1555 image/wireshark.exe.manifest
1556 packaging/macosx/Info.plist
1557 packaging/macosx/dmgbuild-settings.py
1558 packaging/macosx/osx-app.sh
1559 packaging/macosx/osx-dmg.sh
1560 packaging/source/git-export-release.sh
1563 foreach( _cfg_file ${CFG_OUT_FILES} )
1564 configure_file( ${CMAKE_SOURCE_DIR}/${_cfg_file}.in ${CMAKE_BINARY_DIR}/${_cfg_file} @ONLY )
1567 include(FeatureSummary)
1568 set_package_properties(SBC PROPERTIES
1569 DESCRIPTION "Bluetooth low-complexity, subband codec (SBC) decoder"
1570 URL "https://git.kernel.org/pub/scm/bluetooth/sbc.git"
1571 PURPOSE "Support for playing SBC codec in RTP player"
1573 set_package_properties(SPANDSP PROPERTIES
1574 DESCRIPTION "a library of many DSP functions for telephony"
1575 URL "https://www.soft-switch.org"
1576 PURPOSE "Support for G.722 and G.726 codecs in RTP player"
1578 set_package_properties(BCG729 PROPERTIES
1579 DESCRIPTION "G.729 decoder"
1580 URL "https://www.linphone.org/technical-corner/bcg729/overview"
1581 PURPOSE "Support for G.729 codec in RTP player"
1583 set_package_properties(LIBXML2 PROPERTIES
1584 DESCRIPTION "XML parsing library"
1585 URL "http://xmlsoft.org/"
1586 PURPOSE "Read XML configuration files in EPL dissector"
1588 set_package_properties(LIBSSH PROPERTIES
1589 DESCRIPTION "Library for implementing SSH clients"
1590 URL "https://www.libssh.org/"
1591 PURPOSE "extcap remote SSH interfaces (sshdump, ciscodump)"
1593 set_package_properties(LZ4 PROPERTIES
1594 DESCRIPTION "LZ4 is lossless compression algorithm used in some protocol (CQL...)"
1595 URL "http://www.lz4.org"
1596 PURPOSE "LZ4 decompression in CQL and Kafka dissectors"
1598 set_package_properties(SNAPPY PROPERTIES
1599 DESCRIPTION "A fast compressor/decompressor from Google"
1600 URL "https://google.github.io/snappy/"
1601 PURPOSE "Snappy decompression in CQL and Kafka dissectors"
1603 set_package_properties(ZSTD PROPERTIES
1604 DESCRIPTION "A compressor/decompressor from Facebook providing better compression than Snappy at a cost of speed"
1605 URL "https://facebook.github.io/zstd/"
1606 PURPOSE "Zstd decompression in Kafka dissector"
1608 set_package_properties(NGHTTP2 PROPERTIES
1609 DESCRIPTION "HTTP/2 C library and tools"
1610 URL "https://nghttp2.org"
1611 PURPOSE "Header decompression in HTTP2"
1613 set_package_properties(CARES PROPERTIES
1614 DESCRIPTION "Library for asynchronous DNS requests"
1615 URL "https://c-ares.haxx.se/"
1616 PURPOSE "DNS name resolution for captures"
1618 set_package_properties(Systemd PROPERTIES
1619 URL "https://freedesktop.org/wiki/Software/systemd/"
1620 DESCRIPTION "System and Service Manager (libraries)"
1621 PURPOSE "Support for systemd journal extcap interface (sdjournal)"
1623 set_package_properties(NL PROPERTIES
1624 URL "https://www.infradead.org/~tgr/libnl/"
1625 DESCRIPTION "Libraries for using the Netlink protocol on Linux"
1626 PURPOSE "Support for managing wireless 802.11 interfaces"
1628 set_package_properties(MaxMindDB PROPERTIES
1629 URL "https://github.com/maxmind/libmaxminddb"
1630 DESCRIPTION "C library for the MaxMind DB file format"
1631 PURPOSE "Support for GeoIP lookup"
1633 set_package_properties(SpeexDSP PROPERTIES
1634 URL "https://www.speex.org/"
1635 DESCRIPTION "SpeexDSP is a patent-free, Open Source/Free Software DSP library"
1636 PURPOSE "RTP audio resampling"
1638 set_package_properties(Minizip PROPERTIES
1639 URL "https://www.winimage.com/zLibDll/minizip.html"
1640 DESCRIPTION "C library for supporting zip/unzip functionality"
1641 PURPOSE "Support for profiles import/export"
1644 string(TOUPPER "${CMAKE_BUILD_TYPE}" _build_type)
1645 message(STATUS "C-Flags: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${_build_type}}")
1646 message(STATUS "CXX-Flags: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${_build_type}}")
1647 if(WERROR_COMMON_FLAGS)
1648 message(STATUS "Warnings as errors enabled: ${WERROR_COMMON_FLAGS}")
1650 message(STATUS "Warnings as errors disabled")
1653 feature_summary(WHAT ALL)
1655 # Should this be part of libui?
1658 ui/win32/console_win32.c
1659 ui/win32/file_dlg_win32.c
1661 set(PLATFORM_UI_RC_FILES
1662 image/file_dlg_win32.rc
1666 ui/macosx/cocoa_bridge.mm
1669 list(APPEND PLATFORM_UI_SRC ui/macosx/sparkle_bridge.m)
1674 ${CMAKE_SOURCE_DIR}/ui/cli/tap-credentials.c
1675 ${CMAKE_SOURCE_DIR}/ui/cli/tap-camelsrt.c
1676 ${CMAKE_SOURCE_DIR}/ui/cli/tap-diameter-avp.c
1677 ${CMAKE_SOURCE_DIR}/ui/cli/tap-expert.c
1678 ${CMAKE_SOURCE_DIR}/ui/cli/tap-exportobject.c
1679 ${CMAKE_SOURCE_DIR}/ui/cli/tap-endpoints.c
1680 ${CMAKE_SOURCE_DIR}/ui/cli/tap-flow.c
1681 ${CMAKE_SOURCE_DIR}/ui/cli/tap-follow.c
1682 ${CMAKE_SOURCE_DIR}/ui/cli/tap-funnel.c
1683 ${CMAKE_SOURCE_DIR}/ui/cli/tap-gsm_astat.c
1684 ${CMAKE_SOURCE_DIR}/ui/cli/tap-hosts.c
1685 ${CMAKE_SOURCE_DIR}/ui/cli/tap-httpstat.c
1686 ${CMAKE_SOURCE_DIR}/ui/cli/tap-icmpstat.c
1687 ${CMAKE_SOURCE_DIR}/ui/cli/tap-icmpv6stat.c
1688 ${CMAKE_SOURCE_DIR}/ui/cli/tap-iostat.c
1689 ${CMAKE_SOURCE_DIR}/ui/cli/tap-iousers.c
1690 ${CMAKE_SOURCE_DIR}/ui/cli/tap-macltestat.c
1691 ${CMAKE_SOURCE_DIR}/ui/cli/tap-protocolinfo.c
1692 ${CMAKE_SOURCE_DIR}/ui/cli/tap-protohierstat.c
1693 ${CMAKE_SOURCE_DIR}/ui/cli/tap-rlcltestat.c
1694 ${CMAKE_SOURCE_DIR}/ui/cli/tap-rpcprogs.c
1695 ${CMAKE_SOURCE_DIR}/ui/cli/tap-rtd.c
1696 ${CMAKE_SOURCE_DIR}/ui/cli/tap-rtp.c
1697 ${CMAKE_SOURCE_DIR}/ui/cli/tap-rtspstat.c
1698 ${CMAKE_SOURCE_DIR}/ui/cli/tap-sctpchunkstat.c
1699 ${CMAKE_SOURCE_DIR}/ui/cli/tap-simple_stattable.c
1700 ${CMAKE_SOURCE_DIR}/ui/cli/tap-sipstat.c
1701 ${CMAKE_SOURCE_DIR}/ui/cli/tap-smbsids.c
1702 ${CMAKE_SOURCE_DIR}/ui/cli/tap-srt.c
1703 ${CMAKE_SOURCE_DIR}/ui/cli/tap-stats_tree.c
1704 ${CMAKE_SOURCE_DIR}/ui/cli/tap-sv.c
1705 ${CMAKE_SOURCE_DIR}/ui/cli/tap-wspstat.c
1706 ${CUSTOM_TSHARK_TAP_SRC}
1732 ${CMAKE_BINARY_DIR}/doc/AUTHORS-SHORT
1733 ${CMAKE_BINARY_DIR}/doc/androiddump.html
1734 ${CMAKE_BINARY_DIR}/doc/udpdump.html
1735 ${CMAKE_BINARY_DIR}/doc/capinfos.html
1736 ${CMAKE_BINARY_DIR}/doc/captype.html
1737 ${CMAKE_BINARY_DIR}/doc/ciscodump.html
1738 ${CMAKE_BINARY_DIR}/doc/dftest.html
1739 ${CMAKE_BINARY_DIR}/doc/dumpcap.html
1740 ${CMAKE_BINARY_DIR}/doc/editcap.html
1741 ${CMAKE_BINARY_DIR}/doc/extcap.html
1742 ${CMAKE_BINARY_DIR}/doc/mergecap.html
1743 ${CMAKE_BINARY_DIR}/doc/randpkt.html
1744 ${CMAKE_BINARY_DIR}/doc/randpktdump.html
1745 ${CMAKE_BINARY_DIR}/doc/rawshark.html
1746 ${CMAKE_BINARY_DIR}/doc/reordercap.html
1747 ${CMAKE_BINARY_DIR}/doc/sshdump.html
1748 ${CMAKE_BINARY_DIR}/doc/text2pcap.html
1749 ${CMAKE_BINARY_DIR}/doc/tshark.html
1750 ${CMAKE_BINARY_DIR}/doc/wireshark.html
1751 ${CMAKE_BINARY_DIR}/doc/wireshark-filter.html
1755 list(APPEND INSTALL_FILES ${CMAKE_BINARY_DIR}/doc/mmdbresolve.html)
1758 if (BUILD_corbaidl2wrs)
1759 list(APPEND INSTALL_FILES ${CMAKE_BINARY_DIR}/doc/idl2wrs.html)
1762 list(APPEND INSTALL_FILES
1763 ${CMAKE_BINARY_DIR}/doc/asn2deb.html
1764 ${CMAKE_BINARY_DIR}/doc/idl2deb.html
1769 set(TEXTIFY_FILES COPYING NEWS README.windows)
1770 set(TEXTIFY_MD_FILES README.md)
1771 foreach(_text_file ${TEXTIFY_FILES} ${TEXTIFY_MD_FILES})
1772 string(REGEX REPLACE ".md$" "" _out_file ${_text_file})
1773 set(INSTALL_FILES ${CMAKE_BINARY_DIR}/${_out_file}.txt ${INSTALL_FILES})
1776 set(INSTALL_FILES COPYING ${INSTALL_FILES})
1779 set(VERSION_INFO_LIBS
1782 set(VERSION_INFO_INCLUDE_DIRS
1783 ${ZLIB_INCLUDE_DIRS}
1787 set(_dll_output_dir "${DATAFILE_DIR}")
1788 add_custom_target(copy_cli_dlls)
1789 set_target_properties(copy_cli_dlls PROPERTIES FOLDER "Copy Tasks")
1790 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
1791 COMMAND ${CMAKE_COMMAND} -E make_directory "${_dll_output_dir}"
1794 # XXX Can (and should) we iterate over these similar to the way
1795 # the top-level CMakeLists.txt iterates over the package list?
1797 # Required DLLs and their corresponding PDBs.
1798 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
1799 COMMAND ${CMAKE_COMMAND} -E copy_if_different
1800 "$<IF:$<CONFIG:Debug>,${GLIB2_DLLS_DEBUG},${GLIB2_DLLS_RELEASE}>"
1801 "$<IF:$<CONFIG:Debug>,${GLIB2_PDBS_DEBUG},${GLIB2_PDBS_RELEASE}>"
1802 "${_dll_output_dir}"
1803 WORKING_DIRECTORY $<IF:$<CONFIG:Debug>,${GLIB2_DLL_DIR_DEBUG},${GLIB2_DLL_DIR_RELEASE}>
1804 COMMAND_EXPAND_LISTS
1807 # Optional DLLs and PDBs.
1811 list (APPEND OPTIONAL_DLLS "${AIRPCAP_DLL_DIR}/${AIRPCAP_DLL}")
1812 endif(AIRPCAP_FOUND)
1814 list (APPEND OPTIONAL_DLLS "${CARES_DLL_DIR}/${CARES_DLL}")
1815 list (APPEND OPTIONAL_PDBS "${CARES_DLL_DIR}/${CARES_PDB}")
1817 if (MAXMINDDB_FOUND)
1818 list (APPEND OPTIONAL_DLLS "${MAXMINDDB_DLL_DIR}/${MAXMINDDB_DLL}")
1819 endif(MAXMINDDB_FOUND)
1821 list (APPEND OPTIONAL_DLLS "${LIBSSH_DLL_DIR}/${LIBSSH_DLL}")
1823 foreach( _dll ${GCRYPT_DLLS} )
1824 list (APPEND OPTIONAL_DLLS "${GCRYPT_DLL_DIR}/${_dll}")
1826 foreach( _dll ${GNUTLS_DLLS} )
1827 list (APPEND OPTIONAL_DLLS "${GNUTLS_DLL_DIR}/${_dll}")
1829 foreach( _dll ${KERBEROS_DLLS} )
1830 list (APPEND OPTIONAL_DLLS "${KERBEROS_DLL_DIR}/${_dll}")
1833 list (APPEND OPTIONAL_DLLS "${LUA_DLL_DIR}/${LUA_DLL}")
1836 list (APPEND OPTIONAL_DLLS "${LZ4_DLL_DIR}/${LZ4_DLL}")
1837 list (APPEND OPTIONAL_PDBS "${LZ4_DLL_DIR}/${LZ4_PDB}")
1840 list (APPEND OPTIONAL_DLLS "${ZSTD_DLL_DIR}/${ZSTD_DLL}")
1843 list (APPEND OPTIONAL_DLLS "${NGHTTP2_DLL_DIR}/${NGHTTP2_DLL}")
1844 list (APPEND OPTIONAL_PDBS "${NGHTTP2_DLL_DIR}/${NGHTTP2_PDB}")
1845 endif(NGHTTP2_FOUND)
1847 list (APPEND OPTIONAL_DLLS "${SBC_DLL_DIR}/${SBC_DLL}")
1850 list (APPEND OPTIONAL_DLLS "${SPANDSP_DLL_DIR}/${SPANDSP_DLL}")
1851 endif(SPANDSP_FOUND)
1853 list (APPEND OPTIONAL_DLLS "${BCG729_DLL_DIR}/${BCG729_DLL}")
1856 foreach( _dll ${LIBXML2_DLLS} )
1857 list (APPEND OPTIONAL_DLLS "${LIBXML2_DLL_DIR}/${_dll}")
1859 foreach( _pdb ${LIBXML2_PDBS} )
1860 list (APPEND OPTIONAL_PDBS "${LIBXML2_DLL_DIR}/${_pdb}")
1862 endif(LIBXML2_FOUND)
1864 list (APPEND OPTIONAL_DLLS "${SMI_DLL_DIR}/${SMI_DLL}")
1865 # Wireshark.nsi wants SMI_DIR which is the base SMI directory
1866 get_filename_component(SMI_DIR ${SMI_DLL_DIR} DIRECTORY)
1867 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
1868 COMMAND ${CMAKE_COMMAND} -E make_directory
1869 "${_dll_output_dir}/snmp"
1870 COMMAND ${CMAKE_COMMAND} -E make_directory
1871 "${_dll_output_dir}/snmp/mibs"
1872 COMMAND ${CMAKE_COMMAND} -E copy_directory
1873 "${SMI_SHARE_DIR}/mibs/iana"
1874 "${_dll_output_dir}/snmp/mibs"
1875 COMMAND ${CMAKE_COMMAND} -E copy_directory
1876 "${SMI_SHARE_DIR}/mibs/ietf"
1877 "${_dll_output_dir}/snmp/mibs"
1878 COMMAND ${CMAKE_COMMAND} -E copy_directory
1879 "${SMI_SHARE_DIR}/mibs/irtf"
1880 "${_dll_output_dir}/snmp/mibs"
1881 COMMAND ${CMAKE_COMMAND} -E copy_directory
1882 "${SMI_SHARE_DIR}/mibs/site"
1883 "${_dll_output_dir}/snmp/mibs"
1884 COMMAND ${CMAKE_COMMAND} -E copy_directory
1885 "${SMI_SHARE_DIR}/mibs/tubs"
1886 "${_dll_output_dir}/snmp/mibs"
1887 COMMAND ${CMAKE_COMMAND} -E copy_directory
1888 "${SMI_SHARE_DIR}/pibs"
1889 "${_dll_output_dir}/snmp/mibs"
1890 COMMAND ${CMAKE_COMMAND} -E copy_directory
1891 "${SMI_SHARE_DIR}/yang"
1892 "${_dll_output_dir}/snmp/mibs"
1893 #remove the extra directories copied (shallow copying the above would remove the need for this)
1894 COMMAND ${CMAKE_COMMAND} -E remove_directory
1895 "${_dll_output_dir}/snmp/mibs/iana"
1896 COMMAND ${CMAKE_COMMAND} -E remove_directory
1897 "${_dll_output_dir}/snmp/mibs/ietf"
1898 COMMAND ${CMAKE_COMMAND} -E remove_directory
1899 "${_dll_output_dir}/snmp/mibs/site"
1900 COMMAND ${CMAKE_COMMAND} -E remove_directory
1901 "${_dll_output_dir}/snmp/mibs/tubs"
1905 list (APPEND OPTIONAL_DLLS "${SNAPPY_DLL_DIR}/${SNAPPY_DLL}")
1907 if (WINSPARKLE_FOUND)
1908 list (APPEND OPTIONAL_DLLS "${WINSPARKLE_DLL_DIR}/${WINSPARKLE_DLL}")
1909 endif(WINSPARKLE_FOUND)
1911 list (APPEND OPTIONAL_DLLS "${ZLIB_DLL_DIR}/${ZLIB_DLL}")
1912 list (APPEND OPTIONAL_PDBS "${ZLIB_DLL_DIR}/${ZLIB_PDB}")
1915 foreach( _dll ${BROTLI_DLLS} )
1916 list (APPEND OPTIONAL_DLLS "${BROTLI_DLL_DIR}/${_dll}")
1920 # With libs downloaded to c:/wireshark-win64-libs this currently
1921 # (early 2018) expands to about 1900 characters.
1923 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
1924 COMMAND ${CMAKE_COMMAND} -E copy_if_different
1926 "${_dll_output_dir}"
1929 install(FILES ${OPTIONAL_DLLS} DESTINATION "${CMAKE_INSTALL_BINDIR}")
1930 endif(OPTIONAL_DLLS)
1933 add_custom_command(TARGET copy_cli_dlls PRE_BUILD
1934 COMMAND ${CMAKE_COMMAND} -E copy_if_different
1936 "${_dll_output_dir}"
1939 endif(OPTIONAL_PDBS)
1941 add_dependencies(epan copy_cli_dlls)
1943 # We have a lot of choices for creating zip archives:
1944 # - 7z, WinZip, etc., which require a separate download+install.
1945 # - "CMake -E tar cz", which creates a tar file.
1946 # - CPack, which requires a CPack configuration.
1947 # - PowerShell via PSCX or System.IO.Compression.FileSystem.
1948 # - Python via zipfile.
1949 # For now, just look for 7z. It's installed on the Windows builders,
1950 # which might be the only systems that use this target.
1951 find_program(ZIP_EXECUTABLE 7z
1952 PATH "$ENV{PROGRAMFILES}/7-Zip" "$ENV{PROGRAMW6432}/7-Zip"
1953 DOC "Path to the 7z utility."
1956 add_custom_target(pdb_zip_package COMMENT "This packages .PDBs but will not create them.")
1957 set_target_properties(pdb_zip_package PROPERTIES FOLDER "Packaging")
1958 set(_pdb_zip "${CMAKE_BINARY_DIR}/Wireshark-pdb-${WIRESHARK_TARGET_PLATFORM}-${VERSION}.zip")
1959 file(TO_NATIVE_PATH "${_pdb_zip}" _pdb_zip_win)
1960 add_custom_command(TARGET pdb_zip_package POST_BUILD
1961 COMMAND ${CMAKE_COMMAND} -E remove -f "${_pdb_zip}"
1962 COMMAND ${ZIP_EXECUTABLE} a -tzip -mmt=on "${_pdb_zip_win}"
1965 ${PLUGIN_VERSION_DIR}/epan/*.pdb
1966 ${PLUGIN_VERSION_DIR}/wiretap/*.pdb
1967 WORKING_DIRECTORY "${_dll_output_dir}"
1972 # List of extra dependencies for the "copy_data_files" target
1973 set(copy_data_files_depends)
1976 foreach(_text_file ${TEXTIFY_FILES})
1977 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${_text_file}.txt
1978 COMMAND ${POWERSHELL_COMMAND} "${CMAKE_SOURCE_DIR}/tools/textify.ps1"
1979 -Destination ${CMAKE_BINARY_DIR}
1980 ${CMAKE_SOURCE_DIR}/${_text_file}
1982 ${CMAKE_SOURCE_DIR}/${_text_file}
1985 foreach(_md_file ${TEXTIFY_MD_FILES})
1986 string(REGEX REPLACE ".md$" ".txt" _text_file ${_md_file})
1987 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${_text_file}
1988 COMMAND ${POWERSHELL_COMMAND} "${CMAKE_SOURCE_DIR}/tools/textify.ps1"
1989 -Destination ${CMAKE_BINARY_DIR}
1990 ${CMAKE_SOURCE_DIR}/${_md_file}
1991 COMMAND ${CMAKE_COMMAND} -E rename
1992 ${CMAKE_BINARY_DIR}/${_md_file}.txt
1993 ${CMAKE_BINARY_DIR}/${_text_file}
1995 ${CMAKE_SOURCE_DIR}/${_text_file}
2000 foreach(_install_file ${INSTALL_FILES})
2001 get_filename_component(_install_file_src "${_install_file}" ABSOLUTE)
2002 get_filename_component(_install_basename "${_install_file}" NAME)
2003 set(_output_file "${DATAFILE_DIR}/${_install_basename}")
2004 add_custom_command(OUTPUT "${_output_file}"
2005 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2006 "${_install_file_src}"
2012 list(APPEND copy_data_files_depends "${_output_file}")
2015 # Install LUA files in staging directory such that LUA can used when Wireshark
2016 # is ran from the build directory. For install targets, see
2017 # epan/wslua/CMakeLists.txt
2018 if(LUA_FOUND AND ENABLE_LUA)
2020 "${CMAKE_BINARY_DIR}/epan/wslua/init.lua"
2021 "${CMAKE_SOURCE_DIR}/epan/wslua/console.lua"
2022 "${CMAKE_SOURCE_DIR}/epan/wslua/dtd_gen.lua"
2024 foreach(_lua_file ${_lua_files})
2025 get_filename_component(_lua_filename "${_lua_file}" NAME)
2026 list(APPEND copy_data_files_depends
2027 "${DATAFILE_DIR}/${_lua_filename}")
2028 add_custom_command(OUTPUT "${DATAFILE_DIR}/${_lua_filename}"
2029 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2031 "${DATAFILE_DIR}/${_lua_filename}"
2037 endif(LUA_FOUND AND ENABLE_LUA)
2038 # doc/*.html handled elsewhere.
2040 # Glob patterns relative to the source directory that should be copied to
2041 # ${DATAFILE_DIR} (including directory prefixes)
2042 # TODO shouldn't this use full (relative) paths instead of glob patterns?
2049 # Copy all paths from the source tree to the data directory. Directories are
2050 # automatically created if missing as the filename is given.
2051 file(GLOB _data_files RELATIVE "${CMAKE_SOURCE_DIR}" ${DATA_FILES_SRC})
2052 foreach(_data_file ${_data_files})
2053 add_custom_command(OUTPUT "${DATAFILE_DIR}/${_data_file}"
2054 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2055 "${CMAKE_SOURCE_DIR}/${_data_file}"
2056 "${DATAFILE_DIR}/${_data_file}"
2058 "${CMAKE_SOURCE_DIR}/${_data_file}"
2060 list(APPEND copy_data_files_depends "${DATAFILE_DIR}/${_data_file}")
2063 file(GLOB _dtds_src_files RELATIVE "${CMAKE_SOURCE_DIR}" "dtds/*.dtd")
2065 set (_dtds_data_files)
2066 foreach(_data_file ${_dtds_src_files})
2067 list(APPEND _dtds_data_files "${DATAFILE_DIR}/${_data_file}")
2071 OUTPUT ${_dtds_data_files}
2072 COMMAND ${CMAKE_COMMAND} -E make_directory "${DATAFILE_DIR}/dtds"
2073 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2075 "${DATAFILE_DIR}/dtds"
2077 DEPENDS ${_dtds_src_files}
2078 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
2081 file(GLOB _diameter_src_files RELATIVE "${CMAKE_SOURCE_DIR}"
2086 set (_diameter_data_files)
2087 foreach(_data_file ${_diameter_src_files})
2088 list(APPEND _diameter_data_files "${DATAFILE_DIR}/${_data_file}")
2092 OUTPUT ${_diameter_data_files}
2093 COMMAND ${CMAKE_COMMAND} -E make_directory "${DATAFILE_DIR}/diameter"
2094 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2095 ${_diameter_src_files}
2096 "${DATAFILE_DIR}/diameter"
2098 DEPENDS ${_diameter_src_files}
2099 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
2102 file(GLOB _radius_src_files RELATIVE "${CMAKE_SOURCE_DIR}"
2103 radius/README.radius_dictionary
2104 radius/custom.includes
2109 set (_radius_data_files)
2110 foreach(_data_file ${_radius_src_files})
2111 list(APPEND _radius_data_files "${DATAFILE_DIR}/${_data_file}")
2115 OUTPUT ${_radius_data_files}
2116 COMMAND ${CMAKE_COMMAND} -E make_directory "${DATAFILE_DIR}/radius"
2117 COMMAND ${CMAKE_COMMAND} -E copy_if_different
2118 ${_radius_src_files}
2119 "${DATAFILE_DIR}/radius"
2121 DEPENDS ${_radius_src_files}
2122 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
2125 file(GLOB _profiles_src_files RELATIVE "${CMAKE_SOURCE_DIR}" profiles/*/*)
2126 set (_profiles_data_files)
2127 foreach(_data_file ${_profiles_src_files})
2128 list(APPEND _profiles_data_files "${DATAFILE_DIR}/${_data_file}")
2132 OUTPUT ${_profiles_data_files}
2133 COMMAND ${CMAKE_COMMAND} -E copy_directory
2134 "${CMAKE_SOURCE_DIR}/profiles" "${DATAFILE_DIR}/profiles"
2137 list(APPEND copy_data_files_depends
2139 ${_diameter_data_files}
2140 ${_radius_data_files}
2141 ${_profiles_data_files}
2144 # Copy files including ${INSTALL_FILES} and ${INSTALL_DIRS} to ${DATAFILE_DIR}
2145 add_custom_target(copy_data_files ALL DEPENDS ${copy_data_files_depends} )
2146 set_target_properties(copy_data_files PROPERTIES FOLDER "Copy Tasks")
2149 # Shared code, build object files once for all users.
2150 add_library(version_info OBJECT version_info.c)
2151 target_include_directories(version_info SYSTEM PRIVATE ${VERSION_INFO_INCLUDE_DIRS})
2152 if(NOT VCSVERSION_OVERRIDE)
2153 add_dependencies(version_info version)
2155 # sources common for wireshark, tshark, rawshark and sharkd
2156 add_library(shark_common OBJECT
2160 file_packet_provider.c
2164 add_library(cli_main OBJECT cli_main.c)
2165 add_library(capture_opts OBJECT capture_opts.c)
2166 target_include_directories(capture_opts SYSTEM PRIVATE ${PCAP_INCLUDE_DIRS})
2167 set_target_properties(version_info shark_common cli_main capture_opts
2169 COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
2173 if(BUILD_wireshark AND QT_FOUND)
2180 $<TARGET_OBJECTS:capture_opts>
2181 $<TARGET_OBJECTS:qtui>
2182 $<TARGET_OBJECTS:shark_common>
2183 $<TARGET_OBJECTS:version_info>
2185 ${PLATFORM_UI_RC_FILES}
2187 set_executable_resources(wireshark "Wireshark" UNIQUE_RC)
2190 if(ENABLE_APPLICATION_BUNDLE)
2192 # Add -Wl,-single_module to the LDFLAGS used with shared
2193 # libraries, to fix some error that show up in some cases;
2194 # some Apple documentation recommends it for most shared
2197 set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-single_module ${CMAKE_SHARED_LINKER_FLAGS}" )
2199 # Add -Wl,-headerpad_max_install_names to the LDFLAGS, as
2200 # code-signing issues is running out of padding space.
2202 # Add -Wl,-search_paths_first to make sure that if we search
2203 # directories A and B, in that order, for a given library, a
2204 # non-shared version in directory A, rather than a shared
2205 # version in directory B, is chosen (so we can use
2206 # --with-pcap=/usr/local to force all programs to be linked
2207 # with a static version installed in /usr/local/lib rather than
2208 # the system version in /usr/lib).
2211 set(CMAKE_EXE_LINKER_FLAGS
2212 "-Wl,-headerpad_max_install_names -Wl,-search_paths_first ${CMAKE_EXE_LINKER_FLAGS}"
2215 # Create our Frameworks directory
2216 file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/run/${CMAKE_CFG_INTDIR}/Wireshark.app/Contents/Frameworks")
2218 # Add files to the app bundle
2219 # Wireshark.app/Contents
2220 file(WRITE ${CMAKE_BINARY_DIR}/packaging/macosx/PkgInfo "APPLWshk\n")
2221 set(BUNDLE_CONTENTS_FILES
2222 ${CMAKE_BINARY_DIR}/packaging/macosx/PkgInfo
2224 set_source_files_properties(${BUNDLE_CONTENTS_FILES} PROPERTIES
2225 MACOSX_PACKAGE_LOCATION .
2228 # Wireshark.app/Contents/Resources
2229 set(BUNDLE_RESOURCE_FILES
2230 ${CMAKE_SOURCE_DIR}/packaging/macosx/Wireshark.icns
2231 ${CMAKE_SOURCE_DIR}/packaging/macosx/Wiresharkdoc.icns
2233 set_source_files_properties(${BUNDLE_RESOURCE_FILES} PROPERTIES
2234 MACOSX_PACKAGE_LOCATION Resources
2237 # Wireshark.app/Contents/Resources/share/man/man1
2238 set_source_files_properties(${BUNDLE_RESOURCE_SHARE_MAN1_FILES} PROPERTIES
2239 MACOSX_PACKAGE_LOCATION Resources/share/man/man1
2243 # Wireshark.app/Contents/Resources/share/man/man4
2244 set_source_files_properties(${BUNDLE_RESOURCE_SHARE_MAN4_FILES} PROPERTIES
2245 MACOSX_PACKAGE_LOCATION Resources/share/man/man4
2249 # INSTALL_FILES and INSTALL_DIRS are handled by copy_data_files
2251 set(EXTRA_BUNDLE_FILES
2252 ${BUNDLE_CONTENTS_FILES}
2253 ${BUNDLE_RESOURCE_FILES}
2254 ${BUNDLE_RESOURCE_SHARE_MAN1_FILES}
2255 ${BUNDLE_RESOURCE_SHARE_MAN4_FILES}
2258 set(EXTRA_BUNDLE_FILES)
2261 if(BUILD_wireshark AND QT_FOUND)
2269 ${VERSION_INFO_LIBS}
2270 ${APPLE_APPLICATION_SERVICES_LIBRARY}
2271 ${APPLE_APPKIT_LIBRARY}
2272 ${APPLE_CORE_FOUNDATION_LIBRARY}
2273 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
2274 ${SPARKLE_LIBRARIES}
2275 ${WIN_WS2_32_LIBRARY}
2276 ${WIN_VERSION_LIBRARY}
2277 ${WINSPARKLE_LIBRARIES}
2278 $<$<BOOL:${WIN32}>:UxTheme.lib>
2279 ${SPEEXDSP_LIBRARIES}
2280 ${MINIZIP_LIBRARIES}
2283 add_executable(wireshark WIN32 MACOSX_BUNDLE ${wireshark_FILES} ${EXTRA_BUNDLE_FILES})
2285 set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT wireshark)
2287 set(PROGLIST ${PROGLIST} wireshark)
2288 set_target_properties(wireshark PROPERTIES
2289 LINK_FLAGS "${WS_LINK_FLAGS}"
2290 FOLDER "Executables"
2291 INSTALL_RPATH "${EXECUTABLE_INSTALL_RPATH}"
2293 if(ENABLE_APPLICATION_BUNDLE OR WIN32)
2294 set_target_properties(wireshark PROPERTIES OUTPUT_NAME Wireshark)
2297 if(ENABLE_APPLICATION_BUNDLE)
2298 add_dependencies(wireshark manpages)
2299 set_target_properties(
2300 wireshark PROPERTIES
2301 MACOSX_BUNDLE_INFO_PLIST ${CMAKE_BINARY_DIR}/packaging/macosx/Info.plist
2303 if(CMAKE_CFG_INTDIR STREQUAL ".")
2304 # Add a wrapper script which opens the bundle. This adds
2305 # convenience but makes debugging more difficult.
2306 # It is not created if using Xcode
2307 # XXX Running run/Wireshark.app/Contents/MacOS/Wireshark works
2308 # fine for me (Gerald) here on Mojave. Can we just make this a
2310 file(REMOVE ${CMAKE_BINARY_DIR}/run/wireshark)
2311 file(WRITE ${CMAKE_BINARY_DIR}/run/wireshark "#!/bin/sh\n")
2312 file(APPEND ${CMAKE_BINARY_DIR}/run/wireshark "# Generated by ${CMAKE_CURRENT_LIST_FILE}\n")
2313 file(APPEND ${CMAKE_BINARY_DIR}/run/wireshark "# Wrapper script which should work around the issue described at\n")
2314 file(APPEND ${CMAKE_BINARY_DIR}/run/wireshark "# https://stackoverflow.com/questions/25318524/what-exactly-should-i-pass-to-nsapp-activateignoringotherapps-to-get-my-appl\n")
2315 file(APPEND ${CMAKE_BINARY_DIR}/run/wireshark "exec ${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/MacOS/Wireshark \"\$\@\"\n")
2316 execute_process(COMMAND chmod a+x ${CMAKE_BINARY_DIR}/run/wireshark)
2320 target_link_libraries(wireshark ${wireshark_LIBS})
2321 target_include_directories(wireshark SYSTEM PRIVATE ${SPARKLE_INCLUDE_DIRS})
2325 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
2326 BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
2329 if(QT_WINDEPLOYQT_EXECUTABLE)
2330 add_custom_target(copy_qt_dlls ALL)
2331 set_target_properties(copy_qt_dlls PROPERTIES FOLDER "Copy Tasks")
2332 # Will we ever need to use --debug? Windeployqt seems to
2333 # be smart enough to copy debug DLLs when needed.
2334 add_custom_command(TARGET copy_qt_dlls
2336 COMMAND set "PATH=${QT_BIN_PATH};%PATH%"
2337 COMMAND "${QT_WINDEPLOYQT_EXECUTABLE}"
2338 $<$<CONFIG:Debug>:--debug>
2339 $<$<NOT:$<CONFIG:Debug>>:--release>
2340 --no-compiler-runtime
2342 ${QT_WINDEPLOYQT_EXTRA_OPTS}
2343 "$<TARGET_FILE:wireshark>"
2345 add_dependencies(copy_qt_dlls wireshark)
2347 install(CODE "execute_process(COMMAND
2348 \"${QT_WINDEPLOYQT_EXECUTABLE}\"
2349 --no-compiler-runtime
2350 \"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/Wireshark.exe\")"
2353 endif(QT_WINDEPLOYQT_EXECUTABLE)
2356 # Common properties for CLI executables
2357 macro(set_extra_executable_properties _executable _folder)
2358 set_target_properties(${_executable} PROPERTIES
2359 LINK_FLAGS "${WILDCARD_OBJ} ${WS_LINK_FLAGS}"
2361 INSTALL_RPATH "${EXECUTABLE_INSTALL_RPATH}"
2364 set(PROGLIST ${PROGLIST} ${_executable})
2366 if(ENABLE_APPLICATION_BUNDLE)
2367 if(NOT CMAKE_CFG_INTDIR STREQUAL ".")
2369 set_target_properties(${_executable} PROPERTIES
2370 RUNTIME_OUTPUT_DIRECTORY run/$<CONFIG>/Wireshark.app/Contents/MacOS
2373 set_target_properties(${_executable} PROPERTIES
2374 RUNTIME_OUTPUT_DIRECTORY run/Wireshark.app/Contents/MacOS
2376 # Create a convenience link from run/<name> to its respective
2377 # target in the application bundle.
2378 add_custom_target(${_executable}-symlink
2380 Wireshark.app/Contents/MacOS/${_executable}
2381 ${CMAKE_BINARY_DIR}/run/${_executable}
2383 add_dependencies(${_executable} ${_executable}-symlink)
2388 register_tap_files(tshark-tap-register.c
2399 ${VERSION_INFO_LIBS}
2400 ${APPLE_CORE_FOUNDATION_LIBRARY}
2401 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
2402 ${WIN_WS2_32_LIBRARY}
2406 $<TARGET_OBJECTS:capture_opts>
2407 $<TARGET_OBJECTS:cli_main>
2408 $<TARGET_OBJECTS:shark_common>
2409 $<TARGET_OBJECTS:version_info>
2410 tshark-tap-register.c
2415 set_executable_resources(tshark "TShark" UNIQUE_RC)
2416 add_executable(tshark ${tshark_FILES})
2417 set_extra_executable_properties(tshark "Executables")
2418 target_link_libraries(tshark ${tshark_LIBS})
2419 install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
2427 ${VERSION_INFO_LIBS}
2428 ${APPLE_CORE_FOUNDATION_LIBRARY}
2429 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
2432 $<TARGET_OBJECTS:cli_main>
2433 $<TARGET_OBJECTS:shark_common>
2434 $<TARGET_OBJECTS:version_info>
2438 set_executable_resources(tfshark "TFShark")
2439 add_executable(tfshark ${tfshark_FILES})
2440 set_extra_executable_properties(tfshark "Executables")
2441 target_link_libraries(tfshark ${tfshark_LIBS})
2442 install(TARGETS tfshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
2445 if(BUILD_rawshark AND PCAP_FOUND)
2451 ${VERSION_INFO_LIBS}
2452 ${APPLE_CORE_FOUNDATION_LIBRARY}
2453 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
2454 ${WIN_WS2_32_LIBRARY}
2457 $<TARGET_OBJECTS:cli_main>
2458 $<TARGET_OBJECTS:shark_common>
2459 $<TARGET_OBJECTS:version_info>
2462 set_executable_resources(rawshark "Rawshark")
2463 add_executable(rawshark ${rawshark_FILES})
2464 set_extra_executable_properties(rawshark "Executables")
2465 target_link_libraries(rawshark ${rawshark_LIBS})
2466 install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
2474 ${VERSION_INFO_LIBS}
2475 ${APPLE_CORE_FOUNDATION_LIBRARY}
2476 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
2477 ${WIN_WS2_32_LIBRARY}
2478 ${SPEEXDSP_LIBRARIES}
2483 # XXX - currently doesn't work on Windows if it uses
2484 # $<TARGET_OBJECTS:cli_main> and has real_main().
2486 $<TARGET_OBJECTS:shark_common>
2487 $<TARGET_OBJECTS:version_info>
2492 set_executable_resources(sharkd "SharkD")
2493 add_executable(sharkd ${sharkd_FILES})
2494 set_extra_executable_properties(sharkd "Executables")
2495 target_link_libraries(sharkd ${sharkd_LIBS})
2496 target_include_directories(sharkd SYSTEM
2498 ${SPEEXDSP_INCLUDE_DIRS}
2501 install(TARGETS sharkd RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
2509 ${VERSION_INFO_LIBS}
2514 add_executable(dftest ${dftest_FILES})
2515 set_extra_executable_properties(dftest "Tests")
2516 target_link_libraries(dftest ${dftest_LIBS})
2530 $<TARGET_OBJECTS:cli_main>
2531 $<TARGET_OBJECTS:version_info>
2534 add_executable(randpkt ${randpkt_FILES})
2535 set_extra_executable_properties(randpkt "Executables")
2536 target_link_libraries(randpkt ${randpkt_LIBS})
2537 install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
2540 if(BUILD_fuzzshark OR ENABLE_FUZZER OR OSS_FUZZ)
2541 add_subdirectory(fuzz)
2552 $<TARGET_OBJECTS:cli_main>
2553 $<TARGET_OBJECTS:version_info>
2556 add_lex_files(text2pcap_LEX_FILES text2pcap_FILES
2559 set_executable_resources(text2pcap "Text2pcap"
2560 COPYRIGHT_INFO "2001 Ashok Narayanan <ashokn@cisco.com>")
2561 add_executable(text2pcap ${text2pcap_FILES})
2562 set_extra_executable_properties(text2pcap "Executables")
2563 target_link_libraries(text2pcap ${text2pcap_LIBS})
2564 install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
2575 $<TARGET_OBJECTS:cli_main>
2576 $<TARGET_OBJECTS:version_info>
2579 set_executable_resources(mergecap "Mergecap")
2580 add_executable(mergecap ${mergecap_FILES})
2581 set_extra_executable_properties(mergecap "Executables")
2582 target_link_libraries(mergecap ${mergecap_LIBS})
2583 install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
2586 if(BUILD_reordercap)
2593 set(reordercap_FILES
2594 $<TARGET_OBJECTS:cli_main>
2595 $<TARGET_OBJECTS:version_info>
2598 set_executable_resources(reordercap "Reordercap")
2599 add_executable(reordercap ${reordercap_FILES})
2600 set_extra_executable_properties(reordercap "Executables")
2601 target_link_libraries(reordercap ${reordercap_LIBS})
2602 install(TARGETS reordercap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
2615 $<TARGET_OBJECTS:cli_main>
2616 $<TARGET_OBJECTS:version_info>
2619 set_executable_resources(capinfos "Capinfos")
2620 add_executable(capinfos ${capinfos_FILES})
2621 set_extra_executable_properties(capinfos "Executables")
2622 target_link_libraries(capinfos ${capinfos_LIBS})
2623 install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
2635 $<TARGET_OBJECTS:cli_main>
2636 $<TARGET_OBJECTS:version_info>
2639 set_executable_resources(captype "Captype")
2640 add_executable(captype ${captype_FILES})
2641 set_extra_executable_properties(captype "Executables")
2642 target_link_libraries(captype ${captype_LIBS})
2643 install(TARGETS captype RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
2655 $<TARGET_OBJECTS:cli_main>
2656 $<TARGET_OBJECTS:version_info>
2659 set_executable_resources(editcap "Editcap")
2660 add_executable(editcap ${editcap_FILES})
2661 set_extra_executable_properties(editcap "Executables")
2662 target_link_libraries(editcap ${editcap_LIBS})
2663 install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
2666 if(BUILD_dumpcap AND PCAP_FOUND)
2675 ${GTHREAD2_LIBRARIES}
2677 ${APPLE_CORE_FOUNDATION_LIBRARY}
2678 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
2679 ${WIN_WS2_32_LIBRARY}
2682 $<TARGET_OBJECTS:capture_opts>
2683 $<TARGET_OBJECTS:cli_main>
2684 $<TARGET_OBJECTS:version_info>
2689 set_executable_resources(dumpcap "Dumpcap" UNIQUE_RC)
2690 add_executable(dumpcap ${dumpcap_FILES})
2691 set_extra_executable_properties(dumpcap "Executables")
2692 target_link_libraries(dumpcap ${dumpcap_LIBS})
2693 install(TARGETS dumpcap
2694 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
2695 PERMISSIONS ${DUMPCAP_SETUID}
2696 OWNER_READ OWNER_WRITE OWNER_EXECUTE
2697 GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
2699 if(ENABLE_DUMPCAP_GROUP)
2700 install(CODE "execute_process(COMMAND chgrp ${DUMPCAP_INSTALL_GROUP} ${CMAKE_INSTALL_FULL_BINDIR}/dumpcap)")
2701 install(CODE "execute_process(COMMAND chmod o-x ${CMAKE_INSTALL_FULL_BINDIR}/dumpcap)")
2703 if(DUMPCAP_INSTALL_OPTION STREQUAL "capabilities")
2704 install( CODE "execute_process(
2706 ${SETCAP_EXECUTABLE}
2707 cap_net_raw,cap_net_admin+ep
2708 ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/dumpcap${CMAKE_EXECUTABLE_SUFFIX}
2712 if( _SETCAP_RESULT )
2713 message( WARNING \"setcap failed (${_SETCAP_RESULT}).\")
2717 elseif(BUILD_dumpcap AND ENABLE_PCAP)
2718 message(WARNING "Dumpcap was requested but libpcap dependency is not available. "
2719 "Wireshark will be built without packet capture capability.")
2722 # We have two idl2wrs utilities: this and the CORBA version in tools.
2723 # We probably shouldn't do that.
2724 if(BUILD_dcerpcidl2wrs)
2730 epan/dissectors/dcerpc/idl2wrs.c
2733 add_executable(idl2wrs ${idl2wrs_FILES})
2734 set_target_properties(idl2wrs PROPERTIES FOLDER "Executables")
2735 set_extra_executable_properties(idl2wrs "Executables")
2736 target_link_libraries(idl2wrs ${idl2wrs_LIBS})
2737 install(TARGETS idl2wrs RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
2741 find_package( MSVC_REDIST )
2743 # Must come after executable targets are defined.
2744 find_package( NSIS )
2746 if(MAKENSIS_EXECUTABLE)
2747 add_subdirectory( packaging/nsis EXCLUDE_FROM_ALL )
2748 ADD_NSIS_UNINSTALLER_TARGET()
2749 ADD_NSIS_PACKAGE_TARGET()
2754 if(WIX_CANDLE_EXECUTABLE)
2755 add_subdirectory( packaging/wix EXCLUDE_FROM_ALL )
2756 ADD_WIX_PACKAGE_TARGET()
2759 find_package( PortableApps )
2760 if(PORTABLEAPPS_LAUNCHER_GENERATOR_EXECUTABLE AND PORTABLEAPPS_INSTALLER_EXECUTABLE)
2761 add_subdirectory( packaging/portableapps EXCLUDE_FROM_ALL )
2762 ADD_PORTABLEAPPS_PACKAGE_TARGET()
2766 if (MAXMINDDB_FOUND)
2767 set(mmdbresolve_LIBS
2768 # Note: libmaxminddb is not GPL-2 compatible.
2769 ${MAXMINDDB_LIBRARY}
2771 set(mmdbresolve_FILES
2774 add_executable(mmdbresolve ${mmdbresolve_FILES})
2775 set_extra_executable_properties(mmdbresolve "Executables")
2776 target_link_libraries(mmdbresolve ${mmdbresolve_LIBS})
2777 target_include_directories(mmdbresolve PUBLIC ${MAXMINDDB_INCLUDE_DIRS})
2778 target_compile_definitions(mmdbresolve PUBLIC ${MAXMINDDB_DEFINITIONS})
2779 install(TARGETS mmdbresolve RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
2782 if(ENABLE_APPLICATION_BUNDLE)
2783 set (install_chmodbpf_component_pkg "${CMAKE_BINARY_DIR}/install.ChmodBPF.pkg")
2784 add_custom_command(OUTPUT "${install_chmodbpf_component_pkg}"
2786 --identifier org.wireshark.ChmodBPF.pkg
2788 --root "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/root"
2789 --scripts "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/install-scripts"
2790 ${install_chmodbpf_component_pkg}
2792 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/root/Library/Application Support/Wireshark/ChmodBPF/ChmodBPF"
2793 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/root/Library/LaunchDaemons/org.wireshark.ChmodBPF.plist"
2794 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/install-scripts/postinstall"
2796 set (install_chmodbpf_pkg "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/Extras/Install ChmodBPF.pkg")
2797 add_custom_command(OUTPUT "${install_chmodbpf_pkg}"
2798 COMMAND productbuild
2799 --identifier org.wireshark.install.ChmodBPF.product
2801 --distribution "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/install-distribution.xml"
2802 --package-path "${CMAKE_BINARY_DIR}"
2803 ${install_chmodbpf_pkg}
2805 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/install-distribution.xml"
2806 ${install_chmodbpf_component_pkg}
2809 set (uninstall_chmodbpf_component_pkg "${CMAKE_BINARY_DIR}/uninstall.ChmodBPF.pkg")
2810 add_custom_command(OUTPUT "${uninstall_chmodbpf_component_pkg}"
2812 --identifier org.wireshark.uninstall.ChmodBPF.pkg
2815 --scripts "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/uninstall-scripts"
2816 ${uninstall_chmodbpf_component_pkg}
2818 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/uninstall-scripts/postinstall"
2820 set (uninstall_chmodbpf_pkg "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/Extras/Uninstall ChmodBPF.pkg")
2821 add_custom_command(OUTPUT "${uninstall_chmodbpf_pkg}"
2822 COMMAND productbuild
2823 --identifier org.wireshark.uninstall.ChmodBPF.product
2825 --distribution "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/uninstall-distribution.xml"
2826 --package-path "${CMAKE_BINARY_DIR}"
2827 ${uninstall_chmodbpf_pkg}
2829 "${CMAKE_SOURCE_DIR}/packaging/macosx/ChmodBPF/uninstall-distribution.xml"
2830 ${uninstall_chmodbpf_component_pkg}
2833 add_custom_target(chmodbpf DEPENDS ${install_chmodbpf_pkg} ${uninstall_chmodbpf_pkg})
2835 set (install_path_helper_component_pkg "${CMAKE_BINARY_DIR}/install.path_helper.pkg")
2836 add_custom_command(OUTPUT "${install_path_helper_component_pkg}"
2838 --identifier org.wireshark.path_helper.pkg
2840 --root "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/root/etc"
2841 --install-location /private/etc
2842 ${install_path_helper_component_pkg}
2844 "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/root/etc/paths.d/Wireshark"
2845 "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/root/etc/manpaths.d/Wireshark"
2847 set (install_path_helper_pkg "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/Extras/Add Wireshark to the system path.pkg")
2848 add_custom_command(OUTPUT "${install_path_helper_pkg}"
2849 COMMAND productbuild
2850 --identifier org.wireshark.install.path_helper.product
2852 --distribution "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/install-distribution.xml"
2853 --package-path "${CMAKE_BINARY_DIR}"
2854 ${install_path_helper_pkg}
2856 "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/install-distribution.xml"
2857 ${install_path_helper_component_pkg}
2860 set (uninstall_path_helper_component_pkg "${CMAKE_BINARY_DIR}/uninstall.path_helper.pkg")
2861 add_custom_command(OUTPUT "${uninstall_path_helper_component_pkg}"
2863 --identifier org.wireshark.uninstall.path_helper.pkg
2866 --scripts "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/uninstall-scripts"
2867 ${uninstall_path_helper_component_pkg}
2869 "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/uninstall-scripts/postinstall"
2871 set (uninstall_path_helper_pkg "${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Resources/Extras/Remove Wireshark from the system path.pkg")
2872 add_custom_command(OUTPUT "${uninstall_path_helper_pkg}"
2873 COMMAND productbuild
2874 --identifier org.wireshark.uninstall.path_helper.product
2876 --distribution "${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/uninstall-distribution.xml"
2877 --package-path "${CMAKE_BINARY_DIR}"
2878 ${uninstall_path_helper_pkg}
2880 ${CMAKE_SOURCE_DIR}/packaging/macosx/path_helper/uninstall-distribution.xml
2881 ${uninstall_path_helper_component_pkg}
2884 add_custom_target(path_helper DEPENDS ${install_path_helper_pkg} ${uninstall_path_helper_pkg})
2886 add_custom_target(app_bundle)
2887 set_target_properties(app_bundle PROPERTIES FOLDER "Copy Tasks")
2888 add_custom_command(TARGET app_bundle
2890 COMMAND "${CMAKE_BINARY_DIR}/packaging/macosx/osx-app.sh"
2891 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/run"
2893 add_dependencies(app_bundle ${PROGLIST} chmodbpf path_helper)
2895 if( DMGBUILD_EXECUTABLE AND ASCIIDOCTOR_FOUND)
2896 add_custom_target(dmg_package_prep DEPENDS app_bundle)
2898 set(_read_me_first "packaging/macosx/Read me first.html")
2902 COMMAND ${ASCIIDOCTOR_EXECUTABLE}
2904 --out-file ${_read_me_first}
2905 --attribute include-dir=${CMAKE_SOURCE_DIR}/docbook
2906 --attribute min-macos-version=${MIN_MACOS_VERSION}
2907 ${CMAKE_CURRENT_SOURCE_DIR}/packaging/macosx/Read_me_first.adoc
2909 ${CMAKE_CURRENT_SOURCE_DIR}/packaging/macosx/Read_me_first.adoc
2911 add_custom_target(read_me_first_html DEPENDS ${_read_me_first} )
2912 add_dependencies(dmg_package_prep read_me_first_html)
2914 ADD_CUSTOM_TARGET( dmg_package
2915 COMMAND bash -x ${CMAKE_BINARY_DIR}/packaging/macosx/osx-dmg.sh
2916 # Unlike nsis_package_prep + nsis_package, we can add a direct
2918 DEPENDS dmg_package_prep
2919 # We create Wireshark.app in "run". Do our work there.
2920 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/run
2926 if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
2927 find_program(RPMBUILD_EXECUTABLE rpmbuild)
2928 find_program(DPKG_BUILDPACKAGE_EXECUTABLE dpkg-buildpackage)
2929 find_program(GIT_EXECUTABLE git)
2930 # Should we add appimaged's monitored directories
2932 # https://github.com/AppImage/appimaged
2933 find_program(LINUXDEPLOYQT_EXECUTABLE linuxdeployqt)
2934 find_program(APPIMAGETOOL_EXECUTABLE appimagetool)
2938 string(REPLACE "-" "_" RPM_VERSION "${VERSION}")
2939 configure_file(packaging/rpm/wireshark.spec.in ${CMAKE_BINARY_DIR}/packaging/rpm/SPECS/wireshark.spec)
2940 if(RPMBUILD_EXECUTABLE)
2941 foreach(_rpm_dir BUILD RPMS SOURCES SPECS SRPMS)
2942 file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/packaging/rpm/${_rpm_dir}")
2945 set(_rpmbuild_with_args)
2946 if(CMAKE_GENERATOR STREQUAL "Ninja")
2947 list(APPEND _rpmbuild_with_args --with ninja)
2949 if(CCACHE_EXECUTABLE)
2950 list(APPEND _rpmbuild_with_args --with ccache)
2952 if(NOT BUILD_wireshark)
2953 list(APPEND _rpmbuild_with_args --without qt5)
2955 if (MAXMINDDB_FOUND)
2956 list(APPEND _rpmbuild_with_args --with mmdbresolve)
2959 list(APPEND _rpmbuild_with_args --with lua)
2961 if (LZ4_FOUND AND SNAPPY_FOUND)
2962 list(APPEND _rpmbuild_with_args --with lz4_and_snappy)
2965 list(APPEND _rpmbuild_with_args --with c_ares)
2968 list(APPEND _rpmbuild_with_args --with spandsp)
2971 list(APPEND _rpmbuild_with_args --with bcg729)
2974 list(APPEND _rpmbuild_with_args --with libxml2)
2977 list(APPEND _rpmbuild_with_args --with nghttp2)
2980 list(APPEND _rpmbuild_with_args --with sdjournal)
2983 list(APPEND _rpmbuild_with_args --with brotli)
2987 COMMAND ${PERL_EXECUTABLE}
2988 ${CMAKE_SOURCE_DIR}/tools/make-version.pl
2992 # XXX Replace with the "dist" target?
2993 set(_export_tarball "${PROJECT_NAME}-${VERSION}.tar.xz")
2995 OUTPUT "${CMAKE_BINARY_DIR}/packaging/rpm/SOURCES/${_export_tarball}"
2996 COMMAND ${CMAKE_BINARY_DIR}/packaging/source/git-export-release.sh
2997 -d "${CMAKE_BINARY_DIR}/packaging/rpm/SOURCES"
2999 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
3001 add_custom_target(rpm-package
3002 COMMAND ${RPMBUILD_EXECUTABLE}
3003 --define "_topdir ${CMAKE_BINARY_DIR}/packaging/rpm"
3004 --define "_prefix ${CMAKE_INSTALL_PREFIX}"
3005 ${_rpmbuild_with_args}
3007 -ba SPECS/wireshark.spec
3008 DEPENDS "${CMAKE_BINARY_DIR}/packaging/rpm/SOURCES/${_export_tarball}"
3009 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/packaging/rpm"
3010 COMMENT "Create a tarball from the current git commit."
3014 if(DPKG_BUILDPACKAGE_EXECUTABLE)
3015 add_custom_target(deb-package
3016 COMMAND ${DPKG_BUILDPACKAGE_EXECUTABLE} -us -uc
3017 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
3021 if(LINUXDEPLOYQT_EXECUTABLE AND APPIMAGETOOL_EXECUTABLE)
3022 # The documentation at https://github.com/probonopd/linuxdeployqt
3023 # says that you need to set CMAKE_BUILD_TYPE=Release and
3024 # CMAKE_INSTALL_PREFIX=/usr. I (gcc) also had to set
3025 # CMAKE_INSTALL_LIBDIR=/usr/lib.
3026 if (CMAKE_BUILD_TYPE STREQUAL "Release" AND CMAKE_INSTALL_PREFIX STREQUAL "/usr" AND CMAKE_INSTALL_LIBDIR STREQUAL "/usr/lib" )
3027 add_custom_target(appimage-prerequisites)
3028 add_dependencies(appimage-prerequisites ${PROGLIST})
3030 add_custom_target(appimage-prerequisites
3031 COMMAND echo "CMAKE_BUILD_TYPE isn't Release or CMAKE_INSTALL_PREFIX isn't /usr or CMAKE_INSTALL_LIBDIR isn't /usr/lib."
3035 set (_ai_appdir "${CMAKE_BINARY_DIR}/packaging/appimage/appdir")
3036 add_custom_target(appimage-appdir
3037 COMMAND ${CMAKE_COMMAND} -E make_directory "${_ai_appdir}"
3038 COMMAND env DESTDIR=${_ai_appdir}
3039 ${CMAKE_COMMAND} --build . --target install
3040 DEPENDS appimage-prerequisites
3043 foreach(_prog ${PROGLIST})
3044 # XXX Is this the correct path?
3045 list(APPEND _exe_args "-executable=${_ai_appdir}/usr/bin/${_prog}")
3047 # linuxdeployqt currently clobbers AppRun:
3048 # https://github.com/probonopd/linuxdeployqt/issues/159
3049 # When that's fixed we will no longer need appimagetool. Until
3050 # then, we need to prep and package in two steps:
3051 # https://github.com/probonopd/linuxdeployqt/wiki/Custom-wrapper-script-instead-of-AppRun
3052 add_custom_target(appimage-prep
3053 COMMAND ${LINUXDEPLOYQT_EXECUTABLE}
3054 "${_ai_appdir}/usr/share/applications/wireshark.desktop"
3056 COMMAND rm -f "${_ai_appdir}/AppRun"
3058 "${CMAKE_SOURCE_DIR}/packaging/appimage/AppRun"
3059 "${_ai_appdir}/AppRun"
3060 DEPENDS appimage-appdir
3062 add_custom_target(appimage
3063 COMMAND env VERSION=${PROJECT_VERSION} ${APPIMAGETOOL_EXECUTABLE} appdir
3064 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/packaging/appimage"
3065 DEPENDS appimage-prep
3076 ${randpktdump_FILES}
3084 ${mmdbresolve_FILES}
3088 # Make sure we don't pass /WX to rc.exe. Rc doesn't have a /WX flag,
3089 # but it does have /W (warn about invalid code pages) and /X (ignore
3090 # the INCLUDE environment variable).
3091 # This should apparently be handled for us via CMAKE_RC_FLAG_REGEX
3092 # in CMakeRCInformation.cmake but that doesn't appear to work.
3094 list(FILTER CLEAN_C_FILES EXCLUDE REGEX ".*\\.rc")
3097 # XXX This also contains object files ($<TARGET_OBJECTS:...>), is that an issue?
3098 set_source_files_properties(
3101 COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
3109 OWNER_WRITE OWNER_READ
3113 ${CMAKE_INSTALL_DATADIR}
3116 set(SHARK_PUBLIC_HEADERS
3127 ${CMAKE_BINARY_DIR}/ws_version.h
3130 install(FILES ${SHARK_PUBLIC_HEADERS}
3131 DESTINATION ${PROJECT_INSTALL_INCLUDEDIR}
3134 # Install icons and other desktop files for Freedesktop.org-compliant desktops.
3135 if((BUILD_wireshark AND QT_FOUND) AND NOT (WIN32 OR APPLE))
3136 install(FILES wireshark-mime-package.xml
3137 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/mime/packages"
3138 RENAME wireshark.xml
3140 install(FILES wireshark.appdata.xml
3141 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/appdata"
3143 if(BUILD_wireshark AND QT_FOUND)
3144 install(FILES wireshark.desktop
3145 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
3147 foreach(size 16 24 32 48 64 128 256)
3148 install(FILES image/wsicon${size}.png
3149 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${size}x${size}/apps"
3150 RENAME wireshark.png)
3151 install(FILES image/WiresharkDoc-${size}.png
3152 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${size}x${size}/mimetypes"
3153 RENAME application-wireshark-doc.png)
3155 install(FILES image/wsicon.svg
3156 DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps"
3157 RENAME wireshark.svg)
3162 "${CMAKE_BINARY_DIR}/wireshark.pc"
3164 ${CMAKE_INSTALL_LIBDIR}/pkgconfig
3171 ${CMAKE_INSTALL_DATADIR}
3173 OWNER_WRITE OWNER_READ
3176 DIRECTORY_PERMISSIONS
3177 OWNER_EXECUTE OWNER_WRITE OWNER_READ
3178 GROUP_EXECUTE GROUP_READ
3179 WORLD_EXECUTE WORLD_READ
3180 PATTERN ".git" EXCLUDE
3181 PATTERN ".svn" EXCLUDE
3182 PATTERN "Makefile.*" EXCLUDE
3186 # Note: CMake export mechanism misbehaves with a '.' in the
3187 # path (incorrect relative path computation).
3188 set(WIRESHARK_INSTALL_CMAKEDIR "cmake")
3190 set(WIRESHARK_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/cmake")
3195 ${CMAKE_MODULE_PATH}/FindGLIB2.cmake
3196 ${CMAKE_MODULE_PATH}/FindWSWinLibs.cmake
3197 ${CMAKE_MODULE_PATH}/UseAsn2Wrs.cmake
3198 ${CMAKE_MODULE_PATH}/LocatePythonModule.cmake
3199 ${CMAKE_MODULE_PATH}/UseMakePluginReg.cmake
3201 ${WIRESHARK_INSTALL_CMAKEDIR}
3204 include(CMakePackageConfigHelpers)
3206 configure_package_config_file(WiresharkConfig.cmake.in
3207 ${CMAKE_BINARY_DIR}/WiresharkConfig.cmake
3208 INSTALL_DESTINATION ${WIRESHARK_INSTALL_CMAKEDIR}
3210 CMAKE_INSTALL_LIBDIR
3211 CMAKE_INSTALL_INCLUDEDIR
3212 PLUGIN_INSTALL_VERSION_LIBDIR
3213 EXTCAP_INSTALL_LIBDIR
3216 write_basic_package_version_file(
3217 ${CMAKE_BINARY_DIR}/WiresharkConfigVersion.cmake
3218 COMPATIBILITY AnyNewerVersion
3223 ${CMAKE_BINARY_DIR}/WiresharkConfig.cmake
3224 ${CMAKE_BINARY_DIR}/WiresharkConfigVersion.cmake
3226 ${WIRESHARK_INSTALL_CMAKEDIR}
3229 install(EXPORT WiresharkTargets
3230 DESTINATION ${WIRESHARK_INSTALL_CMAKEDIR}
3233 if (DOXYGEN_EXECUTABLE)
3235 # We don't have a good way of tracking dependencies, so we simply
3236 # recreate the whole thing from scratch each time.
3237 add_custom_target(wsar_html
3238 COMMAND ${CMAKE_COMMAND} -E remove_directory wsar_html
3239 COMMAND ${DOXYGEN_EXECUTABLE} doxygen.cfg
3242 add_custom_target(wsar_html_zip
3243 COMMAND ${CMAKE_COMMAND} -E tar "cfv" "wsar_html.zip" --format=zip wsar_html
3246 set_target_properties(wsar_html wsar_html_zip PROPERTIES
3248 EXCLUDE_FROM_DEFAULT_BUILD True
3250 endif(DOXYGEN_EXECUTABLE)
3252 add_custom_target(test-programs
3258 COMMENT "Building unit test programs and wrapper"
3260 set_target_properties(test-programs PROPERTIES
3262 EXCLUDE_FROM_DEFAULT_BUILD True
3267 # We could try to build this list dynamically, but given that we tend to
3268 # go years between adding suites just run
3269 # test/test.py --list-groups | sort
3270 # and paste the output here.
3271 set(_test_group_list
3275 suite_dfilter.group_bytes_ether
3276 suite_dfilter.group_bytes_ipv6
3277 suite_dfilter.group_bytes_type
3278 suite_dfilter.group_double
3279 suite_dfilter.group_dfunction_string
3280 suite_dfilter.group_integer
3281 suite_dfilter.group_integer_1byte
3282 suite_dfilter.group_ipv4
3283 suite_dfilter.group_membership
3284 suite_dfilter.group_range_method
3285 suite_dfilter.group_scanner
3286 suite_dfilter.group_string_type
3287 suite_dfilter.group_stringz
3288 suite_dfilter.group_time_relative
3289 suite_dfilter.group_time_type
3290 suite_dfilter.group_tvb
3291 suite_dfilter.group_uint64
3293 suite_dissectors.group_asterix
3306 # We don't currently handle spaces in arguments. On Windows this
3307 # means that you will probably have to pass in an interface index
3308 # instead of a name.
3309 set(TEST_EXTRA_ARGS "" CACHE STRING "Extra arguments to pass to test/test.py")
3310 separate_arguments(TEST_EXTRA_ARGS)
3312 foreach(_group_name ${_test_group_list})
3315 COMMAND ${CMAKE_COMMAND} -E env PYTHONIOENCODING=UTF-8
3316 ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/test/test.py
3318 --program-path ${WS_PROGRAM_PATH}
3322 set_tests_properties(${_group_name} PROPERTIES TIMEOUT 600)
3325 # Make it possible to run pytest without passing the full path as argument.
3326 if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
3327 file(READ "${CMAKE_CURRENT_SOURCE_DIR}/pytest.ini" pytest_ini)
3328 string(REGEX REPLACE "\naddopts = ([^\n]+)"
3329 "\naddopts = ${CMAKE_CURRENT_SOURCE_DIR}/test \\1"
3330 pytest_ini "${pytest_ini}")
3331 file(WRITE "${CMAKE_BINARY_DIR}/pytest.ini" "${pytest_ini}")
3335 # Update AUTHORS file with entries from git shortlog
3338 COMMAND ${PERL_EXECUTABLE} tools/generate_authors.pl AUTHORS.src > AUTHORS
3339 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
3341 else (GIT_EXECUTABLE)
3342 add_custom_target( gen-authors COMMAND ${CMAKE_COMMAND} -E echo "Git not found." )
3343 endif (GIT_EXECUTABLE)
3344 set_target_properties(gen-authors PROPERTIES FOLDER "Docs")
3347 file (TO_NATIVE_PATH ${CMAKE_SOURCE_DIR}/tools/Get-HardenFlags.ps1 _win_harden_flags)
3348 add_custom_target(hardening-check
3349 COMMAND ${POWERSHELL_COMMAND} "${_win_harden_flags}" "${_dll_output_dir_win}"
3351 COMMENT "Checking binaries for security features"
3353 set_target_properties(hardening-check PROPERTIES FOLDER "Tests")
3355 find_program(HARDENING_CHECK_EXECUTABLE hardening-check
3356 DOC "Path to the hardening-check utility."
3358 if(HARDENING_CHECK_EXECUTABLE)
3359 foreach(_prog ${PROGLIST})
3360 get_target_property(_prog_dir ${_prog} RUNTIME_OUTPUT_DIRECTORY)
3362 set(_prog_dir "${CMAKE_BINARY_DIR}/run")
3364 set(_prog_paths ${_prog_paths} "${_prog_dir}/${_prog}")
3366 add_custom_target(hardening-check
3367 COMMAND ${HARDENING_CHECK_EXECUTABLE} ${_prog_paths}
3369 COMMENT "Checking binaries for security features"
3384 find_program(SHELLCHECK_EXECUTABLE shellcheck
3385 DOC "Path to the shellcheck utility."
3387 if(SHELLCHECK_EXECUTABLE)
3388 add_custom_target(shellcheck)
3389 set_target_properties(shellcheck PROPERTIES FOLDER "Tests")
3390 # --external-sources requires 0.4.0 or later.
3391 add_custom_command(TARGET shellcheck POST_BUILD
3392 COMMAND shellcheck --external-sources
3393 image/stock_icons/svg-to-png.sh
3394 packaging/appimage/AppRun
3395 packaging/macosx/osx-app.sh.in
3396 packaging/macosx/osx-dmg.sh.in
3397 packaging/source/git-export-release.sh.in
3398 tools/compress-pngs.sh
3399 tools/debian-setup.sh
3403 tools/randpkt-test.sh
3404 tools/release-update-debian-soversions.sh
3405 tools/test-captures.sh
3407 tools/valgrind-wireshark.sh
3408 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
3413 # Editor modelines - https://www.wireshark.org/tools/modelines.html
3418 # indent-tabs-mode: t
3421 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
3422 # :indentSize=8:tabSize=8:noTabs=false: