3 # We need 3.12 or later, so that we can set policy CMP0074; see
6 cmake_minimum_required(VERSION 3.12)
11 # if this is a version of CMake less than 3.5, require only
12 # 2.8.12, just in case somebody is configuring with CMake
13 # on a "long-term support" version # of some OS and that
14 # version supplies an older version of CMake;
16 # otherwise, require 3.5, so we don't get messages warning
17 # that support for versions of CMake lower than 3.5 is
20 if(CMAKE_VERSION VERSION_LESS "3.5")
21 cmake_minimum_required(VERSION 2.8.12)
23 cmake_minimum_required(VERSION 3.5)
28 # We want find_path() and find_library() to honor {packagename}_ROOT,
29 # as that appears to be the standard way to say "hey, look here for
30 # this package" from the command line.
33 cmake_policy(SET CMP0074 NEW)
39 # When building on NetBSD, with a libpcap installed from pkgsrc,
40 # a -Wl,-rpath,/usr/pkg/lib option is added to the options when
41 # linking tcpdump. This puts /usr/pkg/lib into the run-time path.
43 # However, by default, CMake adds a rule to the install CMake script
44 # a CMake command (using an undocumented subcommand of file()) that
45 # strips /usr/pkg/lib *out* of the run-time path; the message in the
46 # output for the "install" target is
48 # -- Set runtime path of "{target-directory}/tcpdump" to ""
50 # I am not certain what the rationale is for doing this, but a
51 # *consequence* of this is that, when you run the installed tcpdump,
52 # it fails to find libpcap.so:
54 # $ {target-directory}/tcpdump -h
55 # {target-directory}/tcpdump: Shared object "libpcap.so.0" not found
57 # It also appears to be the case that, on Ubuntu 22.04, FreeBSD 12,
58 # DragonFly BSD 5.8, OpenBSD 6.6, and Solaris 11.4,
60 # On Ubuntu and Solaris, even if you have a libpcap in /usr/local, you
61 # have to provide not only -I/usr/local/include and -L/usr/local/lib,
62 # you also must provide -Wl,-rpath,/usr/local/lib in order to have
63 # the run-time linker look in /usr/local/lib for libpcap. If it's not
64 # specified, then, if the shared library major version number of the
65 # libpcap in /usr/lib is the same as the shared major version number
66 # of the libpcap in /usr/local/lib, the run-time linker will find the
67 # libpcap in /usr/lib; if the versions are different, the run-time
68 # linker will fail to find the libpcap in /usr/lib, so the program will
71 # We suppress this by setting CMAKE_INSTALL_RPATH_USE_LINK_PATH to TRUE;
72 # as the documentation for that variable says:
74 # Add paths to linker search and installed rpath.
76 # CMAKE_INSTALL_RPATH_USE_LINK_PATH is a boolean that if set to True
77 # will append to the runtime search path (rpath) of installed
78 # binaries any directories outside the project that are in the linker
79 # search path or contain linked library files. The directories are
80 # appended after the value of the INSTALL_RPATH target property.
82 # If, for whatever reason, directories in which we search for external
83 # libraries, other than the standard system library directories, are
84 # added to the executable's rpath in the build process, we most
85 # definitely want them in the installed image's rpath if they are
86 # necessary in order to find the libraries at run time.
88 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
90 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
93 # We explicitly indicate what languages are used in tcpdump to avoid
94 # checking for a C++ compiler.
96 # One reason to avoid that check is that there's no need to waste
97 # configuration time performing it.
99 # Another reason is that:
101 # CMake will try to determine the sizes of some data types, including
102 # void *, early in the process of configuration; apparently, it's done
103 # as part of processing the project() command.
105 # At least as of CMake 2.8.6, it does so by checking the size of
106 # "void *" in C, setting CMAKE_C_SIZEOF_DATA_PTR based on that,
107 # setting CMAKE_SIZEOF_VOID_P to that, and then checking the size
108 # of "void *" in C++, setting CMAKE_CXX_SIZEOF_DATA_PTR based on
109 # that, and then setting CMAKE_SIZEOF_VOID_P to *that*.
111 # The compile tests include whatever C flags may have been provided
112 # to CMake in the CFLAGS and CXXFLAGS environment variables.
114 # If you set an architecture flag such as -m32 or -m64 in CFLAGS
115 # but *not* in CXXFLAGS, the size for C++ will win, and hilarity
118 # Or if, at least on Solaris, you have a newer version of GCC
119 # installed, but *not* a newer version of G++, and you have Oracle
120 # Studio installed, it will find GCC, which will default to building
121 # 64-bit, and Oracle Studio's C++ compiler, which will default to
122 # building 32-bit, the size for C++ will win, and, again, hilarity
128 # Export the size of void * as SIZEOF_VOID_P so that it can be
131 set(SIZEOF_VOID_P "${CMAKE_SIZEOF_VOID_P}")
134 # Show the bit width for which we're compiling.
135 # This can help debug problems if you're dealing with a compiler that
136 # defaults to generating 32-bit code even when running on a 64-bit
137 # platform, and where that platform may provide only 64-bit versions of
138 # libraries that we might use (looking at *you*, Oracle Studio!).
140 if(CMAKE_SIZEOF_VOID_P EQUAL 4)
141 message(STATUS "Building 32-bit")
142 elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
143 message(STATUS "Building 64-bit")
147 # Solaris pkg-config is annoying. For at least one package (D-Bus, I'm
148 # looking at *you*!), there are separate include files for 32-bit and
149 # 64-bit builds (I guess using "unsigned long long" as a 64-bit integer
150 # type on a 64-bit build is like crossing the beams or something), and
151 # there are two separate .pc files, so if we're doing a 32-bit build we
152 # should make sure we look in /usr/lib/pkgconfig for .pc files and if
153 # we're doing a 64-bit build we should make sure we look in
154 # /usr/lib/amd64/pkgconfig for .pc files.
156 if(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*")
158 # Note: string(REPLACE) does not appear to support using ENV{...}
159 # as an argument, so we set a variable and then use set() to set
160 # the environment variable.
162 if(CMAKE_SIZEOF_VOID_P EQUAL 8)
164 # 64-bit build. If /usr/lib/pkgconfig appears in the path,
165 # prepend /usr/lib/amd64/pkgconfig to it; otherwise,
166 # put /usr/lib/amd64 at the end.
168 if((NOT DEFINED ENV{PKG_CONFIG_PATH}) OR "$ENV{PKG_CONFIG_PATH}" EQUAL "")
170 # Not set, or empty. Set it to /usr/lib/amd64/pkgconfig.
172 set(fixed_path "/usr/lib/amd64/pkgconfig")
173 elseif("$ENV{PKG_CONFIG_PATH}" MATCHES "/usr/lib/pkgconfig")
175 # It contains /usr/lib/pkgconfig. Prepend
176 # /usr/lib/amd64/pkgconfig to /usr/lib/pkgconfig.
178 string(REPLACE "/usr/lib/pkgconfig"
179 "/usr/lib/amd64/pkgconfig:/usr/lib/pkgconfig"
180 fixed_path "$ENV{PKG_CONFIG_PATH}")
183 # Not empty, but doesn't contain /usr/lib/pkgconfig.
184 # Append /usr/lib/amd64/pkgconfig to it.
186 set(fixed_path "$ENV{PKG_CONFIG_PATH}:/usr/lib/amd64/pkgconfig")
188 set(ENV{PKG_CONFIG_PATH} "${fixed_path}")
189 elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
191 # 32-bit build. If /usr/amd64/lib/pkgconfig appears in the path,
192 # prepend /usr/lib/pkgconfig to it.
194 if("$ENV{PKG_CONFIG_PATH}" MATCHES "/usr/lib/amd64/pkgconfig")
196 # It contains /usr/lib/amd64/pkgconfig. Prepend
197 # /usr/lib/pkgconfig to /usr/lib/amd64/pkgconfig.
199 string(REPLACE "/usr/lib/amd64/pkgconfig"
200 "/usr/lib/pkgconfig:/usr/lib/amd64/pkgconfig"
201 fixed_path "$ENV{PKG_CONFIG_PATH}")
202 set(ENV{PKG_CONFIG_PATH} "${fixed_path}")
208 # For checking if a compiler flag works and adding it if it does.
210 include(CheckCCompilerFlag)
211 macro(check_and_add_compiler_option _option)
212 message(STATUS "Checking C compiler flag ${_option}")
213 string(REPLACE "=" "-" _temp_option_variable ${_option})
214 string(REGEX REPLACE "^-" "" _option_variable ${_temp_option_variable})
215 check_c_compiler_flag("${_option}" ${_option_variable})
216 if(${${_option_variable}})
217 set(C_ADDITIONAL_FLAGS "${C_ADDITIONAL_FLAGS} ${_option}")
222 # If we're building with Visual Studio, we require Visual Studio 2015,
223 # in order to get sufficient C99 compatibility. Check for that.
225 # If not, try the appropriate flag for the compiler to enable C99
228 set(C_ADDITIONAL_FLAGS "")
230 if(MSVC_VERSION LESS 1900)
231 message(FATAL_ERROR "Visual Studio 2015 or later is required")
235 # Treat source files as being in UTF-8 with MSVC if it's not using
236 # the Clang front end.
237 # We assume that UTF-8 source is OK with other compilers and with
238 # MSVC if it's using the Clang front end.
240 if(NOT ${CMAKE_C_COMPILER} MATCHES "clang*")
241 set(C_ADDITIONAL_FLAGS "${C_ADDITIONAL_FLAGS} /utf-8")
242 endif(NOT ${CMAKE_C_COMPILER} MATCHES "clang*")
245 # Try to enable as many C99 features as we can.
246 # At minimum, we want C++/C99-style // comments.
248 # Newer versions of compilers might default to supporting C99, but
249 # older versions may require a special flag.
251 # Prior to CMake 3.1, setting CMAKE_C_STANDARD will not have any effect,
252 # so, unless and until we require CMake 3.1 or later, we have to do it
253 # ourselves on pre-3.1 CMake, so we just do it ourselves on all versions
256 # Note: with CMake 3.1 through 3.5, the only compilers for which CMake
257 # handles CMAKE_C_STANDARD are GCC and Clang. 3.6 adds support only
258 # for Intel C; 3.9 adds support for PGI C, Sun C, and IBM XL C, and
259 # 3.10 adds support for Cray C and IAR C, but no version of CMake has
260 # support for HP C. Therefore, even if we use CMAKE_C_STANDARD with
261 # compilers for which CMake supports it, we may still have to do it
262 # ourselves on other compilers.
264 # See the CMake documentation for the CMAKE_<LANG>_COMPILER_ID variables
265 # for a list of compiler IDs.
267 # XXX - this just tests whether the option works and adds it if it does.
268 # We don't test whether it's necessary in order to get the C99 features
269 # that we use; if we ever have a user who tries to compile with a compiler
270 # that can't be made to support those features, we can add a test to make
271 # sure we actually *have* C99 support.
273 if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR
274 CMAKE_C_COMPILER_ID MATCHES "Clang")
275 check_and_add_compiler_option("-std=gnu99")
276 elseif(CMAKE_C_COMPILER_ID MATCHES "XL")
278 # We want support for extensions picked up for GNU C compatibility,
279 # so we use -qlanglvl=extc99.
281 check_and_add_compiler_option("-qlanglvl=extc99")
282 elseif(CMAKE_C_COMPILER_ID MATCHES "HP")
283 check_and_add_compiler_option("-AC99")
284 elseif(CMAKE_C_COMPILER_ID MATCHES "Sun")
285 check_and_add_compiler_option("-xc99")
286 elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
287 check_and_add_compiler_option("-c99")
291 set(LIBRARY_NAME netdissect)
293 ###################################################################
295 ###################################################################
297 option(WITH_SMI "Build with libsmi, if available" ON)
298 option(WITH_CRYPTO "Build with OpenSSL/libressl libcrypto, if available" ON)
299 option(WITH_CAPSICUM "Build with Capsicum security functions, if available" ON)
300 option(WITH_CAP_NG "Use libcap-ng, if available" ON)
301 option(ENABLE_SMB "Build with the SMB dissector" OFF)
304 # String parameters. Neither of them are set, initially; only if the
305 # user explicitly configures them are they set.
307 # WITH_CHROOT is STRING, not PATH, as the directory need not exist
310 set(WITH_CHROOT CACHE STRING
311 "Directory to which to chroot when dropping privileges")
312 set(WITH_USER CACHE STRING
313 "User to whom to set the UID when dropping privileges")
316 # By default, build universal with the appropriate set of architectures
317 # for the OS on which we're doing the build.
319 if(APPLE AND "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
321 # Get the major version of Darwin.
323 string(REGEX MATCH "^([0-9]+)" SYSTEM_VERSION_MAJOR "${CMAKE_SYSTEM_VERSION}")
325 if(SYSTEM_VERSION_MAJOR EQUAL 9)
327 # Leopard. Build for x86 and 32-bit PowerPC, with
328 # x86 first. (That's what Apple does.)
330 set(CMAKE_OSX_ARCHITECTURES "i386;ppc")
331 elseif(SYSTEM_VERSION_MAJOR EQUAL 10)
333 # Snow Leopard. Build for x86-64 and x86, with
334 # x86-64 first. (That's what Apple does.)
336 set(CMAKE_OSX_ARCHITECTURES "x86_64;i386")
340 ###################################################################
342 ###################################################################
344 # Get, parse, format and set tcpdump's version string from
345 # [tcpdump_root]/VERSION for later use.
347 # Get MAJOR, MINOR, PATCH & SUFFIX
348 file(STRINGS ${tcpdump_SOURCE_DIR}/VERSION
350 LIMIT_COUNT 1 # Read only the first line
353 ######################################
355 ######################################
358 ${CMAKE_CURRENT_BINARY_DIR}
359 ${tcpdump_SOURCE_DIR}
363 add_definitions(-D__STDC__)
364 add_definitions(-D_CRT_SECURE_NO_WARNINGS)
369 MESSAGE(STATUS "Use STATIC runtime")
371 set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MT")
372 set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT")
373 set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
374 set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
376 set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT")
377 set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT")
378 set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
379 set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
381 MESSAGE(STATUS "Use DYNAMIC runtime")
383 set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MD")
384 set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MD")
385 set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
386 set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
388 set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MD")
389 set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MD")
390 set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MD")
391 set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MDd")
392 endif (USE_STATIC_RT)
395 ###################################################################
396 # Detect available platform features
397 ###################################################################
399 include(CMakePushCheckState)
400 include(CheckIncludeFile)
401 include(CheckIncludeFiles)
402 include(CheckFunctionExists)
403 include(CheckLibraryExists)
404 include(CheckSymbolExists)
405 include(CheckStructHasMember)
406 include(CheckVariableExists)
407 include(CheckTypeSize)
410 # Get the size of a time_t, to know whether it's 32-bit or 64-bit.
412 cmake_push_check_state()
413 set(CMAKE_EXTRA_INCLUDE_FILES time.h)
414 check_type_size("time_t" SIZEOF_TIME_T)
415 cmake_pop_check_state()
420 check_include_file(rpc/rpc.h HAVE_RPC_RPC_H)
422 check_include_files("rpc/rpc.h;rpc/rpcent.h" HAVE_RPC_RPCENT_H)
423 endif(HAVE_RPC_RPC_H)
428 check_function_exists(strlcat HAVE_STRLCAT)
429 check_function_exists(strlcpy HAVE_STRLCPY)
430 check_function_exists(strsep HAVE_STRSEP)
433 # Find library needed for gethostbyaddr.
434 # NOTE: if you hand check_library_exists as its last argument a variable
435 # that's been set, it skips the test, so we need different variables.
437 set(TCPDUMP_LINK_LIBRARIES "")
440 # We need winsock2.h and ws2tcpip.h.
442 cmake_push_check_state()
443 set(CMAKE_REQUIRED_LIBRARIES ws2_32)
444 check_symbol_exists(gethostbyaddr "winsock2.h;ws2tcpip.h" LIBWS2_32_HAS_GETHOSTBYADDR)
445 cmake_pop_check_state()
446 if(LIBWS2_32_HAS_GETHOSTBYADDR)
447 set(TCPDUMP_LINK_LIBRARIES ws2_32 ${TCPDUMP_LINK_LIBRARIES})
448 else(LIBWS2_32_HAS_GETHOSTBYADDR)
449 message(FATAL_ERROR "gethostbyaddr is required, but wasn't found")
450 endif(LIBWS2_32_HAS_GETHOSTBYADDR)
452 check_function_exists(gethostbyaddr STDLIBS_HAVE_GETHOSTBYADDR)
453 if(NOT STDLIBS_HAVE_GETHOSTBYADDR)
454 check_library_exists(socket gethostbyaddr "" LIBSOCKET_HAS_GETHOSTBYADDR)
455 if(LIBSOCKET_HAS_GETHOSTBYADDR)
456 set(TCPDUMP_LINK_LIBRARIES ${TCPDUMP_LINK_LIBRARIES} socket)
457 else(LIBSOCKET_HAS_GETHOSTBYADDR)
458 check_library_exists(nsl gethostbyaddr "" LIBNSL_HAS_GETHOSTBYADDR)
459 if(LIBNSL_HAS_GETHOSTBYADDR)
460 set(TCPDUMP_LINK_LIBRARIES ${TCPDUMP_LINK_LIBRARIES} nsl)
461 else(LIBNSL_HAS_GETHOSTBYADDR)
462 check_library_exists(network gethostbyaddr "" LIBNETWORK_HAS_GETHOSTBYADDR)
463 if(LIBNETWORK_HAS_GETHOSTBYADDR)
464 set(TCPDUMP_LINK_LIBRARIES ${TCPDUMP_LINK_LIBRARIES} network)
465 else(LIBNETWORK_HAS_GETHOSTBYADDR)
466 message(FATAL_ERROR "gethostbyaddr is required, but wasn't found")
467 endif(LIBNETWORK_HAS_GETHOSTBYADDR)
468 endif(LIBNSL_HAS_GETHOSTBYADDR)
469 endif(LIBSOCKET_HAS_GETHOSTBYADDR)
470 endif(NOT STDLIBS_HAVE_GETHOSTBYADDR)
474 # This may require additional libraries.
476 cmake_push_check_state()
477 set(CMAKE_REQUIRED_LIBRARIES ${TCPDUMP_LINK_LIBRARIES})
478 check_function_exists(getservent STDLIBS_HAVE_GETSERVENT)
479 if(STDLIBS_HAVE_GETSERVENT)
480 set(HAVE_GETSERVENT TRUE)
481 else(STDLIBS_HAVE_GETSERVENT)
483 # Some platforms may need -lsocket for getservent.
485 set(CMAKE_REQUIRED_LIBRARIES socket ${TCPDUMP_LINK_LIBRARIES})
486 check_function_exists(getservent LIBSOCKET_HAS_GETSERVENT)
487 if(LIBSOCKET_HAS_GETSERVENT)
488 set(HAVE_GETSERVENT TRUE)
489 set(TCPDUMP_LINK_LIBRARIES socket ${TCPDUMP_LINK_LIBRARIES})
490 endif(LIBSOCKET_HAS_GETSERVENT)
491 endif(STDLIBS_HAVE_GETSERVENT)
492 cmake_pop_check_state()
495 # Require a proof of suitable snprintf(3), same as in Autoconf.
497 include(CheckCSourceRuns)
498 check_c_source_runs("
501 #include <inttypes.h>
502 #include <sys/types.h>
507 uint64_t t = (uint64_t)1 << 32;
509 snprintf(buf, sizeof(buf), \"%zu\", sizeof(buf));
510 if (strncmp(buf, \"100\", sizeof(buf)))
513 snprintf(buf, sizeof(buf), \"%zd\", -sizeof(buf));
514 if (strncmp(buf, \"-100\", sizeof(buf)))
517 snprintf(buf, sizeof(buf), \"%\" PRId64, -t);
518 if (strncmp(buf, \"-4294967296\", sizeof(buf)))
521 snprintf(buf, sizeof(buf), \"0o%\" PRIo64, t);
522 if (strncmp(buf, \"0o40000000000\", sizeof(buf)))
525 snprintf(buf, sizeof(buf), \"0x%\" PRIx64, t);
526 if (strncmp(buf, \"0x100000000\", sizeof(buf)))
529 snprintf(buf, sizeof(buf), \"%\" PRIu64, t);
530 if (strncmp(buf, \"4294967296\", sizeof(buf)))
539 if(NOT SUITABLE_SNPRINTF)
541 "The snprintf(3) implementation in this libc is not suitable,
542 tcpdump would not work correctly even if it managed to compile."
546 check_function_exists(getopt_long HAVE_GETOPT_LONG)
548 # For Windows, don't need to waste time checking for fork() or vfork().
551 check_function_exists(fork HAVE_FORK)
552 check_function_exists(vfork HAVE_VFORK)
556 # Some platforms may need -lnsl for getrpcbynumber.
558 cmake_push_check_state()
559 set(CMAKE_REQUIRED_LIBRARIES ${TCPDUMP_LINK_LIBRARIES})
560 check_function_exists(getrpcbynumber STDLIBS_HAVE_GETRPCBYNUMBER)
561 if(STDLIBS_HAVE_GETRPCBYNUMBER)
562 set(HAVE_GETRPCBYNUMBER TRUE)
563 else(STDLIBS_HAVE_GETRPCBYNUMBER)
564 set(CMAKE_REQUIRED_LIBRARIES ${TCPDUMP_LINK_LIBRARIES} nsl)
565 check_function_exists(getrpcbynumber LIBNSL_HAS_GETRPCBYNUMBER)
566 if(LIBNSL_HAS_GETRPCBYNUMBER)
567 set(HAVE_GETRPCBYNUMBER TRUE)
568 set(TCPDUMP_LINK_LIBRARIES ${TCPDUMP_LINK_LIBRARIES} nsl)
569 endif(LIBNSL_HAS_GETRPCBYNUMBER)
570 endif(STDLIBS_HAVE_GETRPCBYNUMBER)
571 cmake_pop_check_state()
574 # This requires the libraries we require, as ether_ntohost might be
575 # in one of those libraries. That means we have to do this after
576 # we check for those libraries.
578 # You are in a twisty little maze of UN*Xes, all different.
579 # Some might not have ether_ntohost().
580 # Some might have it and declare it in <net/ethernet.h>.
581 # Some might have it and declare it in <netinet/ether.h>
582 # Some might have it and declare it in <sys/ethernet.h>.
583 # Some might have it and declare it in <arpa/inet.h>.
584 # Some might have it and declare it in <netinet/if_ether.h>.
585 # Some might have it and not declare it in any header file.
587 # Before you is a C compiler.
589 cmake_push_check_state()
590 set(CMAKE_REQUIRED_LIBRARIES ${TCPDUMP_LINK_LIBRARIES})
591 check_function_exists(ether_ntohost HAVE_ETHER_NTOHOST)
592 if(HAVE_ETHER_NTOHOST)
594 # OK, we have ether_ntohost(). We don't check whether it's buggy,
595 # as we assume any system that has CMake is likely to be new enough
596 # that, if it has ether_ntohost(), whatever bug is checked for in
597 # autotools is fixed; we just decide to use it.
599 set(USE_ETHER_NTOHOST TRUE)
602 # Is it declared in <net/ethernet.h>?
604 # This test fails if we don't have <net/ethernet.h> or if we do
605 # but it doesn't declare ether_ntohost().
607 check_symbol_exists(ether_ntohost net/ethernet.h NET_ETHERNET_H_DECLARES_ETHER_NTOHOST)
608 if(NET_ETHERNET_H_DECLARES_ETHER_NTOHOST)
610 # Yes - we have it declared.
612 set(HAVE_DECL_ETHER_NTOHOST TRUE)
617 if(NOT HAVE_DECL_ETHER_NTOHOST)
619 # No - how about <netinet/ether.h>, as on Linux?
621 # This test fails if we don't have <netinet/ether.h>
622 # or if we do but it doesn't declare ether_ntohost().
624 check_symbol_exists(ether_ntohost netinet/ether.h NETINET_ETHER_H_DECLARES_ETHER_NTOHOST)
625 if(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST)
627 # Yes - we have it declared.
629 set(HAVE_DECL_ETHER_NTOHOST TRUE)
635 if(NOT HAVE_DECL_ETHER_NTOHOST)
637 # No - how about <sys/ethernet.h>, as on Solaris 10 and later?
639 # This test fails if we don't have <sys/ethernet.h>
640 # or if we do but it doesn't declare ether_ntohost().
642 check_symbol_exists(ether_ntohost sys/ethernet.h SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST)
643 if(SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST)
645 # Yes - we have it declared.
647 set(HAVE_DECL_ETHER_NTOHOST TRUE)
653 if(NOT HAVE_DECL_ETHER_NTOHOST)
655 # No, how about <arpa/inet.h>, as on AIX?
657 # This test fails if we don't have <arpa/inet.h>
658 # or if we do but it doesn't declare ether_ntohost().
660 check_symbol_exists(ether_ntohost arpa/inet.h ARPA_INET_H_DECLARES_ETHER_NTOHOST)
661 if(ARPA_INET_H_DECLARES_ETHER_NTOHOST)
663 # Yes - we have it declared.
665 set(HAVE_DECL_ETHER_NTOHOST TRUE)
671 if(NOT HAVE_DECL_ETHER_NTOHOST)
673 # No, how about <netinet/if_ether.h>?
674 # On some platforms, it requires <net/if.h> and
675 # <netinet/in.h>, and we always include it with
676 # both of them, so test it with both of them.
678 # This test fails if we don't have <netinet/if_ether.h>
679 # and the headers we include before it, or if we do but
680 # <netinet/if_ether.h> doesn't declare ether_ntohost().
682 check_symbol_exists(ether_ntohost "sys/types.h;sys/socket.h;net/if.h;netinet/in.h;netinet/if_ether.h" NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST)
683 if(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST)
685 # Yes - we have it declared.
687 set(HAVE_DECL_ETHER_NTOHOST TRUE)
691 # After all that, is ether_ntohost() declared?
693 if(NOT HAVE_DECL_ETHER_NTOHOST)
695 # No, we'll have to declare it ourselves.
696 # Do we have "struct ether_addr" if we include<netinet/if_ether.h>?
698 check_struct_has_member("struct ether_addr" octet "sys/types.h;sys/socket.h;net/if.h;netinet/in.h;netinet/if_ether.h" HAVE_STRUCT_ETHER_ADDR)
701 cmake_pop_check_state()
706 # XXX - there's no check_struct() macro that's like check_struct_has_member()
707 # except that it only checks for the existence of the structure type,
708 # so we use check_struct_has_member() and look for ss_family.
711 ######################################
712 # External dependencies
713 ######################################
716 # libpcap/WinPcap/Npcap.
719 find_package(PCAP REQUIRED)
720 include_directories(${PCAP_INCLUDE_DIRS})
722 cmake_push_check_state()
727 set(CMAKE_REQUIRED_INCLUDES ${PCAP_INCLUDE_DIRS})
730 # Check whether we have pcap/pcap-inttypes.h.
731 # If we do, we use that to get the C99 types defined.
733 check_include_file(pcap/pcap-inttypes.h HAVE_PCAP_PCAP_INTTYPES_H)
736 # Check for various functions in libpcap/WinPcap/Npcap.
738 cmake_push_check_state()
739 set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARIES})
742 # Do we have the new open API? Check for pcap_create() and for
743 # pcap_statustostr(), and assume that, if we have both of them,
744 # we also have pcap_activate() and the other new routines
745 # introduced in libpcap 1.0.
747 # We require those routines, so fail if we don't find it.
749 check_function_exists(pcap_create HAVE_PCAP_CREATE)
750 if(NOT HAVE_PCAP_CREATE)
752 MESSAGE(FATAL_ERROR "libpcap is too old; 1.0 or later is required")
754 MESSAGE(FATAL_ERROR "libpcap is too old; 1.0 or later is required - if you're using WinPcap, try Npcap")
756 endif(NOT HAVE_PCAP_CREATE)
760 # We check for pcap_statustostr() as well, because WinPcap 4.1.3
761 # screwed up and exported pcap_create() but not other routines
762 # such as pcap_statustostr(), even though it defined them and
763 # even though you really want pcap_statustostr() to get strings
764 # corresponding to some of the status returns from the new routines.)
766 check_function_exists(pcap_statustostr HAVE_PCAP_STATUSTOSTR)
767 if(NOT HAVE_PCAP_STATUSTOSTR)
768 MESSAGE(FATAL_ERROR "pcap_create is available, but pcap_statustostr isn't - if you're using WinPcap, try Npcap ")
769 endif(NOT HAVE_PCAP_STATUSTOSTR)
773 # OK, do we have pcap_set_tstamp_type? If so, assume we have
774 # pcap_list_tstamp_types and pcap_free_tstamp_types as well.
776 check_function_exists(pcap_set_tstamp_type HAVE_PCAP_SET_TSTAMP_TYPE)
779 # And do we have pcap_set_tstamp_precision? If so, we assume
780 # we also have pcap_open_offline_with_tstamp_precision.
782 check_function_exists(pcap_set_tstamp_precision HAVE_PCAP_SET_TSTAMP_PRECISION)
785 # Check for a miscellaneous collection of functions which we use
788 check_function_exists(pcap_set_immediate_mode HAVE_PCAP_SET_IMMEDIATE_MODE)
789 check_function_exists(pcap_dump_ftell64 HAVE_PCAP_DUMP_FTELL64)
791 # macOS Sonoma's libpcap includes stub versions of the remote-
792 # capture APIs. They are exported as "weakly linked symbols".
794 # Xcode 15 offers only a macOS Sonoma SDK, which has a .tbd
795 # file for libpcap that claims it includes those APIs. (Newer
796 # versions of macOS don't provide the system shared libraries,
797 # they only provide the dyld shared cache containing those
798 # libraries, so the OS provides SDKs that include a .tbd file
799 # to use when linking.)
801 # This means that check_function_exists() will think that
802 # the remote-capture APIs are present, including pcap_open()
803 # and pcap_findalldevs_ex().
805 # However, they are *not* present in macOS Ventura and earlier,
806 # which means that building on Ventura with Xcode 15 produces
807 # executables that fail to start because one of those APIs
808 # isn't found in the system libpcap.
810 # Protecting calls to those APIs with __builtin_available()
811 # does not prevent this, because the libpcap header files
812 # in the Sonoma SDK mark them as being first available
813 # in macOS 10.13, just like all the other routines introduced
814 # in libpcap 1.9, even though they're only available if libpcap
815 # is built with remote capture enabled or stub routines are
816 # provided. (A fix to enable this has been checked into the
817 # libpcap repository, and may end up in a later version of
820 # Given all that, and given that the versions of the
821 # remote-capture APIs in Sonoma are stubs that always fail,
822 # there doesn't seem to be any point in checking for pcap_open()
823 # and pcap_findalldevs_ex() if we're linking against the Apple libpcap.
825 # However, if we're *not* linking against the Apple libpcap,
826 # we should check for it, so that we can use it if it's present.
828 # So we check for pcap_open() and pcap_findalldevs_ex() if 1) this isn't
829 # macOS or 2) the the libpcap we found is not a system library, meaning
830 # that its path begins neither with /usr/lib (meaning it's a system
831 # dylib) nor /Application/Xcode.app (meaning it's a file in
835 (PCAP_LIBRARIES MATCHES "/usr/lib/.*" OR
836 PCAP_LIBRARIES MATCHES "/Application/Xcode.app/.*"))
837 check_function_exists(pcap_open HAVE_PCAP_OPEN)
838 check_function_exists(pcap_findalldevs_ex HAVE_PCAP_FINDALLDEVS_EX)
842 # On Windows, check for pcap_wsockinit(); if we don't have it, check for
846 check_function_exists(pcap_wsockinit HAVE_PCAP_WSOCKINIT)
847 if(NOT HAVE_PCAP_WSOCKINIT)
848 check_function_exists(wsockinit HAVE_WSOCKINIT)
849 endif(NOT HAVE_PCAP_WSOCKINIT)
853 # Check for special debugging functions
855 check_function_exists(pcap_set_parser_debug HAVE_PCAP_SET_PARSER_DEBUG)
856 if(NOT HAVE_PCAP_SET_PARSER_DEBUG)
857 # Check whether libpcap defines pcap_debug or yydebug
858 check_variable_exists(pcap_debug HAVE_PCAP_DEBUG)
859 if(NOT HAVE_PCAP_DEBUG)
860 check_variable_exists(yydebug HAVE_YYDEBUG)
861 endif(NOT HAVE_PCAP_DEBUG)
862 endif(NOT HAVE_PCAP_SET_PARSER_DEBUG)
864 check_function_exists(pcap_set_optimizer_debug HAVE_PCAP_SET_OPTIMIZER_DEBUG)
867 # bpf_dump() moved from tcpdump to libpcap in libpcap 0.6, but not all
868 # versions of libpcap didn't pick that change up; the OpenBSD libpcap
869 # picked up most of the new APIs from versions up to 1.0, but didn't
870 # pick up bpf_dump(), so we need to provide it if it's absent.
872 check_function_exists(bpf_dump HAVE_BPF_DUMP)
874 cmake_pop_check_state()
875 cmake_pop_check_state()
880 include_directories(SYSTEM ${PCAP_INCLUDE_DIRS})
881 set(TCPDUMP_LINK_LIBRARIES ${PCAP_LIBRARIES} ${TCPDUMP_LINK_LIBRARIES})
884 # Optional libraries.
893 include_directories(SYSTEM ${SMI_INCLUDE_DIRS})
894 set(TCPDUMP_LINK_LIBRARIES ${TCPDUMP_LINK_LIBRARIES} ${SMI_LIBRARIES})
900 # OpenSSL/libressl libcrypto.
906 # 1) do we have EVP_CIPHER_CTX_new?
907 # If so, we use it to allocate an EVP_CIPHER_CTX, as
908 # EVP_CIPHER_CTX may be opaque; otherwise, we allocate
911 cmake_push_check_state()
912 set(CMAKE_REQUIRED_LIBRARIES "${CRYPTO_LIBRARIES}")
914 check_function_exists(EVP_CIPHER_CTX_new HAVE_EVP_CIPHER_CTX_NEW)
917 # 2) do we have EVP_DecryptInit_ex()?
918 # If so, we use it, because we need to be able to make two
919 # "initialize the cipher" calls, one with the cipher and key,
920 # and one with the IV, and, as of OpenSSL 1.1, You Can't Do That
921 # with EVP_DecryptInit(), because a call to EVP_DecryptInit() will
922 # unconditionally clear the context, and if you don't supply a
923 # cipher, it'll clear the cipher, rendering the context unusable
924 # and causing a crash.
926 check_function_exists(EVP_DecryptInit_ex HAVE_EVP_DECRYPTINIT_EX)
928 cmake_pop_check_state()
933 include_directories(SYSTEM ${CRYPTO_INCLUDE_DIRS})
934 set(TCPDUMP_LINK_LIBRARIES ${TCPDUMP_LINK_LIBRARIES} ${CRYPTO_LIBRARIES})
935 set(HAVE_LIBCRYPTO ON)
940 # Capsicum sandboxing.
941 # Some of this is in the system library, some of it is in other libraries.
944 check_include_files("sys/capsicum.h" HAVE_SYS_CAPSICUM_H)
945 if(HAVE_SYS_CAPSICUM_H)
946 check_function_exists(cap_enter HAVE_CAP_ENTER)
947 check_function_exists(cap_rights_limit HAVE_CAP_RIGHTS_LIMIT)
948 check_function_exists(cap_ioctls_limit HAVE_CAP_IOCTLS_LIMIT)
949 check_function_exists(openat HAVE_OPENAT)
950 if(HAVE_CAP_ENTER AND HAVE_CAP_RIGHTS_LIMIT AND
951 HAVE_CAP_IOCTLS_LIMIT AND HAVE_OPENAT)
953 # OK, we have the functions we need to support Capsicum.
955 set(HAVE_CAPSICUM TRUE)
958 # OK, can we use Casper?
960 check_library_exists(casper cap_init "" HAVE_CAP_INIT)
962 cmake_push_check_state()
963 set(CMAKE_REQUIRED_LIBRARIES casper)
964 check_library_exists(cap_dns cap_gethostbyaddr "" HAVE_CAP_GETHOSTBYADDR)
965 cmake_pop_check_state()
966 if(HAVE_CAP_GETHOSTBYADDR)
967 set(HAVE_CASPER TRUE)
968 set(TCPDUMP_LINK_LIBRARIES ${TCPDUMP_LINK_LIBRARIES} casper cap_dns)
969 endif(HAVE_CAP_GETHOSTBYADDR)
971 endif(HAVE_CAP_ENTER AND HAVE_CAP_RIGHTS_LIMIT AND
972 HAVE_CAP_IOCTLS_LIMIT AND HAVE_OPENAT)
973 endif(HAVE_SYS_CAPSICUM_H)
980 check_include_file(cap-ng.h HAVE_CAP_NG_H)
981 check_library_exists(cap-ng capng_change_id "" HAVE_LIBCAP_NG)
983 set(TCPDUMP_LINK_LIBRARIES ${TCPDUMP_LINK_LIBRARIES} cap-ng)
984 endif(HAVE_LIBCAP_NG)
987 ###################################################################
989 ###################################################################
992 # Check and add warning options if we have a .devel file.
994 if(EXISTS ${CMAKE_SOURCE_DIR}/.devel OR EXISTS ${CMAKE_BINARY_DIR}/.devel)
998 if(MSVC AND NOT ${CMAKE_C_COMPILER} MATCHES "clang*")
1000 # MSVC, with Microsoft's front end and code generator.
1001 # "MSVC" is also set for Microsoft's compiler with a Clang
1002 # front end and their code generator ("Clang/C2"), so we
1003 # check for clang.exe and treat that differently.
1005 check_and_add_compiler_option(-Wall)
1007 # Disable some pointless warnings that /Wall turns on.
1009 # Unfortunately, MSVC does not appear to have an equivalent
1010 # to "__attribute__((unused))" to mark a particular function
1011 # parameter as being known to be unused, so that the compiler
1012 # won't warn about it (for example, the function might have
1013 # that parameter because a pointer to it is being used, and
1014 # the signature of that function includes that parameter).
1015 # C++ lets you give a parameter a type but no name, but C
1016 # doesn't have that.
1018 check_and_add_compiler_option(-wd4100)
1020 # In theory, we care whether somebody uses f() rather than
1021 # f(void) to declare a function with no arguments, but, in
1022 # practice, there are places in the Windows header files
1023 # that appear to do that, so we squelch that warning.
1025 check_and_add_compiler_option(-wd4255)
1027 # Windows FD_SET() generates this, so we suppress it.
1029 check_and_add_compiler_option(-wd4548)
1031 # Perhaps testing something #defined to be 0 with #ifdef is an
1032 # error, and it should be tested with #if, but perhaps it's
1033 # not, and Microsoft does that in its headers, so we squelch
1036 check_and_add_compiler_option(-wd4574)
1038 # The Windows headers also test not-defined values in #if, so
1039 # we don't want warnings about that, either.
1041 check_and_add_compiler_option(-wd4668)
1043 # We do *not* care whether some function is, or isn't, going to be
1046 check_and_add_compiler_option(-wd4710)
1047 check_and_add_compiler_option(-wd4711)
1049 # We do *not* care whether we're adding padding bytes after
1050 # structure members.
1052 check_and_add_compiler_option(-wd4820)
1054 # We do *not* care about every single place the compiler would
1055 # have inserted Spectre mitigation if only we had told it to
1056 # do so with /Qspectre. I guess the theory is that it's seeing
1057 # bounds checks that would prevent out-of-bounds loads and that
1058 # those out-of-bounds loads could be done speculatively and that
1059 # the Spectre attack could detect the value of the out-of-bounds
1060 # data *if* it's within our address space, but unless I'm
1061 # missing something I don't see that as being any form of
1064 # XXX - add /Qspectre if that is really worth doing.
1066 check_and_add_compiler_option(-wd5045)
1068 # We do *not* care whether a structure had padding added at
1069 # the end because of __declspec(align) - *we* don't use
1070 # __declspec(align), because the only structures whose layout
1071 # we precisely specify are those that get overlaid on packet
1072 # data, and in those every element is an array of octets so
1073 # that we have full control over the size and alignment, and,
1074 # apparently, jmp_buf has such a declaration on x86, meaning
1075 # that everything that includes netdissect.h, i.e. almost every
1076 # file in tcpdump, gets a warning.
1078 check_and_add_compiler_option(-wd4324)
1081 # Other compilers, including MSVC with a Clang front end and
1082 # Microsoft's code generator. We currently treat them as if
1083 # they might support GCC-style -W options.
1085 check_and_add_compiler_option(-W)
1086 check_and_add_compiler_option(-Wall)
1087 check_and_add_compiler_option(-Wassign-enum)
1088 check_and_add_compiler_option(-Wcast-qual)
1089 check_and_add_compiler_option(-Wmissing-prototypes)
1090 check_and_add_compiler_option(-Wmissing-variable-declarations)
1091 check_and_add_compiler_option(-Wold-style-definition)
1092 if(NOT CMAKE_C_COMPILER_ID MATCHES "Sun")
1093 # In Sun C versions that implement GCC compatibility "-Wpedantic"
1094 # means the same as "-pedantic". The latter is mutually exclusive
1095 # with several other options. One of those is "-xc99", which has
1096 # already been set for Sun C above.
1097 check_and_add_compiler_option(-Wpedantic)
1099 check_and_add_compiler_option(-Wpointer-arith)
1100 check_and_add_compiler_option(-Wpointer-sign)
1101 check_and_add_compiler_option(-Wshadow)
1102 check_and_add_compiler_option(-Wsign-compare)
1103 check_and_add_compiler_option(-Wstrict-prototypes)
1104 check_and_add_compiler_option(-Wundef)
1105 check_and_add_compiler_option(-Wunreachable-code-return)
1106 check_and_add_compiler_option(-Wused-but-marked-unused)
1107 check_and_add_compiler_option(-Wwrite-strings)
1112 # Extra compiler options for the build matrix scripts to request -Werror or
1113 # its equivalent if required. The CMake variable name cannot be CFLAGS
1114 # because that is already used for a different purpose in CMake. Example
1115 # usage: cmake -DEXTRA_CFLAGS='-Wall -Wextra -Werror' ...
1117 if(NOT "${EXTRA_CFLAGS}" STREQUAL "")
1118 # The meaning of EXTRA_CFLAGS is "use the exact specified options, or the
1119 # build risks failing to fail", not "try every specified option, omit those
1120 # that do not work and use the rest". Thus use add_compile_options(), not
1121 # foreach()/check_and_add_compiler_option().
1122 string(REPLACE " " ";" _extra_cflags_list ${EXTRA_CFLAGS})
1123 add_compile_options(${_extra_cflags_list})
1124 message(STATUS "Added extra compile options (${EXTRA_CFLAGS})")
1127 ######################################
1129 ######################################
1133 # We allow the SMB dissector to be omitted.
1135 set(LOCALSRC ${LOCALSRC}
1140 set(NETDISSECT_SOURCE_LIST_C
1255 print-openflow-1.0.c
1256 print-openflow-1.3.c
1326 # Replace missing functions
1328 foreach(FUNC strlcat strlcpy strsep getservent getopt_long)
1329 string(TOUPPER ${FUNC} FUNC_UPPERCASE)
1330 set(HAVE_FUNC_UPPERCASE HAVE_${FUNC_UPPERCASE})
1331 if(NOT ${HAVE_FUNC_UPPERCASE})
1332 set(NETDISSECT_SOURCE_LIST_C ${NETDISSECT_SOURCE_LIST_C} missing/${FUNC}.c)
1336 add_library(netdissect STATIC
1337 ${NETDISSECT_SOURCE_LIST_C}
1339 if(NOT C_ADDITIONAL_FLAGS STREQUAL "")
1340 set_target_properties(netdissect PROPERTIES COMPILE_FLAGS ${C_ADDITIONAL_FLAGS})
1343 set(TCPDUMP_SOURCE_LIST_C fptype.c tcpdump.c)
1345 if(NOT HAVE_BPF_DUMP)
1346 set(TCPDUMP_SOURCE_LIST_C ${TCPDUMP_SOURCE_LIST_C} bpf_dump.c)
1347 endif(NOT HAVE_BPF_DUMP)
1349 set(PROJECT_SOURCE_LIST_C ${NETDISSECT_SOURCE_LIST_C} ${TCPDUMP_SOURCE_LIST_C})
1351 file(GLOB PROJECT_SOURCE_LIST_H
1356 # Assume, by default, no support for shared libraries and V7/BSD
1357 # convention for man pages (devices in section 4, file formats in
1358 # section 5, miscellaneous info in section 7, administrative commands
1359 # and daemons in section 8). Individual cases can override this.
1360 # Individual cases can override this.
1362 set(MAN_FILE_FORMATS 5)
1363 set(MAN_MISC_INFO 7)
1364 if(CMAKE_SYSTEM_NAME STREQUAL "HP-UX")
1366 # Use System V conventions for man pages.
1368 set(MAN_FILE_FORMATS 4)
1369 set(MAN_MISC_INFO 5)
1370 elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*")
1374 if(CMAKE_SYSTEM_VERSION STREQUAL "5.12")
1377 # Use System V conventions for man pages.
1379 set(MAN_FILE_FORMATS 4)
1380 set(MAN_MISC_INFO 5)
1384 source_group("Source Files" FILES ${PROJECT_SOURCE_LIST_C})
1385 source_group("Header Files" FILES ${PROJECT_SOURCE_LIST_H})
1387 ######################################
1389 ######################################
1391 add_executable(tcpdump ${TCPDUMP_SOURCE_LIST_C})
1392 if(NOT C_ADDITIONAL_FLAGS STREQUAL "")
1393 set_target_properties(tcpdump PROPERTIES COMPILE_FLAGS ${C_ADDITIONAL_FLAGS})
1395 target_link_libraries(tcpdump netdissect ${TCPDUMP_LINK_LIBRARIES})
1397 ######################################
1398 # Write out the config.h file
1399 ######################################
1401 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
1403 ######################################
1404 # Install tcpdump and man pages
1405 ######################################
1408 # "Define GNU standard installation directories", which actually
1409 # are also defined, to some degree, by autotools, and at least
1410 # some of which are general UN*X conventions.
1412 include(GNUInstallDirs)
1414 set(MAN1_EXPAND tcpdump.1.in)
1417 # XXX TODO where to install on Windows?
1419 install(TARGETS tcpdump DESTINATION bin)
1422 # On UN*X, and on Windows when not using MSVC, process man pages and
1423 # arrange that they be installed.
1428 # For each section of the manual for which we have man pages
1429 # that require macro expansion, do the expansion.
1432 foreach(TEMPLATE_MANPAGE ${MAN1_EXPAND})
1433 string(REPLACE ".in" "" MANPAGE ${TEMPLATE_MANPAGE})
1434 configure_file(${CMAKE_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY)
1435 set(MAN1 ${MAN1} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE})
1436 endforeach(TEMPLATE_MANPAGE)
1437 install(FILES ${MAN1} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
1442 "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
1443 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
1446 add_custom_target(uninstall
1447 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
1451 # We try to find the Perl interpreter and, if we do, we have the check
1452 # rule run tests/TESTrun with it, because just trying to run the TESTrun
1453 # script as a command won't work on Windows.
1455 find_program(PERL perl)
1457 message(STATUS "Found perl at ${PERL}")
1458 add_custom_target(check
1459 COMMAND ${PERL} ${CMAKE_SOURCE_DIR}/tests/TESTrun)
1461 message(STATUS "Didn't find perl")