3 # We need 3.12 or later, so that we can set policy CMP0074; see
5 cmake_minimum_required(VERSION 3.12)
8 # For now, require only 2.8.12, just in case somebody is
9 # configuring with CMake on a "long-term support" version
10 # of some OS and that version supplies an older version of
13 # If this is ever updated to CMake 3.1 or later, remove the
14 # stuff in cmake/Modules/FindPCAP.cmake that appends subdirectories
15 # of directories from CMAKE_PREFIX_PATH to the PKG_CONFIG_PATH
16 # environment variable when running pkg-config, to make sure
17 # it finds any .pc file from there.
19 cmake_minimum_required(VERSION 2.8.12)
23 # We want find_path() and find_library() to honor {packagename}_ROOT,
24 # as that appears to be the standard way to say "hey, look here for
25 # this package" from the command line.
28 cmake_policy(SET CMP0074 NEW)
34 # When building on NetBSD, with a libpcap installed from pkgsrc,
35 # a -Wl,-rpath,/usr/pkg/lib option is added to the options when
36 # linking tcpdump. This puts /usr/pkg/lib into the run-time path.
38 # However, by default, CMake adds a rule to the install CMake script
39 # a CMake command (using an undocumented subcommand of file()) that
40 # strips /usr/pkg/lib *out* of the run-time path; the message in the
41 # output for the "install" target is
43 # -- Set runtime path of "{target-directory}/tcpdump" to ""
45 # I am not certain what the rationale is for doing this, but a
46 # *consequence* of this is that, when you run the installed tcpdump,
47 # it fails to find libpcap.so:
49 # $ {target-directory}/tcpdump -h
50 # {target-directory}/tcpdump: Shared object "libpcap.so.0" not found
52 # It also appears to be the case that, on Ubuntu 22.04, FreeBSD 12,
53 # DragonFly BSD 5.8, OpenBSD 6.6, and Solaris 11.4,
55 # On Ubuntu and Solaris, even if you have a libpcap in /usr/local, you
56 # have to provide not only -I/usr/local/include and -L/usr/local/lib,
57 # you also must provide -Wl,-rpath,/usr/local/lib in order to have
58 # the run-time linker look in /usr/local/lib for libpcap. If it's not
59 # specified, then, if the shared library major version number of the
60 # libpcap in /usr/lib is the same as the shared major version number
61 # of the libpcap in /usr/local/lib, the run-time linker will find the
62 # libpcap in /usr/lib; if the versions are different, the run-time
63 # linker will fail to find the libpcap in /usr/lib, so the program will
66 # We suppress this by setting CMAKE_INSTALL_RPATH_USE_LINK_PATH to TRUE;
67 # as the documentation for that variable says:
69 # Add paths to linker search and installed rpath.
71 # CMAKE_INSTALL_RPATH_USE_LINK_PATH is a boolean that if set to True
72 # will append to the runtime search path (rpath) of installed
73 # binaries any directories outside the project that are in the linker
74 # search path or contain linked library files. The directories are
75 # appended after the value of the INSTALL_RPATH target property.
77 # If, for whatever reason, directories in which we search for external
78 # libraries, other than the standard system library directories, are
79 # added to the executable's rpath in the build process, we most
80 # defintely want them in the installed image's rpath if they are
81 # necessary in order to find the libraries at run time.
83 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
85 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
88 # OK, this is a royal pain.
90 # CMake will try to determine the sizes of some data types, including
91 # void *, early in the process of configuration; apparently, it's done
92 # as part of processing the project() command.
94 # At least as of CMake 2.8.6, it does so by checking the size of
95 # "void *" in C, setting CMAKE_C_SIZEOF_DATA_PTR based on that,
96 # setting CMAKE_SIZEOF_VOID_P to that, and then checking the size
97 # of "void *" in C++, setting CMAKE_CXX_SIZEOF_DATA_PTR based on
98 # that, and then setting CMAKE_SIZEOF_VOID_P to *that*.
100 # The compile tests include whatever C flags may have been provided
101 # to CMake in the CFLAGS and CXXFLAGS environment variables.
103 # If you set an architecture flag such as -m32 or -m64 in CFLAGS
104 # but *not* in CXXFLAGS, the size for C++ will win, and hilarity
107 # Or if, at least on Solaris, you have a newer version of GCC
108 # installed, but *not* a newer version of G++, and you have Oracle
109 # Studio installed, it will find GCC, which will default to building
110 # 64-bit, and Oracle Studio's C++ compiler, which will default to
111 # building 32-bit, the size for C++ will win, and, again, hilarity
114 # So we *explicitly* state that only C is used; there is currently no
115 # C++ code in tcpdump.
120 # For checking if a compiler flag works and adding it if it does.
122 include(CheckCCompilerFlag)
123 macro(check_and_add_compiler_option _option)
124 message(STATUS "Checking C compiler flag ${_option}")
125 string(REPLACE "=" "-" _temp_option_variable ${_option})
126 string(REGEX REPLACE "^-" "" _option_variable ${_temp_option_variable})
127 check_c_compiler_flag("${_option}" ${_option_variable})
128 if(${${_option_variable}})
129 set(C_ADDITIONAL_FLAGS "${C_ADDITIONAL_FLAGS} ${_option}")
134 # If we're building with Visual Studio, we require Visual Studio 2015,
135 # in order to get sufficient C99 compatibility. Check for that.
137 # If not, try the appropriate flag for the compiler to enable C99
140 set(C_ADDITIONAL_FLAGS "")
142 if(MSVC_VERSION LESS 1900)
143 message(FATAL_ERROR "Visual Studio 2015 or later is required")
147 # Treat source files as being in UTF-8 with MSVC if it's not using
148 # the Clang front end.
149 # We assume that UTF-8 source is OK with other compilers and with
150 # MSVC if it's using the Clang front end.
152 if(NOT ${CMAKE_C_COMPILER} MATCHES "clang*")
153 set(C_ADDITIONAL_FLAGS "${C_ADDITIONAL_FLAGS} /utf-8")
154 endif(NOT ${CMAKE_C_COMPILER} MATCHES "clang*")
157 # Try to enable as many C99 features as we can.
158 # At minimum, we want C++/C99-style // comments.
160 # Newer versions of compilers might default to supporting C99, but
161 # older versions may require a special flag.
163 # Prior to CMake 3.1, setting CMAKE_C_STANDARD will not have any effect,
164 # so, unless and until we require CMake 3.1 or later, we have to do it
165 # ourselves on pre-3.1 CMake, so we just do it ourselves on all versions
168 # Note: with CMake 3.1 through 3.5, the only compilers for which CMake
169 # handles CMAKE_C_STANDARD are GCC and Clang. 3.6 adds support only
170 # for Intel C; 3.9 adds support for PGI C, Sun C, and IBM XL C, and
171 # 3.10 adds support for Cray C and IAR C, but no version of CMake has
172 # support for HP C. Therefore, even if we use CMAKE_C_STANDARD with
173 # compilers for which CMake supports it, we may still have to do it
174 # ourselves on other compilers.
176 # See the CMake documentation for the CMAKE_<LANG>_COMPILER_ID variables
177 # for a list of compiler IDs.
179 # XXX - this just tests whether the option works and adds it if it does.
180 # We don't test whether it's necessary in order to get the C99 features
181 # that we use; if we ever have a user who tries to compile with a compiler
182 # that can't be made to support those features, we can add a test to make
183 # sure we actually *have* C99 support.
185 if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR
186 CMAKE_C_COMPILER_ID MATCHES "Clang")
187 check_and_add_compiler_option("-std=gnu99")
188 elseif(CMAKE_C_COMPILER_ID MATCHES "XL")
190 # We want support for extensions picked up for GNU C compatibility,
191 # so we use -qlanglvl=extc99.
193 check_and_add_compiler_option("-qlanglvl=extc99")
194 elseif(CMAKE_C_COMPILER_ID MATCHES "HP")
195 check_and_add_compiler_option("-AC99")
196 elseif(CMAKE_C_COMPILER_ID MATCHES "Sun")
197 check_and_add_compiler_option("-xc99")
198 elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
199 check_and_add_compiler_option("-c99")
203 set(LIBRARY_NAME netdissect)
205 ###################################################################
207 ###################################################################
209 option(WITH_SMI "Build with libsmi, if available" ON)
210 option(WITH_CRYPTO "Build with OpenSSL/libressl libcrypto, if available" ON)
211 option(WITH_CAPSICUM "Build with Capsicum security functions, if available" ON)
212 option(WITH_CAP_NG "Use libcap-ng, if available" ON)
213 option(ENABLE_SMB "Build with the SMB dissector" OFF)
216 # String parameters. Neither of them are set, initially; only if the
217 # user explicitly configures them are they set.
219 # WITH_CHROOT is STRING, not PATH, as the directory need not exist
222 set(WITH_CHROOT CACHE STRING
223 "Directory to which to chroot when dropping privileges")
224 set(WITH_USER CACHE STRING
225 "User to whom to set the UID when dropping privileges")
228 # By default, build universal with the appropriate set of architectures
229 # for the OS on which we're doing the build.
231 if(APPLE AND "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
233 # Get the major version of Darwin.
235 string(REGEX MATCH "^([0-9]+)" SYSTEM_VERSION_MAJOR "${CMAKE_SYSTEM_VERSION}")
237 if(SYSTEM_VERSION_MAJOR EQUAL 9)
239 # Leopard. Build for x86 and 32-bit PowerPC, with
240 # x86 first. (That's what Apple does.)
242 set(CMAKE_OSX_ARCHITECTURES "i386;ppc")
243 elseif(SYSTEM_VERSION_MAJOR EQUAL 10)
245 # Snow Leopard. Build for x86-64 and x86, with
246 # x86-64 first. (That's what Apple does.)
248 set(CMAKE_OSX_ARCHITECTURES "x86_64;i386")
252 ###################################################################
254 ###################################################################
256 # Get, parse, format and set tcpdump's version string from
257 # [tcpdump_root]/VERSION for later use.
259 # Get MAJOR, MINOR, PATCH & SUFFIX
260 file(STRINGS ${tcpdump_SOURCE_DIR}/VERSION
262 LIMIT_COUNT 1 # Read only the first line
265 ######################################
267 ######################################
269 add_definitions(-DHAVE_CONFIG_H)
272 ${CMAKE_CURRENT_BINARY_DIR}
273 ${tcpdump_SOURCE_DIR}
277 add_definitions(-D__STDC__)
278 add_definitions(-D_CRT_SECURE_NO_WARNINGS)
283 MESSAGE(STATUS "Use STATIC runtime")
285 set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MT")
286 set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT")
287 set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
288 set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
290 set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT")
291 set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT")
292 set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
293 set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
295 MESSAGE(STATUS "Use DYNAMIC runtime")
297 set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MD")
298 set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MD")
299 set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
300 set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
302 set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MD")
303 set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MD")
304 set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MD")
305 set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MDd")
306 endif (USE_STATIC_RT)
309 ###################################################################
310 # Detect available platform features
311 ###################################################################
313 include(CMakePushCheckState)
314 include(CheckIncludeFile)
315 include(CheckIncludeFiles)
316 include(CheckFunctionExists)
317 include(CheckLibraryExists)
318 include(CheckSymbolExists)
319 include(CheckStructHasMember)
320 include(CheckVariableExists)
321 include(CheckTypeSize)
326 check_include_file(fcntl.h HAVE_FCNTL_H)
327 check_include_file(rpc/rpc.h HAVE_RPC_RPC_H)
328 check_include_file(net/if.h HAVE_NET_IF_H)
330 check_include_files("rpc/rpc.h;rpc/rpcent.h" HAVE_RPC_RPCENT_H)
331 endif(HAVE_RPC_RPC_H)
336 check_function_exists(strlcat HAVE_STRLCAT)
337 check_function_exists(strlcpy HAVE_STRLCPY)
338 check_function_exists(strdup HAVE_STRDUP)
339 check_function_exists(strsep HAVE_STRSEP)
342 # Find library needed for gethostbyaddr.
343 # NOTE: if you hand check_library_exists as its last argument a variable
344 # that's been set, it skips the test, so we need different variables.
346 set(TCPDUMP_LINK_LIBRARIES "")
349 # We need winsock2.h and ws2tcpip.h.
351 cmake_push_check_state()
352 set(CMAKE_REQUIRED_LIBRARIES ws2_32)
353 check_symbol_exists(gethostbyaddr "winsock2.h;ws2tcpip.h" LIBWS2_32_HAS_GETHOSTBYADDR)
354 cmake_pop_check_state()
355 if(LIBWS2_32_HAS_GETHOSTBYADDR)
356 set(TCPDUMP_LINK_LIBRARIES ws2_32 ${TCPDUMP_LINK_LIBRARIES})
357 else(LIBWS2_32_HAS_GETHOSTBYADDR)
358 message(FATAL_ERROR "gethostbyaddr is required, but wasn't found")
359 endif(LIBWS2_32_HAS_GETHOSTBYADDR)
361 check_function_exists(gethostbyaddr STDLIBS_HAVE_GETHOSTBYADDR)
362 if(NOT STDLIBS_HAVE_GETHOSTBYADDR)
363 check_library_exists(socket gethostbyaddr "" LIBSOCKET_HAS_GETHOSTBYADDR)
364 if(LIBSOCKET_HAS_GETHOSTBYADDR)
365 set(TCPDUMP_LINK_LIBRARIES ${TCPDUMP_LINK_LIBRARIES} socket)
366 else(LIBSOCKET_HAS_GETHOSTBYADDR)
367 check_library_exists(nsl gethostbyaddr "" LIBNSL_HAS_GETHOSTBYADDR)
368 if(LIBNSL_HAS_GETHOSTBYADDR)
369 set(TCPDUMP_LINK_LIBRARIES ${TCPDUMP_LINK_LIBRARIES} nsl)
370 else(LIBNSL_HAS_GETHOSTBYADDR)
371 check_library_exists(network gethostbyaddr "" LIBNETWORK_HAS_GETHOSTBYADDR)
372 if(LIBNETWORK_HAS_GETHOSTBYADDR)
373 set(TCPDUMP_LINK_LIBRARIES ${TCPDUMP_LINK_LIBRARIES} network)
374 else(LIBNETWORK_HAS_GETHOSTBYADDR)
375 message(FATAL_ERROR "gethostbyaddr is required, but wasn't found")
376 endif(LIBNETWORK_HAS_GETHOSTBYADDR)
377 endif(LIBNSL_HAS_GETHOSTBYADDR)
378 endif(LIBSOCKET_HAS_GETHOSTBYADDR)
379 endif(NOT STDLIBS_HAVE_GETHOSTBYADDR)
383 # This may require additional libraries.
385 cmake_push_check_state()
386 set(CMAKE_REQUIRED_LIBRARIES ${TCPDUMP_LINK_LIBRARIES})
387 check_function_exists(getservent STDLIBS_HAVE_GETSERVENT)
388 if(STDLIBS_HAVE_GETSERVENT)
389 set(HAVE_GETSERVENT TRUE)
390 else(STDLIBS_HAVE_GETSERVENT)
392 # Some platforms may need -lsocket for getservent.
394 set(CMAKE_REQUIRED_LIBRARIES socket ${TCPDUMP_LINK_LIBRARIES})
395 check_function_exists(getservent LIBSOCKET_HAS_GETSERVENT)
396 if(LIBSOCKET_HAS_GETSERVENT)
397 set(HAVE_GETSERVENT TRUE)
398 set(TCPDUMP_LINK_LIBRARIES socket ${TCPDUMP_LINK_LIBRARIES})
399 endif(LIBSOCKET_HAS_GETSERVENT)
400 endif(STDLIBS_HAVE_GETSERVENT)
401 cmake_pop_check_state()
404 # Make sure we have vsnprintf() and snprintf(); we require them.
405 # We use check_symbol_exists(), as they aren't necessarily external
406 # functions - in Visual Studio, for example, they're inline functions
407 # calling a common external function.
409 check_symbol_exists(vsnprintf "stdio.h" HAVE_VSNPRINTF)
410 if(NOT HAVE_VSNPRINTF)
411 message(FATAL_ERROR "vsnprintf() is required but wasn't found")
412 endif(NOT HAVE_VSNPRINTF)
413 check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF)
414 if(NOT HAVE_SNPRINTF)
415 message(FATAL_ERROR "snprintf() is required but wasn't found")
418 check_function_exists(getopt_long HAVE_GETOPT_LONG)
419 check_function_exists(setlinebuf HAVE_SETLINEBUF)
421 # For Windows, don't need to waste time checking for fork() or vfork().
424 check_function_exists(fork HAVE_FORK)
425 check_function_exists(vfork HAVE_VFORK)
429 # Some platforms may need -lnsl for getrpcbynumber.
431 cmake_push_check_state()
432 set(CMAKE_REQUIRED_LIBRARIES ${TCPDUMP_LINK_LIBRARIES})
433 check_function_exists(getrpcbynumber STDLIBS_HAVE_GETRPCBYNUMBER)
434 if(STDLIBS_HAVE_GETRPCBYNUMBER)
435 set(HAVE_GETRPCBYNUMBER TRUE)
436 else(STDLIBS_HAVE_GETRPCBYNUMBER)
437 set(CMAKE_REQUIRED_LIBRARIES ${TCPDUMP_LINK_LIBRARIES} nsl)
438 check_function_exists(getrpcbynumber LIBNSL_HAS_GETRPCBYNUMBER)
439 if(LIBNSL_HAS_GETRPCBYNUMBER)
440 set(HAVE_GETRPCBYNUMBER TRUE)
441 set(TCPDUMP_LINK_LIBRARIES ${TCPDUMP_LINK_LIBRARIES} nsl)
442 endif(LIBNSL_HAS_GETRPCBYNUMBER)
443 endif(STDLIBS_HAVE_GETRPCBYNUMBER)
444 cmake_pop_check_state()
447 # This requires the libraries we require, as ether_ntohost might be
448 # in one of those libraries. That means we have to do this after
449 # we check for those libraries.
451 # You are in a twisty little maze of UN*Xes, all different.
452 # Some might not have ether_ntohost().
453 # Some might have it and declare it in <net/ethernet.h>.
454 # Some might have it and declare it in <netinet/ether.h>
455 # Some might have it and declare it in <sys/ethernet.h>.
456 # Some might have it and declare it in <arpa/inet.h>.
457 # Some might have it and declare it in <netinet/if_ether.h>.
458 # Some might have it and not declare it in any header file.
460 # Before you is a C compiler.
462 cmake_push_check_state()
463 set(CMAKE_REQUIRED_LIBRARIES ${TCPDUMP_LINK_LIBRARIES})
464 check_function_exists(ether_ntohost HAVE_ETHER_NTOHOST)
465 if(HAVE_ETHER_NTOHOST)
467 # OK, we have ether_ntohost(). We don't check whether it's buggy,
468 # as we assume any system that has CMake is likely to be new enough
469 # that, if it has ether_ntohost(), whatever bug is checked for in
470 # autotools is fixed; we just decide to use it.
472 set(USE_ETHER_NTOHOST TRUE)
475 # Is it declared in <net/ethernet.h>?
477 # This test fails if we don't have <net/ethernet.h> or if we do
478 # but it doesn't declare ether_ntohost().
480 check_symbol_exists(ether_ntohost net/ethernet.h NET_ETHERNET_H_DECLARES_ETHER_NTOHOST)
481 if(NET_ETHERNET_H_DECLARES_ETHER_NTOHOST)
483 # Yes - we have it declared.
485 set(HAVE_DECL_ETHER_NTOHOST TRUE)
490 if(NOT HAVE_DECL_ETHER_NTOHOST)
492 # No - how about <netinet/ether.h>, as on Linux?
494 # This test fails if we don't have <netinet/ether.h>
495 # or if we do but it doesn't declare ether_ntohost().
497 check_symbol_exists(ether_ntohost netinet/ether.h NETINET_ETHER_H_DECLARES_ETHER_NTOHOST)
498 if(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST)
500 # Yes - we have it declared.
502 set(HAVE_DECL_ETHER_NTOHOST TRUE)
508 if(NOT HAVE_DECL_ETHER_NTOHOST)
510 # No - how about <sys/ethernet.h>, as on Solaris 10 and later?
512 # This test fails if we don't have <sys/ethernet.h>
513 # or if we do but it doesn't declare ether_ntohost().
515 check_symbol_exists(ether_ntohost sys/ethernet.h SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST)
516 if(SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST)
518 # Yes - we have it declared.
520 set(HAVE_DECL_ETHER_NTOHOST TRUE)
526 if(NOT HAVE_DECL_ETHER_NTOHOST)
528 # No, how about <arpa/inet.h>, as on AIX?
530 # This test fails if we don't have <arpa/inet.h>
531 # or if we do but it doesn't declare ether_ntohost().
533 check_symbol_exists(ether_ntohost arpa/inet.h ARPA_INET_H_DECLARES_ETHER_NTOHOST)
534 if(ARPA_INET_H_DECLARES_ETHER_NTOHOST)
536 # Yes - we have it declared.
538 set(HAVE_DECL_ETHER_NTOHOST TRUE)
544 if(NOT HAVE_DECL_ETHER_NTOHOST)
546 # No, how about <netinet/if_ether.h>?
547 # On some platforms, it requires <net/if.h> and
548 # <netinet/in.h>, and we always include it with
549 # both of them, so test it with both of them.
551 # This test fails if we don't have <netinet/if_ether.h>
552 # and the headers we include before it, or if we do but
553 # <netinet/if_ether.h> doesn't declare ether_ntohost().
555 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)
556 if(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST)
558 # Yes - we have it declared.
560 set(HAVE_DECL_ETHER_NTOHOST TRUE)
564 # After all that, is ether_ntohost() declared?
566 if(NOT HAVE_DECL_ETHER_NTOHOST)
568 # No, we'll have to declare it ourselves.
569 # Do we have "struct ether_addr" if we include<netinet/if_ether.h>?
571 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)
574 cmake_pop_check_state()
579 # XXX - there's no check_struct() macro that's like check_struct_has_member()
580 # except that it only checks for the existence of the structure type,
581 # so we use check_struct_has_member() and look for ss_family.
585 # Check for IPv6 support.
586 # We just check for AF_INET6 and struct in6_addr.
588 cmake_push_check_state()
590 set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h ws2tcpip.h)
591 check_symbol_exists(AF_INET6 "sys/types.h;ws2tcpip.h" HAVE_AF_INET6)
593 set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h sys/socket.h netinet/in.h)
594 check_symbol_exists(AF_INET6 "sys/types.h;sys/socket.h;netinet/in.h" HAVE_AF_INET6)
596 check_type_size("struct in6_addr" HAVE_STRUCT_IN6_ADDR)
597 cmake_pop_check_state()
598 if(HAVE_AF_INET6 AND HAVE_STRUCT_IN6_ADDR)
599 set(HAVE_OS_IPV6_SUPPORT TRUE)
600 endif(HAVE_AF_INET6 AND HAVE_STRUCT_IN6_ADDR)
602 ######################################
603 # External dependencies
604 ######################################
607 # libpcap/WinPcap/Npcap.
610 find_package(PCAP REQUIRED)
611 include_directories(${PCAP_INCLUDE_DIRS})
613 cmake_push_check_state()
618 set(CMAKE_REQUIRED_INCLUDES ${PCAP_INCLUDE_DIRS})
621 # Check whether we have pcap/pcap-inttypes.h.
622 # If we do, we use that to get the C99 types defined.
624 check_include_file(pcap/pcap-inttypes.h HAVE_PCAP_PCAP_INTTYPES_H)
627 # Check for various functions in libpcap/WinPcap/Npcap.
629 cmake_push_check_state()
630 set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARIES})
633 # Check for "pcap_list_datalinks()" and use a substitute version if
634 # it's not present. If it is present, check for "pcap_free_datalinks()";
635 # if it's not present, we don't replace it for now. (We could do so
636 # on UN*X, but not on Windows, where hilarity ensues if a program
637 # built with one version of the MSVC support library tries to free
638 # something allocated by a library built with another version of
639 # the MSVC support library.)
641 check_function_exists(pcap_list_datalinks HAVE_PCAP_LIST_DATALINKS)
642 if(HAVE_PCAP_LIST_DATALINKS)
643 check_function_exists(pcap_free_datalinks HAVE_PCAP_FREE_DATALINKS)
644 endif(HAVE_PCAP_LIST_DATALINKS)
647 # Check for "pcap_datalink_name_to_val()", and use a substitute
648 # version if it's not present. If it is present, check for
649 # "pcap_datalink_val_to_description()", and if we don't have it,
650 # use a substitute version.
652 check_function_exists(pcap_datalink_name_to_val HAVE_PCAP_DATALINK_NAME_TO_VAL)
653 if(HAVE_PCAP_DATALINK_NAME_TO_VAL)
654 check_function_exists(pcap_datalink_val_to_description HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION)
655 endif(HAVE_PCAP_DATALINK_NAME_TO_VAL)
658 # Check for "pcap_set_datalink()"; you can't substitute for it if
659 # it's absent (it has hooks into libpcap), so just define the
660 # HAVE_ value if it's there.
662 check_function_exists(pcap_set_datalink HAVE_PCAP_SET_DATALINK)
665 # Check for "pcap_breakloop()"; you can't substitute for it if
666 # it's absent (it has hooks into the live capture routines),
667 # so just define the HAVE_ value if it's there.
669 check_function_exists(pcap_breakloop HAVE_PCAP_BREAKLOOP)
672 # Check for "pcap_dump_ftell()"; we use a substitute version
673 # if it's not present.
675 check_function_exists(pcap_dump_ftell HAVE_PCAP_DUMP_FTELL)
678 # Do we have the new open API? Check for pcap_create() and for
679 # pcap_statustostr(), and assume that, if we have both of them,
680 # we also have pcap_activate() and the other new routines
681 # introduced in libpcap 1.0.0. (We check for pcap_statustostr()
682 # as well, because WinPcap 4.1.3 screwed up and exported pcap_create()
683 # but not other routines such as pcap_statustostr(), even though it
684 # defined them and even though you really want pcap_statustostr() to
685 # get strings corresponding to some of the status returns from the
688 check_function_exists(pcap_statustostr HAVE_PCAP_STATUSTOSTR)
690 # If we don't have pcap_statustostr(), don't check for pcap_create(),
691 # so we pretend we don't have it.
693 if(HAVE_PCAP_STATUSTOSTR)
694 check_function_exists(pcap_create HAVE_PCAP_CREATE)
695 endif(HAVE_PCAP_STATUSTOSTR)
698 # OK, do we have pcap_set_tstamp_type? If so, assume we have
699 # pcap_list_tstamp_types and pcap_free_tstamp_types as well.
701 check_function_exists(pcap_set_tstamp_type HAVE_PCAP_SET_TSTAMP_TYPE)
704 # And do we have pcap_set_tstamp_precision? If so, we assume
705 # we also have pcap_open_offline_with_tstamp_precision.
707 check_function_exists(pcap_set_tstamp_precision HAVE_PCAP_SET_TSTAMP_PRECISION)
708 endif(HAVE_PCAP_CREATE)
711 # Check for a miscellaneous collection of functions which we use
714 check_function_exists(pcap_findalldevs HAVE_PCAP_FINDALLDEVS)
715 if(HAVE_PCAP_FINDALLDEVS)
717 # Check for libpcap having pcap_findalldevs() but the pcap.h header
718 # not having pcap_if_t; some versions of Mac OS X shipped with pcap.h
719 # from 0.6 and libpcap 0.8, so that libpcap had pcap_findalldevs but
720 # pcap.h didn't have pcap_if_t.
722 cmake_push_check_state()
723 set(CMAKE_REQUIRED_INCLUDES ${PCAP_INCLUDE_DIRS})
724 set(CMAKE_EXTRA_INCLUDE_FILES pcap.h)
725 check_type_size(pcap_if_t PCAP_IF_T)
726 cmake_pop_check_state()
727 endif(HAVE_PCAP_FINDALLDEVS)
728 check_function_exists(pcap_dump_flush HAVE_PCAP_DUMP_FLUSH)
729 check_function_exists(pcap_lib_version HAVE_PCAP_LIB_VERSION)
730 if(NOT HAVE_PCAP_LIB_VERSION)
731 # Check for the pcap_version string variable and set HAVE_PCAP_VERSION
732 endif(NOT HAVE_PCAP_LIB_VERSION)
733 check_function_exists(pcap_setdirection HAVE_PCAP_SETDIRECTION)
734 check_function_exists(pcap_set_immediate_mode HAVE_PCAP_SET_IMMEDIATE_MODE)
735 check_function_exists(pcap_dump_ftell64 HAVE_PCAP_DUMP_FTELL64)
736 check_function_exists(pcap_open HAVE_PCAP_OPEN)
737 check_function_exists(pcap_findalldevs_ex HAVE_PCAP_FINDALLDEVS_EX)
740 # On Windows, check for pcap_wsockinit(); if we don't have it, check for
744 check_function_exists(pcap_wsockinit HAVE_PCAP_WSOCKINIT)
745 if(NOT HAVE_PCAP_WSOCKINIT)
746 check_function_exists(wsockinit HAVE_WSOCKINIT)
747 endif(NOT HAVE_PCAP_WSOCKINIT)
751 # Check for special debugging functions
753 check_function_exists(pcap_set_parser_debug HAVE_PCAP_SET_PARSER_DEBUG)
754 if(NOT HAVE_PCAP_SET_PARSER_DEBUG)
755 # Check whether libpcap defines pcap_debug or yydebug
756 check_variable_exists(pcap_debug HAVE_PCAP_DEBUG)
757 if(NOT HAVE_PCAP_DEBUG)
758 check_variable_exists(yydebug HAVE_YYDEBUG)
759 endif(NOT HAVE_PCAP_DEBUG)
760 endif(NOT HAVE_PCAP_SET_PARSER_DEBUG)
762 check_function_exists(pcap_set_optimizer_debug HAVE_PCAP_SET_OPTIMIZER_DEBUG)
763 check_function_exists(bpf_dump HAVE_BPF_DUMP)
765 cmake_pop_check_state()
770 include_directories(SYSTEM ${PCAP_INCLUDE_DIRS})
771 set(TCPDUMP_LINK_LIBRARIES ${PCAP_LIBRARIES} ${TCPDUMP_LINK_LIBRARIES})
774 # Optional libraries.
783 include_directories(SYSTEM ${SMI_INCLUDE_DIRS})
784 set(TCPDUMP_LINK_LIBRARIES ${TCPDUMP_LINK_LIBRARIES} ${SMI_LIBRARIES})
790 # OpenSSL/libressl libcrypto.
796 # Check for some headers and functions.
798 check_include_file(openssl/evp.h HAVE_OPENSSL_EVP_H)
801 # 1) do we have EVP_CIPHER_CTX_new?
802 # If so, we use it to allocate an EVP_CIPHER_CTX, as
803 # EVP_CIPHER_CTX may be opaque; otherwise, we allocate
806 cmake_push_check_state()
807 set(CMAKE_REQUIRED_LIBRARIES "${CRYPTO_LIBRARIES}")
809 check_function_exists(EVP_CIPHER_CTX_new HAVE_EVP_CIPHER_CTX_NEW)
812 # 2) do we have EVP_DecryptInit_ex()?
813 # If so, we use it, because we need to be able to make two
814 # "initialize the cipher" calls, one with the cipher and key,
815 # and one with the IV, and, as of OpenSSL 1.1, You Can't Do That
816 # with EVP_DecryptInit(), because a call to EVP_DecryptInit() will
817 # unconditionally clear the context, and if you don't supply a
818 # cipher, it'll clear the cipher, rendering the context unusable
819 # and causing a crash.
821 check_function_exists(EVP_DecryptInit_ex HAVE_EVP_DECRYPTINIT_EX)
823 cmake_pop_check_state()
828 include_directories(SYSTEM ${CRYPTO_INCLUDE_DIRS})
829 set(TCPDUMP_LINK_LIBRARIES ${TCPDUMP_LINK_LIBRARIES} ${CRYPTO_LIBRARIES})
830 set(HAVE_LIBCRYPTO ON)
835 # Capsicum sandboxing.
836 # Some of this is in the system library, some of it is in other libraries.
839 check_include_files("sys/capsicum.h" HAVE_SYS_CAPSICUM_H)
840 if(HAVE_SYS_CAPSICUM_H)
841 check_function_exists(cap_enter HAVE_CAP_ENTER)
842 check_function_exists(cap_rights_limit HAVE_CAP_RIGHTS_LIMIT)
843 check_function_exists(cap_ioctls_limit HAVE_CAP_IOCTLS_LIMIT)
844 check_function_exists(openat HAVE_OPENAT)
845 if(HAVE_CAP_ENTER AND HAVE_CAP_RIGHTS_LIMIT AND
846 HAVE_CAP_IOCTLS_LIMIT AND HAVE_OPENAT)
848 # OK, we have the functions we need to support Capsicum.
850 set(HAVE_CAPSICUM TRUE)
853 # OK, can we use Casper?
855 check_library_exists(casper cap_init "" HAVE_CAP_INIT)
857 cmake_push_check_state()
858 set(CMAKE_REQUIRED_LIBRARIES casper)
859 check_library_exists(cap_dns cap_gethostbyaddr "" HAVE_CAP_GETHOSTBYADDR)
860 cmake_pop_check_state()
861 if(HAVE_CAP_GETHOSTBYADDR)
862 set(HAVE_CASPER TRUE)
863 set(TCPDUMP_LINK_LIBRARIES ${TCPDUMP_LINK_LIBRARIES} casper cap_dns)
864 endif(HAVE_CAP_GETHOSTBYADDR)
866 endif(HAVE_CAP_ENTER AND HAVE_CAP_RIGHTS_LIMIT AND
867 HAVE_CAP_IOCTLS_LIMIT AND HAVE_OPENAT)
868 endif(HAVE_SYS_CAPSICUM_H)
875 check_include_file(cap-ng.h HAVE_CAP_NG_H)
876 check_library_exists(cap-ng capng_change_id "" HAVE_LIBCAP_NG)
878 set(TCPDUMP_LINK_LIBRARIES ${TCPDUMP_LINK_LIBRARIES} cap-ng)
879 endif(HAVE_LIBCAP_NG)
882 ###################################################################
884 ###################################################################
887 # Check and add warning options if we have a .devel file.
889 if(EXISTS ${CMAKE_SOURCE_DIR}/.devel OR EXISTS ${CMAKE_BINARY_DIR}/.devel)
893 if(MSVC AND NOT ${CMAKE_C_COMPILER} MATCHES "clang*")
895 # MSVC, with Microsoft's front end and code generator.
896 # "MSVC" is also set for Microsoft's compiler with a Clang
897 # front end and their code generator ("Clang/C2"), so we
898 # check for clang.exe and treat that differently.
900 check_and_add_compiler_option(-Wall)
902 # Disable some pointless warnings that /Wall turns on.
904 # Unfortunately, MSVC does not appear to have an equivalent
905 # to "__attribute__((unused))" to mark a particular function
906 # parameter as being known to be unused, so that the compiler
907 # won't warn about it (for example, the function might have
908 # that parameter because a pointer to it is being used, and
909 # the signature of that function includes that parameter).
910 # C++ lets you give a parameter a type but no name, but C
913 check_and_add_compiler_option(-wd4100)
915 # In theory, we care whether somebody uses f() rather than
916 # f(void) to declare a function with no arguments, but, in
917 # practice, there are places in the Windows header files
918 # that appear to do that, so we squelch that warning.
920 check_and_add_compiler_option(-wd4255)
922 # Windows FD_SET() generates this, so we suppress it.
924 check_and_add_compiler_option(-wd4548)
926 # Perhaps testing something #defined to be 0 with #ifdef is an
927 # error, and it should be tested with #if, but perhaps it's
928 # not, and Microsoft does that in its headers, so we squelch
931 check_and_add_compiler_option(-wd4574)
933 # The Windows headers also test not-defined values in #if, so
934 # we don't want warnings about that, either.
936 check_and_add_compiler_option(-wd4668)
938 # We do *not* care whether some function is, or isn't, going to be
941 check_and_add_compiler_option(-wd4710)
942 check_and_add_compiler_option(-wd4711)
944 # We do *not* care whether we're adding padding bytes after
947 check_and_add_compiler_option(-wd4820)
949 # We do *not* care about every single place the compiler would
950 # have inserted Spectre mitigation if only we had told it to
951 # do so with /Qspectre. I guess the theory is that it's seeing
952 # bounds checks that would prevent out-of-bounds loads and that
953 # those out-of-bounds loads could be done speculatively and that
954 # the Spectre attack could detect the value of the out-of-bounds
955 # data *if* it's within our address space, but unless I'm
956 # missing something I don't see that as being any form of
959 # XXX - add /Qspectre if that is really worth doing.
961 check_and_add_compiler_option(-wd5045)
963 # We do *not* care whether a structure had padding added at
964 # the end because of __declspec(align) - *we* don't use
965 # __declspec(align), because the only structures whose layout
966 # we precisely specify are those that get overlayed on packet
967 # data, and in those every element is an array of octets so
968 # that we have full control over the size and aligmnet, and,
969 # apparently, jmp_buf has such a declaration on x86, meaning
970 # that everything that includes netdissect.h, i.e. almost every
971 # file in tcpdump, gets a warning.
973 check_and_add_compiler_option(-wd4324)
976 # Other compilers, including MSVC with a Clang front end and
977 # Microsoft's code generator. We currently treat them as if
978 # they might support GCC-style -W options.
980 check_and_add_compiler_option(-W)
981 check_and_add_compiler_option(-Wall)
982 check_and_add_compiler_option(-Wassign-enum)
983 check_and_add_compiler_option(-Wcast-qual)
984 check_and_add_compiler_option(-Wmissing-prototypes)
985 check_and_add_compiler_option(-Wmissing-variable-declarations)
986 check_and_add_compiler_option(-Wold-style-definition)
987 check_and_add_compiler_option(-Wpedantic)
988 check_and_add_compiler_option(-Wpointer-arith)
989 check_and_add_compiler_option(-Wpointer-sign)
990 check_and_add_compiler_option(-Wshadow)
991 check_and_add_compiler_option(-Wsign-compare)
992 check_and_add_compiler_option(-Wstrict-prototypes)
993 check_and_add_compiler_option(-Wunreachable-code-return)
994 check_and_add_compiler_option(-Wused-but-marked-unused)
995 check_and_add_compiler_option(-Wwrite-strings)
1000 # Extra compiler options for the build matrix scripts to request -Werror or
1001 # its equivalent if required. The CMake variable name cannot be CFLAGS
1002 # because that is already used for a different purpose in CMake. Example
1003 # usage: cmake -DEXTRA_CFLAGS='-Wall -Wextra -Werror' ...
1005 if(NOT "${EXTRA_CFLAGS}" STREQUAL "")
1006 foreach(_extra_cflag ${EXTRA_CFLAGS})
1007 check_and_add_compiler_option("${_extra_cflag}")
1008 endforeach(_extra_cflag)
1009 message(STATUS "Added extra compile options (${EXTRA_CFLAGS})")
1012 ######################################
1014 ######################################
1018 # We allow the SMB dissector to be omitted.
1020 set(LOCALSRC ${LOCALSRC}
1025 set(NETDISSECT_SOURCE_LIST_C
1139 print-openflow-1.0.c
1140 print-openflow-1.3.c
1210 # Replace missing functions
1212 foreach(FUNC strlcat strlcpy strdup strsep getservent getopt_long)
1213 string(TOUPPER ${FUNC} FUNC_UPPERCASE)
1214 set(HAVE_FUNC_UPPERCASE HAVE_${FUNC_UPPERCASE})
1215 if(NOT ${HAVE_FUNC_UPPERCASE})
1216 set(NETDISSECT_SOURCE_LIST_C ${NETDISSECT_SOURCE_LIST_C} missing/${FUNC}.c)
1220 add_library(netdissect STATIC
1221 ${NETDISSECT_SOURCE_LIST_C}
1223 if(NOT C_ADDITIONAL_FLAGS STREQUAL "")
1224 set_target_properties(netdissect PROPERTIES COMPILE_FLAGS ${C_ADDITIONAL_FLAGS})
1227 set(TCPDUMP_SOURCE_LIST_C fptype.c tcpdump.c)
1229 if(NOT HAVE_BPF_DUMP)
1230 set(TCPDUMP_SOURCE_LIST_C ${TCPDUMP_SOURCE_LIST_C} bpf_dump.c)
1231 endif(NOT HAVE_BPF_DUMP)
1232 if(NOT HAVE_PCAP_DUMP_FTELL)
1233 set(TCPDUMP_SOURCE_LIST_C ${TCPDUMP_SOURCE_LIST_C} missing/pcap_dump_ftell.c)
1234 endif(NOT HAVE_PCAP_DUMP_FTELL)
1236 if(NOT HAVE_PCAP_LIST_DATALINKS)
1237 set(TCPDUMP_SOURCE_LIST_C ${TCPDUMP_SOURCE_LIST_C} missing/datalinks.c)
1238 endif(NOT HAVE_PCAP_LIST_DATALINKS)
1240 if((NOT HAVE_PCAP_DATALINK_NAME_TO_VAL) OR (NOT HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION))
1241 set(TCPDUMP_SOURCE_LIST_C ${TCPDUMP_SOURCE_LIST_C} missing/dlnames.c)
1242 endif((NOT HAVE_PCAP_DATALINK_NAME_TO_VAL) OR (NOT HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION))
1244 set(PROJECT_SOURCE_LIST_C ${NETDISSECT_SOURCE_LIST_C} ${TCPDUMP_SOURCE_LIST_C})
1246 file(GLOB PROJECT_SOURCE_LIST_H
1251 # Assume, by default, no support for shared libraries and V7/BSD
1252 # convention for man pages (devices in section 4, file formats in
1253 # section 5, miscellaneous info in section 7, administrative commands
1254 # and daemons in section 8). Individual cases can override this.
1255 # Individual cases can override this.
1257 set(MAN_FILE_FORMATS 5)
1258 set(MAN_MISC_INFO 7)
1259 if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
1260 # Workaround to enable certain features
1262 elseif(CMAKE_SYSTEM_NAME STREQUAL "HP-UX")
1264 # Use System V conventions for man pages.
1266 set(MAN_FILE_FORMATS 4)
1267 set(MAN_MISC_INFO 5)
1268 elseif(CMAKE_SYSTEM_NAME STREQUAL "IRIX" OR CMAKE_SYSTEM_NAME STREQUAL "IRIX64")
1270 # Use IRIX conventions for man pages; they're the same as the
1271 # System V conventions, except that they use section 8 for
1272 # administrative commands and daemons.
1274 set(MAN_FILE_FORMATS 4)
1275 set(MAN_MISC_INFO 5)
1276 elseif(CMAKE_SYSTEM_NAME STREQUAL "OSF1")
1278 # DEC OSF/1, a/k/a Digital UNIX, a/k/a Tru64 UNIX.
1279 # Use Tru64 UNIX conventions for man pages; they're the same as the
1280 # System V conventions except that they use section 8 for
1281 # administrative commands and daemons.
1283 set(MAN_FILE_FORMATS 4)
1284 set(MAN_MISC_INFO 5)
1285 elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*")
1289 if(CMAKE_SYSTEM_VERSION STREQUAL "5.12")
1292 # Use System V conventions for man pages.
1294 set(MAN_FILE_FORMATS 4)
1295 set(MAN_MISC_INFO 5)
1299 source_group("Source Files" FILES ${PROJECT_SOURCE_LIST_C})
1300 source_group("Header Files" FILES ${PROJECT_SOURCE_LIST_H})
1302 ######################################
1304 ######################################
1306 add_executable(tcpdump ${TCPDUMP_SOURCE_LIST_C})
1307 if(NOT C_ADDITIONAL_FLAGS STREQUAL "")
1308 set_target_properties(tcpdump PROPERTIES COMPILE_FLAGS ${C_ADDITIONAL_FLAGS})
1310 target_link_libraries(tcpdump netdissect ${TCPDUMP_LINK_LIBRARIES})
1312 ######################################
1313 # Write out the config.h file
1314 ######################################
1316 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
1318 ######################################
1319 # Install tcpdump and man pages
1320 ######################################
1323 # "Define GNU standard installation directories", which actually
1324 # are also defined, to some degree, by autotools, and at least
1325 # some of which are general UN*X conventions.
1327 include(GNUInstallDirs)
1329 set(MAN1_EXPAND tcpdump.1.in)
1332 # XXX TODO where to install on Windows?
1334 install(TARGETS tcpdump DESTINATION bin)
1337 # On UN*X, and on Windows when not using MSVC, process man pages and
1338 # arrange that they be installed.
1343 # For each section of the manual for which we have man pages
1344 # that require macro expansion, do the expansion.
1347 foreach(TEMPLATE_MANPAGE ${MAN1_EXPAND})
1348 string(REPLACE ".in" "" MANPAGE ${TEMPLATE_MANPAGE})
1349 configure_file(${CMAKE_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY)
1350 set(MAN1 ${MAN1} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE})
1351 endforeach(TEMPLATE_MANPAGE)
1352 install(FILES ${MAN1} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
1357 "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
1358 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
1361 add_custom_target(uninstall
1362 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
1366 # We try to find the Perl interpreter and, if we do, we have the check
1367 # rule run tests/TESTrun with it, because just trying to run the TESTrun
1368 # script as a command won't work on Windows.
1370 find_program(PERL perl)
1372 message(STATUS "Found perl at ${PERL}")
1373 add_custom_target(check
1374 COMMAND ${PERL} ${CMAKE_SOURCE_DIR}/tests/TESTrun)
1376 message(STATUS "Didn't find perl")