16f9cba8fSJoseph Mingroneif(WIN32) 26f9cba8fSJoseph Mingrone # 36f9cba8fSJoseph Mingrone # We need 3.12 or later, so that we can set policy CMP0074; see 46f9cba8fSJoseph Mingrone # below. 5*afdbf109SJoseph Mingrone # 66f9cba8fSJoseph Mingrone cmake_minimum_required(VERSION 3.12) 76f9cba8fSJoseph Mingroneelse(WIN32) 8*afdbf109SJoseph Mingrone # 9*afdbf109SJoseph Mingrone # For now: 10*afdbf109SJoseph Mingrone # 11*afdbf109SJoseph Mingrone # if this is a version of CMake less than 3.5, require only 12*afdbf109SJoseph Mingrone # 2.8.12, just in case somebody is configuring with CMake 13*afdbf109SJoseph Mingrone # on a "long-term support" version # of some OS and that 14*afdbf109SJoseph Mingrone # version supplies an older version of CMake; 15*afdbf109SJoseph Mingrone # 16*afdbf109SJoseph Mingrone # otherwise, require 3.5, so we don't get messages warning 17*afdbf109SJoseph Mingrone # that support for versions of CMake lower than 3.5 is 18*afdbf109SJoseph Mingrone # deprecated. 19*afdbf109SJoseph Mingrone # 20*afdbf109SJoseph Mingrone if(CMAKE_VERSION VERSION_LESS "3.5") 21*afdbf109SJoseph Mingrone cmake_minimum_required(VERSION 2.8.12) 22*afdbf109SJoseph Mingrone else() 23*afdbf109SJoseph Mingrone cmake_minimum_required(VERSION 3.5) 24*afdbf109SJoseph Mingrone endif() 256f9cba8fSJoseph Mingroneendif(WIN32) 26b00ab754SHans Petter Selasky 27b00ab754SHans Petter Selasky# 28b00ab754SHans Petter Selasky# Apple doesn't build with an install_name starting with @rpath, and 29b00ab754SHans Petter Selasky# neither do we with autotools; don't do so with CMake, either, and 30b00ab754SHans Petter Selasky# suppress warnings about that. 31b00ab754SHans Petter Selasky# 32*afdbf109SJoseph Mingrone# Setting CMAKE_MACOSX_RPATH to FALSE uses the old behavior, 33*afdbf109SJoseph Mingrone# but removes the POLICY CMP0042 OLD deprecated warning. 34*afdbf109SJoseph Mingrone# See https://cmake.org/cmake/help/latest/policy/CMP0042.html 35*afdbf109SJoseph Mingrone# 36*afdbf109SJoseph Mingroneif (NOT DEFINED CMAKE_MACOSX_RPATH) 37*afdbf109SJoseph Mingrone set(CMAKE_MACOSX_RPATH FALSE) 38*afdbf109SJoseph Mingroneendif() 39b00ab754SHans Petter Selaskyif(POLICY CMP0042) 40*afdbf109SJoseph Mingrone cmake_policy(SET CMP0042 NEW) 41b00ab754SHans Petter Selaskyendif() 42b00ab754SHans Petter Selasky 436f9cba8fSJoseph Mingrone# 446f9cba8fSJoseph Mingrone# Squelch noise about quoted strings in if() statements. 456f9cba8fSJoseph Mingrone# WE KNOW WHAT WE'RE DOING, WE'RE DOING EVERYTHING THE WAY THAT NEWER 466f9cba8fSJoseph Mingrone# VERSIONS OF CMAKE EXPECT BY DEFAULT, DON'T WASTE OUR TIME WITH NOISE. 476f9cba8fSJoseph Mingrone# 486f9cba8fSJoseph Mingroneif(POLICY CMP0054) 496f9cba8fSJoseph Mingrone cmake_policy(SET CMP0054 NEW) 506f9cba8fSJoseph Mingroneendif() 516f9cba8fSJoseph Mingrone 526f9cba8fSJoseph Mingrone# 536f9cba8fSJoseph Mingrone# We want find_file() and find_library() to honor {packagename}_ROOT, 546f9cba8fSJoseph Mingrone# as that appears to be the only way, with the Visual Studio 2019 IDE 556f9cba8fSJoseph Mingrone# and its CMake support, to tell CMake where to look for the Npcap 566f9cba8fSJoseph Mingrone# or WinPcap SDK. 576f9cba8fSJoseph Mingrone# 586f9cba8fSJoseph Mingroneif(POLICY CMP0074) 596f9cba8fSJoseph Mingrone cmake_policy(SET CMP0074 NEW) 606f9cba8fSJoseph Mingroneendif() 616f9cba8fSJoseph Mingrone 626f9cba8fSJoseph Mingrone# 636f9cba8fSJoseph Mingrone# We want check_include_file() to honor CMAKE_REQUIRED_LIBRARIES; see 646f9cba8fSJoseph Mingrone# the big comment before the check_include_file() test for 656f9cba8fSJoseph Mingrone# infiniband/verbs.h for the reason. 666f9cba8fSJoseph Mingrone# 676f9cba8fSJoseph Mingroneif(POLICY CMP0075) 686f9cba8fSJoseph Mingrone cmake_policy(SET CMP0075 NEW) 696f9cba8fSJoseph Mingroneendif() 706f9cba8fSJoseph Mingrone 7157e22627SCy Schubertset(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) 72b00ab754SHans Petter Selasky 736f9cba8fSJoseph Mingrone# 74*afdbf109SJoseph Mingrone# We explicitly indicate what languages are used in libpcap to avoid 75*afdbf109SJoseph Mingrone# checking for a C++ compiler. 766f9cba8fSJoseph Mingrone# 77*afdbf109SJoseph Mingrone# One reason to avoid that check is that there's no need to waste 78*afdbf109SJoseph Mingrone# configuration time performing it. 796f9cba8fSJoseph Mingrone# 80*afdbf109SJoseph Mingrone# Another reason is that: 81*afdbf109SJoseph Mingrone# 82*afdbf109SJoseph Mingrone# CMake will try to determine the sizes of some data types, including 83*afdbf109SJoseph Mingrone# void *, early in the process of configuration; apparently, it's done 84*afdbf109SJoseph Mingrone# as part of processing the project() command. 85*afdbf109SJoseph Mingrone# 86*afdbf109SJoseph Mingrone# At least as of CMake 2.8.6, it does so by checking the size of 87*afdbf109SJoseph Mingrone# "void *" in C, setting CMAKE_C_SIZEOF_DATA_PTR based on that, 88*afdbf109SJoseph Mingrone# setting CMAKE_SIZEOF_VOID_P to that, and then checking the size 89*afdbf109SJoseph Mingrone# of "void *" in C++, setting CMAKE_CXX_SIZEOF_DATA_PTR based on 90*afdbf109SJoseph Mingrone# that, and then setting CMAKE_SIZEOF_VOID_P to *that*. 91*afdbf109SJoseph Mingrone# 92*afdbf109SJoseph Mingrone# The compile tests include whatever C flags may have been provided 93*afdbf109SJoseph Mingrone# to CMake in the CFLAGS and CXXFLAGS environment variables. 94*afdbf109SJoseph Mingrone# 95*afdbf109SJoseph Mingrone# If you set an architecture flag such as -m32 or -m64 in CFLAGS 96*afdbf109SJoseph Mingrone# but *not* in CXXFLAGS, the size for C++ will win, and hilarity 97*afdbf109SJoseph Mingrone# will ensue. 98*afdbf109SJoseph Mingrone# 99*afdbf109SJoseph Mingrone# Or if, at least on Solaris, you have a newer version of GCC 100*afdbf109SJoseph Mingrone# installed, but *not* a newer version of G++, and you have Oracle 101*afdbf109SJoseph Mingrone# Studio installed, it will find GCC, which will default to building 102*afdbf109SJoseph Mingrone# 64-bit, and Oracle Studio's C++ compiler, which will default to 103*afdbf109SJoseph Mingrone# building 32-bit, the size for C++ will win, and, again, hilarity 104*afdbf109SJoseph Mingrone# will ensue. 1056f9cba8fSJoseph Mingrone# 1066f9cba8fSJoseph Mingroneproject(pcap C) 1076f9cba8fSJoseph Mingrone 1086f9cba8fSJoseph Mingrone# 109*afdbf109SJoseph Mingrone# Setting CMAKE_MACOSX_RPATH to FALSE causes the installed 110*afdbf109SJoseph Mingrone# libpcap.A.dylib to have just libpcap.A.dylib as the install 111*afdbf109SJoseph Mingrone# name; Apple built libpcap with an install_name of /usr/lib/libpcap.A.dylib 112*afdbf109SJoseph Mingrone# (back when they still shipped individual system dylibs rather than 113*afdbf109SJoseph Mingrone# shipping a pre-built shared library cache, at least), and we do the 114*afdbf109SJoseph Mingrone# same with autotools; do the same with CMake. 115*afdbf109SJoseph Mingrone# 116*afdbf109SJoseph Mingroneif (NOT DEFINED CMAKE_INSTALL_NAME_DIR) 117*afdbf109SJoseph Mingrone set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib) 118*afdbf109SJoseph Mingroneendif() 119*afdbf109SJoseph Mingrone 120*afdbf109SJoseph Mingrone# 1216f9cba8fSJoseph Mingrone# For getting raw lists of --libs and --libs --static information from a 1226f9cba8fSJoseph Mingrone# pkg-config module. 1236f9cba8fSJoseph Mingrone# 1246f9cba8fSJoseph Mingrone# In CMake up to 2.8.12, pkg_check_modules() sets: 1256f9cba8fSJoseph Mingrone# 1266f9cba8fSJoseph Mingrone# <XPREFIX>_LIBRARIES, which is a list of library names to which, on 1276f9cba8fSJoseph Mingrone# a UN*X, -l can be prefixed - i.e., names, without extensions, 1286f9cba8fSJoseph Mingrone# rather than full paths to the file. 1296f9cba8fSJoseph Mingrone# <XPREFIX>_LIBRARY_DIRS, which is a list of paths to directories 1306f9cba8fSJoseph Mingrone# containing the libraries, to which, on a UN*X, -L can be 1316f9cba8fSJoseph Mingrone# prefixed. 1326f9cba8fSJoseph Mingrone# <XPREFIX>_LDFLAGS, which is a list of *all* required linker flags 1336f9cba8fSJoseph Mingrone# <XPREFIX>_LDFLAGS_OTHER, which is a list of all linker flags other 1346f9cba8fSJoseph Mingrone# than -l and -L flags 1356f9cba8fSJoseph Mingrone# 1366f9cba8fSJoseph Mingrone# In 3.0 (at least as of 3.0.2), it also sets: 1376f9cba8fSJoseph Mingrone# 1386f9cba8fSJoseph Mingrone# <XPREFIX>_LINK_LIBRARIES, which is a list of full paths to the 1396f9cba8fSJoseph Mingrone# library files. 1406f9cba8fSJoseph Mingrone# 1416f9cba8fSJoseph Mingrone# but if <XPREFIX> is <PREFIX>_STATIC, <XPREFIX>_LINK_LIBRARIES is 1426f9cba8fSJoseph Mingrone# currently not set by CMake. 1436f9cba8fSJoseph Mingrone# 1446f9cba8fSJoseph Mingrone# Unfortunately, pkg_check_modules() sets the 1456f9cba8fSJoseph Mingrone# PKG_CONFIG_ALLOW_SYSTEM_LIBS environment variable when running 1466f9cba8fSJoseph Mingrone# pkg-config, so the output of --libs, etc. may include a -L for the 1476f9cba8fSJoseph Mingrone# system library, which we do *NOT* want to put in our libpcap.pc and 1486f9cba8fSJoseph Mingrone# pcap-config files. 1496f9cba8fSJoseph Mingrone# 1506f9cba8fSJoseph Mingrone# So we just run pkg-config ourselves, so that we get its output 1516f9cba8fSJoseph Mingrone# directly without any processing by CMake. 1526f9cba8fSJoseph Mingrone# 1536f9cba8fSJoseph Mingronemacro(pkg_get_link_info _prefix _package) 1546f9cba8fSJoseph Mingrone if (PKG_CONFIG_EXECUTABLE) 1556f9cba8fSJoseph Mingrone # 1566f9cba8fSJoseph Mingrone # Get the --libs information. 1576f9cba8fSJoseph Mingrone # 1586f9cba8fSJoseph Mingrone # We force PKG_CONFIG_ALLOW_SYSTEM_LIBS to be undefined, as 1596f9cba8fSJoseph Mingrone # at least some versions of CMake appear to define it in 1606f9cba8fSJoseph Mingrone # pkg_check_modules() before running pkg-config and *not* undefine 1616f9cba8fSJoseph Mingrone # it after running it. 1626f9cba8fSJoseph Mingrone # 1636f9cba8fSJoseph Mingrone unset(ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS}) 1646f9cba8fSJoseph Mingrone set(_pkg_config_result "") 1656f9cba8fSJoseph Mingrone execute_process( 1666f9cba8fSJoseph Mingrone COMMAND ${PKG_CONFIG_EXECUTABLE} "--libs" ${_package} 1676f9cba8fSJoseph Mingrone OUTPUT_VARIABLE _pkg_config_result 1686f9cba8fSJoseph Mingrone RESULT_VARIABLE _pkg_config_failed 1696f9cba8fSJoseph Mingrone OUTPUT_STRIP_TRAILING_WHITESPACE) 1706f9cba8fSJoseph Mingrone 1716f9cba8fSJoseph Mingrone if (_pkg_config_failed) 1726f9cba8fSJoseph Mingrone # 1736f9cba8fSJoseph Mingrone # pkg-config failed; assume that means that there is no such 1746f9cba8fSJoseph Mingrone # package for it to find. XXX - what do we do here? 1756f9cba8fSJoseph Mingrone # 1766f9cba8fSJoseph Mingrone set(${_prefix}_FOUND_WITH_PKG_CONFIG FALSE) 1776f9cba8fSJoseph Mingrone else() 1786f9cba8fSJoseph Mingrone # 1796f9cba8fSJoseph Mingrone # pkg-config succeeded; replace CR and LF with spaces. 1806f9cba8fSJoseph Mingrone # 1816f9cba8fSJoseph Mingrone string(REGEX REPLACE "[\r\n]" " " ${_prefix}_LIBS "${_pkg_config_result}") 1826f9cba8fSJoseph Mingrone 1836f9cba8fSJoseph Mingrone # 1846f9cba8fSJoseph Mingrone # Now get the --libs --static information. 1856f9cba8fSJoseph Mingrone # 1866f9cba8fSJoseph Mingrone set(_pkg_config_result "") 1876f9cba8fSJoseph Mingrone execute_process( 1886f9cba8fSJoseph Mingrone COMMAND ${PKG_CONFIG_EXECUTABLE} "--libs" "--static" ${_package} 1896f9cba8fSJoseph Mingrone OUTPUT_VARIABLE _pkg_config_result 1906f9cba8fSJoseph Mingrone RESULT_VARIABLE _pkg_config_failed 1916f9cba8fSJoseph Mingrone OUTPUT_STRIP_TRAILING_WHITESPACE) 1926f9cba8fSJoseph Mingrone 1936f9cba8fSJoseph Mingrone if (_pkg_config_failed) 1946f9cba8fSJoseph Mingrone # 1956f9cba8fSJoseph Mingrone # pkg-config failed; assume that means that there is no such 1966f9cba8fSJoseph Mingrone # package for it to find. XXX - what do we do here? 1976f9cba8fSJoseph Mingrone # 1986f9cba8fSJoseph Mingrone set(${_prefix}_FOUND_WITH_PKG_CONFIG FALSE) 1996f9cba8fSJoseph Mingrone else() 2006f9cba8fSJoseph Mingrone # 2016f9cba8fSJoseph Mingrone # pkg-config succeeded; replace CR and LF with spaces. 2026f9cba8fSJoseph Mingrone # 2036f9cba8fSJoseph Mingrone string(REGEX REPLACE "[\r\n]" " " ${_prefix}_LIBS_STATIC "${_pkg_config_result}") 2046f9cba8fSJoseph Mingrone 2056f9cba8fSJoseph Mingrone # 2066f9cba8fSJoseph Mingrone # List this package in its PACKAGE_NAME variable. 2076f9cba8fSJoseph Mingrone # 2086f9cba8fSJoseph Mingrone set(${_prefix}_PACKAGE_NAME "${_package}") 2096f9cba8fSJoseph Mingrone 2106f9cba8fSJoseph Mingrone # 2116f9cba8fSJoseph Mingrone # It worked. 2126f9cba8fSJoseph Mingrone # 2136f9cba8fSJoseph Mingrone set(${_prefix}_FOUND_WITH_PKG_CONFIG TRUE) 2146f9cba8fSJoseph Mingrone endif() 2156f9cba8fSJoseph Mingrone endif() 2166f9cba8fSJoseph Mingrone endif() 2176f9cba8fSJoseph Mingroneendmacro() 2186f9cba8fSJoseph Mingrone 2196f9cba8fSJoseph Mingronemacro(get_link_info_from_library_path _library_prefix _library_name) 2206f9cba8fSJoseph Mingrone if(NOT ${_library_prefix}_LIBRARY STREQUAL "${_library_prefix}_LIBRARY-NOTFOUND") 2216f9cba8fSJoseph Mingrone get_filename_component(_lib_directory "${${_library_prefix}_LIBRARY}}" DIRECTORY) 2226f9cba8fSJoseph Mingrone 2236f9cba8fSJoseph Mingrone # 2246f9cba8fSJoseph Mingrone # The closest thing to a list of "system library directories" in 2256f9cba8fSJoseph Mingrone # which the linker will, by default, search for libraries appears to 2266f9cba8fSJoseph Mingrone # be CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES, so that's what we use 2276f9cba8fSJoseph Mingrone # when we're trying to construct a -L argument, for insertion into 2286f9cba8fSJoseph Mingrone # pcap-config and libpcap.pc, for a library upon which we depend. 2296f9cba8fSJoseph Mingrone # 2306f9cba8fSJoseph Mingrone # In some versions of CMake it appears to have duplicate entries, 2316f9cba8fSJoseph Mingrone # but that shouldn't affect a search for a directory in that list. 2326f9cba8fSJoseph Mingrone # 2336f9cba8fSJoseph Mingrone list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${_lib_directory}" _lib_index) 2346f9cba8fSJoseph Mingrone if(_lib_index EQUAL -1) 2356f9cba8fSJoseph Mingrone # 2366f9cba8fSJoseph Mingrone # No, so add a -L flag to get the linker to search in that 2376f9cba8fSJoseph Mingrone # directory. 2386f9cba8fSJoseph Mingrone # 2396f9cba8fSJoseph Mingrone set(${_library_prefix}_LIBS "-L${_lib_directory}") 2406f9cba8fSJoseph Mingrone set(${_library_prefix}_LIBS_STATIC "-L${_lib_directory}") 2416f9cba8fSJoseph Mingrone set(${_libraryprefix}_LIBS_PRIVATE "-L${_lib_directory}") 2426f9cba8fSJoseph Mingrone endif() 2436f9cba8fSJoseph Mingrone set(${_library_prefix}_LIBS "${${_library_prefix}_LIBS} -l${_library_name}") 2446f9cba8fSJoseph Mingrone set(${_library_prefix}_LIBS_STATIC "${${_library_prefix}_LIBS} -l${_library_name}") 2456f9cba8fSJoseph Mingrone set(${_library_prefix}_LIBS_PRIVATE "${${_library_prefix}_LIBS} -l${_library_name}") 2466f9cba8fSJoseph Mingrone endif() 2476f9cba8fSJoseph Mingroneendmacro() 2486f9cba8fSJoseph Mingrone 2496f9cba8fSJoseph Mingrone# 2506f9cba8fSJoseph Mingrone# Show the bit width for which we're compiling. 2516f9cba8fSJoseph Mingrone# This can help debug problems if you're dealing with a compiler that 2526f9cba8fSJoseph Mingrone# defaults to generating 32-bit code even when running on a 64-bit 2536f9cba8fSJoseph Mingrone# platform, and where that platform may provide only 64-bit versions of 2546f9cba8fSJoseph Mingrone# libraries that we might use (looking at *you*, Oracle Studio!). 2556f9cba8fSJoseph Mingrone# 2566f9cba8fSJoseph Mingroneif(CMAKE_SIZEOF_VOID_P EQUAL 4) 2576f9cba8fSJoseph Mingrone message(STATUS "Building 32-bit") 2586f9cba8fSJoseph Mingroneelseif(CMAKE_SIZEOF_VOID_P EQUAL 8) 2596f9cba8fSJoseph Mingrone message(STATUS "Building 64-bit") 2606f9cba8fSJoseph Mingroneendif() 2616f9cba8fSJoseph Mingrone 2626f9cba8fSJoseph Mingrone# 2636f9cba8fSJoseph Mingrone# Solaris pkg-config is annoying. For at least one package (D-Bus, I'm 2646f9cba8fSJoseph Mingrone# looking at *you*!), there are separate include files for 32-bit and 2656f9cba8fSJoseph Mingrone# 64-bit builds (I guess using "unsigned long long" as a 64-bit integer 266*afdbf109SJoseph Mingrone# type on a 64-bit build is like crossing the beams or something), and 2676f9cba8fSJoseph Mingrone# there are two separate .pc files, so if we're doing a 32-bit build we 2686f9cba8fSJoseph Mingrone# should make sure we look in /usr/lib/pkgconfig for .pc files and if 2696f9cba8fSJoseph Mingrone# we're doing a 64-bit build we should make sure we look in 2706f9cba8fSJoseph Mingrone# /usr/lib/amd64/pkgconfig for .pc files. 2716f9cba8fSJoseph Mingrone# 2726f9cba8fSJoseph Mingroneif(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*") 2736f9cba8fSJoseph Mingrone # 2746f9cba8fSJoseph Mingrone # Note: string(REPLACE) does not appear to support using ENV{...} 2756f9cba8fSJoseph Mingrone # as an argument, so we set a variable and then use set() to set 2766f9cba8fSJoseph Mingrone # the environment variable. 2776f9cba8fSJoseph Mingrone # 2786f9cba8fSJoseph Mingrone if(CMAKE_SIZEOF_VOID_P EQUAL 8) 2796f9cba8fSJoseph Mingrone # 2806f9cba8fSJoseph Mingrone # 64-bit build. If /usr/lib/pkgconfig appears in the path, 2816f9cba8fSJoseph Mingrone # prepend /usr/lib/amd64/pkgconfig to it; otherwise, 2826f9cba8fSJoseph Mingrone # put /usr/lib/amd64 at the end. 2836f9cba8fSJoseph Mingrone # 2846f9cba8fSJoseph Mingrone if((NOT DEFINED ENV{PKG_CONFIG_PATH}) OR "$ENV{PKG_CONFIG_PATH}" EQUAL "") 2856f9cba8fSJoseph Mingrone # 2866f9cba8fSJoseph Mingrone # Not set, or empty. Set it to /usr/lib/amd64/pkgconfig. 2876f9cba8fSJoseph Mingrone # 2886f9cba8fSJoseph Mingrone set(fixed_path "/usr/lib/amd64/pkgconfig") 2896f9cba8fSJoseph Mingrone elseif("$ENV{PKG_CONFIG_PATH}" MATCHES "/usr/lib/pkgconfig") 2906f9cba8fSJoseph Mingrone # 2916f9cba8fSJoseph Mingrone # It contains /usr/lib/pkgconfig. Prepend 2926f9cba8fSJoseph Mingrone # /usr/lib/amd64/pkgconfig to /usr/lib/pkgconfig. 2936f9cba8fSJoseph Mingrone # 2946f9cba8fSJoseph Mingrone string(REPLACE "/usr/lib/pkgconfig" 2956f9cba8fSJoseph Mingrone "/usr/lib/amd64/pkgconfig:/usr/lib/pkgconfig" 2966f9cba8fSJoseph Mingrone fixed_path "$ENV{PKG_CONFIG_PATH}") 2976f9cba8fSJoseph Mingrone else() 2986f9cba8fSJoseph Mingrone # 2996f9cba8fSJoseph Mingrone # Not empty, but doesn't contain /usr/lib/pkgconfig. 3006f9cba8fSJoseph Mingrone # Append /usr/lib/amd64/pkgconfig to it. 3016f9cba8fSJoseph Mingrone # 3026f9cba8fSJoseph Mingrone set(fixed_path "$ENV{PKG_CONFIG_PATH}:/usr/lib/amd64/pkgconfig") 3036f9cba8fSJoseph Mingrone endif() 3046f9cba8fSJoseph Mingrone set(ENV{PKG_CONFIG_PATH} "${fixed_path}") 3056f9cba8fSJoseph Mingrone elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) 3066f9cba8fSJoseph Mingrone # 3076f9cba8fSJoseph Mingrone # 32-bit build. If /usr/amd64/lib/pkgconfig appears in the path, 3086f9cba8fSJoseph Mingrone # prepend /usr/lib/pkgconfig to it. 3096f9cba8fSJoseph Mingrone # 3106f9cba8fSJoseph Mingrone if("$ENV{PKG_CONFIG_PATH}" MATCHES "/usr/lib/amd64/pkgconfig") 3116f9cba8fSJoseph Mingrone # 3126f9cba8fSJoseph Mingrone # It contains /usr/lib/amd64/pkgconfig. Prepend 3136f9cba8fSJoseph Mingrone # /usr/lib/pkgconfig to /usr/lib/amd64/pkgconfig. 3146f9cba8fSJoseph Mingrone # 3156f9cba8fSJoseph Mingrone string(REPLACE "/usr/lib/amd64/pkgconfig" 3166f9cba8fSJoseph Mingrone "/usr/lib/pkgconfig:/usr/lib/amd64/pkgconfig" 3176f9cba8fSJoseph Mingrone fixed_path "$ENV{PKG_CONFIG_PATH}") 3186f9cba8fSJoseph Mingrone set(ENV{PKG_CONFIG_PATH} "${fixed_path}") 3196f9cba8fSJoseph Mingrone endif() 3206f9cba8fSJoseph Mingrone endif() 3216f9cba8fSJoseph Mingroneendif() 3226f9cba8fSJoseph Mingrone 3236f9cba8fSJoseph Mingroneinclude(CheckCCompilerFlag) 3246f9cba8fSJoseph Mingrone 3256f9cba8fSJoseph Mingrone# 3266f9cba8fSJoseph Mingrone# For checking if a compiler flag works and adding it if it does. 3276f9cba8fSJoseph Mingrone# 3286f9cba8fSJoseph Mingronemacro(check_and_add_compiler_option _option) 3296f9cba8fSJoseph Mingrone message(STATUS "Checking C compiler flag ${_option}") 3306f9cba8fSJoseph Mingrone string(REPLACE "=" "-" _temp_option_variable ${_option}) 3316f9cba8fSJoseph Mingrone string(REGEX REPLACE "^-" "" _option_variable ${_temp_option_variable}) 3326f9cba8fSJoseph Mingrone check_c_compiler_flag("${_option}" ${_option_variable}) 3336f9cba8fSJoseph Mingrone if(${${_option_variable}}) 3346f9cba8fSJoseph Mingrone set(C_ADDITIONAL_FLAGS "${C_ADDITIONAL_FLAGS} ${_option}") 3356f9cba8fSJoseph Mingrone endif() 3366f9cba8fSJoseph Mingroneendmacro() 3376f9cba8fSJoseph Mingrone 3386f9cba8fSJoseph Mingrone# 3396f9cba8fSJoseph Mingrone# If we're building with Visual Studio, we require Visual Studio 2015, 3406f9cba8fSJoseph Mingrone# in order to get sufficient C99 compatibility. Check for that. 3416f9cba8fSJoseph Mingrone# 3426f9cba8fSJoseph Mingrone# If not, try the appropriate flag for the compiler to enable C99 3436f9cba8fSJoseph Mingrone# features. 3446f9cba8fSJoseph Mingrone# 3456f9cba8fSJoseph Mingroneset(C_ADDITIONAL_FLAGS "") 3466f9cba8fSJoseph Mingroneif(MSVC) 3476f9cba8fSJoseph Mingrone if(MSVC_VERSION LESS 1900) 3486f9cba8fSJoseph Mingrone message(FATAL_ERROR "Visual Studio 2015 or later is required") 3496f9cba8fSJoseph Mingrone endif() 3506f9cba8fSJoseph Mingrone 3516f9cba8fSJoseph Mingrone # 3526f9cba8fSJoseph Mingrone # Treat source files as being in UTF-8 with MSVC if it's not using 3536f9cba8fSJoseph Mingrone # the Clang front end. 3546f9cba8fSJoseph Mingrone # We assume that UTF-8 source is OK with other compilers and with 3556f9cba8fSJoseph Mingrone # MSVC if it's using the Clang front end. 3566f9cba8fSJoseph Mingrone # 3576f9cba8fSJoseph Mingrone if(NOT ${CMAKE_C_COMPILER} MATCHES "clang*") 3586f9cba8fSJoseph Mingrone set(C_ADDITIONAL_FLAGS "${C_ADDITIONAL_FLAGS} /utf-8") 3596f9cba8fSJoseph Mingrone endif(NOT ${CMAKE_C_COMPILER} MATCHES "clang*") 3606f9cba8fSJoseph Mingroneelse(MSVC) 3616f9cba8fSJoseph Mingrone # 3626f9cba8fSJoseph Mingrone # For checking if a compiler flag works, failing if it doesn't, 3636f9cba8fSJoseph Mingrone # and adding it otherwise. 3646f9cba8fSJoseph Mingrone # 3656f9cba8fSJoseph Mingrone macro(require_and_add_compiler_option _option) 3666f9cba8fSJoseph Mingrone message(STATUS "Checking C compiler flag ${_option}") 3676f9cba8fSJoseph Mingrone string(REPLACE "=" "-" _temp_option_variable ${_option}) 3686f9cba8fSJoseph Mingrone string(REGEX REPLACE "^-" "" _option_variable ${_temp_option_variable}) 3696f9cba8fSJoseph Mingrone check_c_compiler_flag("${_option}" ${_option_variable}) 3706f9cba8fSJoseph Mingrone if(${${_option_variable}}) 3716f9cba8fSJoseph Mingrone set(C_ADDITIONAL_FLAGS "${C_ADDITIONAL_FLAGS} ${_option}") 3726f9cba8fSJoseph Mingrone else() 3736f9cba8fSJoseph Mingrone message(FATAL_ERROR "C99 support is required, but the compiler doesn't support a compiler flag to enable it") 3746f9cba8fSJoseph Mingrone endif() 3756f9cba8fSJoseph Mingrone endmacro() 376b00ab754SHans Petter Selasky 377b00ab754SHans Petter Selasky # 378b00ab754SHans Petter Selasky # Try to enable as many C99 features as we can. 379b00ab754SHans Petter Selasky # At minimum, we want C++/C99-style // comments. 380b00ab754SHans Petter Selasky # 3816f9cba8fSJoseph Mingrone # Newer versions of compilers might default to supporting C99, but 3826f9cba8fSJoseph Mingrone # older versions may require a special flag. 383b00ab754SHans Petter Selasky # 384b00ab754SHans Petter Selasky # Prior to CMake 3.1, setting CMAKE_C_STANDARD will not have any effect, 385b00ab754SHans Petter Selasky # so, unless and until we require CMake 3.1 or later, we have to do it 386b00ab754SHans Petter Selasky # ourselves on pre-3.1 CMake, so we just do it ourselves on all versions 387b00ab754SHans Petter Selasky # of CMake. 388b00ab754SHans Petter Selasky # 389b00ab754SHans Petter Selasky # Note: with CMake 3.1 through 3.5, the only compilers for which CMake 390b00ab754SHans Petter Selasky # handles CMAKE_C_STANDARD are GCC and Clang. 3.6 adds support only 391b00ab754SHans Petter Selasky # for Intel C; 3.9 adds support for PGI C, Sun C, and IBM XL C, and 392b00ab754SHans Petter Selasky # 3.10 adds support for Cray C and IAR C, but no version of CMake has 393b00ab754SHans Petter Selasky # support for HP C. Therefore, even if we use CMAKE_C_STANDARD with 394b00ab754SHans Petter Selasky # compilers for which CMake supports it, we may still have to do it 395b00ab754SHans Petter Selasky # ourselves on other compilers. 396b00ab754SHans Petter Selasky # 397b00ab754SHans Petter Selasky # See the CMake documentation for the CMAKE_<LANG>_COMPILER_ID variables 398b00ab754SHans Petter Selasky # for a list of compiler IDs. 399b00ab754SHans Petter Selasky # 4006f9cba8fSJoseph Mingrone # XXX - this just tests whether the option works, fails if it doesn't, 4016f9cba8fSJoseph Mingrone # and adds it if it does. We don't test whether it's necessary in order 4026f9cba8fSJoseph Mingrone # to get the C99 features that we use, or whether, if it's used, it 4036f9cba8fSJoseph Mingrone # enables all the features that we require. 404b00ab754SHans Petter Selasky # 405b00ab754SHans Petter Selasky if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR 406b00ab754SHans Petter Selasky CMAKE_C_COMPILER_ID MATCHES "Clang") 4076f9cba8fSJoseph Mingrone require_and_add_compiler_option("-std=gnu99") 408b00ab754SHans Petter Selasky elseif(CMAKE_C_COMPILER_ID MATCHES "XL") 409b00ab754SHans Petter Selasky # 410b00ab754SHans Petter Selasky # We want support for extensions picked up for GNU C compatibility, 411b00ab754SHans Petter Selasky # so we use -qlanglvl=extc99. 412b00ab754SHans Petter Selasky # 4136f9cba8fSJoseph Mingrone require_and_add_compiler_option("-qlanglvl=extc99") 414b00ab754SHans Petter Selasky elseif(CMAKE_C_COMPILER_ID MATCHES "HP") 4156f9cba8fSJoseph Mingrone require_and_add_compiler_option("-AC99") 416b00ab754SHans Petter Selasky elseif(CMAKE_C_COMPILER_ID MATCHES "Sun") 4176f9cba8fSJoseph Mingrone require_and_add_compiler_option("-xc99") 418b00ab754SHans Petter Selasky elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") 4196f9cba8fSJoseph Mingrone require_and_add_compiler_option("-c99") 420b00ab754SHans Petter Selasky endif() 4216f9cba8fSJoseph Mingroneendif(MSVC) 4226f9cba8fSJoseph Mingrone 4236f9cba8fSJoseph Mingrone# 4246f9cba8fSJoseph Mingrone# If we're building with MinGW, we need to specify _WIN32_WINNT as 4256f9cba8fSJoseph Mingrone# 0x0600 ("NT 6.0", a/k/a Vista/Windows Server 2008) or higher 4266f9cba8fSJoseph Mingrone# in order to get the full IPv6 API, including inet_ntop(), and we 4276f9cba8fSJoseph Mingrone# need to specify it as 0x0601 ("NT 6.1", a/k/a Windows 7) or higher 4286f9cba8fSJoseph Mingrone# in order to get NdisMediumIP. 4296f9cba8fSJoseph Mingrone# 4306f9cba8fSJoseph Mingrone# NOTE: pcap does *NOT* work with msvcrt.dll; it must link with 4316f9cba8fSJoseph Mingrone# a newer version of the C library, i.e. Visual Studio 2015 or 4326f9cba8fSJoseph Mingrone# later, as it depends on C99 features introduced in VS 2015. 4336f9cba8fSJoseph Mingrone# 4346f9cba8fSJoseph Mingroneif(MINGW) 4356f9cba8fSJoseph Mingrone add_definitions(-D_WIN32_WINNT=0x0601) 4366f9cba8fSJoseph Mingroneendif(MINGW) 437b00ab754SHans Petter Selasky 438b00ab754SHans Petter Selasky# 439b00ab754SHans Petter Selasky# Build all runtimes in the top-level binary directory; that way, 440b00ab754SHans Petter Selasky# on Windows, the executables will be in the same directory as 441b00ab754SHans Petter Selasky# the DLLs, so the system will find pcap.dll when any of the 442b00ab754SHans Petter Selasky# executables are run. 443b00ab754SHans Petter Selasky# 444b00ab754SHans Petter Selaskyset(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run) 445b00ab754SHans Petter Selasky 446b00ab754SHans Petter Selasky################################################################### 447b00ab754SHans Petter Selasky# Parameters 448b00ab754SHans Petter Selasky################################################################### 449b00ab754SHans Petter Selasky 450b00ab754SHans Petter Selaskyif(WIN32) 451b00ab754SHans Petter Selasky # 452b00ab754SHans Petter Selasky # On Windows, allow the library name to be overridden, for the 453b00ab754SHans Petter Selasky # benefit of projects that combine libpcap with their own 454b00ab754SHans Petter Selasky # kernel-mode code to support capturing. 455b00ab754SHans Petter Selasky # 456b00ab754SHans Petter Selasky set(LIBRARY_NAME pcap CACHE STRING "Library name") 457b00ab754SHans Petter Selaskyelse() 458b00ab754SHans Petter Selasky # 459b00ab754SHans Petter Selasky # On UN*X, it's always been libpcap. 460b00ab754SHans Petter Selasky # 461b00ab754SHans Petter Selasky set(LIBRARY_NAME pcap) 462b00ab754SHans Petter Selaskyendif() 463b00ab754SHans Petter Selasky 464b00ab754SHans Petter Selaskyoption(INET6 "Enable IPv6" ON) 465b00ab754SHans Petter Selaskyif(WIN32) 466b00ab754SHans Petter Selasky option(USE_STATIC_RT "Use static Runtime" ON) 467b00ab754SHans Petter Selaskyendif(WIN32) 468b00ab754SHans Petter Selaskyoption(BUILD_SHARED_LIBS "Build shared libraries" ON) 4696f9cba8fSJoseph Mingroneset(dpdk_ROOT "" CACHE PATH "Path to directory with include and lib subdirectories for DPDK") 470b00ab754SHans Petter Selaskyif(WIN32) 4716f9cba8fSJoseph Mingrone set(Packet_ROOT "" CACHE PATH "Path to directory with include and lib subdirectories for packet.dll") 4726f9cba8fSJoseph Mingrone set(AirPcap_ROOT "" CACHE PATH "Path to directory with include and lib subdirectories for airpcap.dll") 473b00ab754SHans Petter Selaskyendif(WIN32) 474b00ab754SHans Petter Selasky 4756f9cba8fSJoseph Mingroneoption(ENABLE_PROFILING "Enable code profiling" OFF) 4766f9cba8fSJoseph Mingrone 477b00ab754SHans Petter Selasky# To pacify those who hate the protochain instruction 478b00ab754SHans Petter Selaskyoption(NO_PROTOCHAIN "Disable protochain instruction" OFF) 479b00ab754SHans Petter Selasky 480b00ab754SHans Petter Selasky# 481b00ab754SHans Petter Selasky# Start out with the capture mechanism type unspecified; the user 482b00ab754SHans Petter Selasky# can explicitly specify it and, if they don't, we'll pick an 483b00ab754SHans Petter Selasky# appropriate one. 484b00ab754SHans Petter Selasky# 485b00ab754SHans Petter Selaskyset(PCAP_TYPE "" CACHE STRING "Packet capture type") 486b00ab754SHans Petter Selasky 487b00ab754SHans Petter Selasky# 488b00ab754SHans Petter Selasky# Default to having remote capture support on Windows and, for now, to 489b00ab754SHans Petter Selasky# not having it on UN*X. 490b00ab754SHans Petter Selasky# 491b00ab754SHans Petter Selaskyif(WIN32) 492b00ab754SHans Petter Selasky option(ENABLE_REMOTE "Enable remote capture" ON) 493b00ab754SHans Petter Selaskyelse() 494b00ab754SHans Petter Selasky option(ENABLE_REMOTE "Enable remote capture" OFF) 495b00ab754SHans Petter Selaskyendif(WIN32) 496b00ab754SHans Petter Selasky 497b00ab754SHans Petter Selaskyif(CMAKE_SYSTEM_NAME STREQUAL "Linux") 498b00ab754SHans Petter Selasky option(BUILD_WITH_LIBNL "Build with libnl" ON) 499b00ab754SHans Petter Selaskyendif() 500b00ab754SHans Petter Selasky 501b00ab754SHans Petter Selasky# 502b00ab754SHans Petter Selasky# Additional capture modules. 503b00ab754SHans Petter Selasky# 5046f9cba8fSJoseph Mingroneif(CMAKE_SYSTEM_NAME STREQUAL "Linux") 5056f9cba8fSJoseph Mingrone option(DISABLE_LINUX_USBMON "Disable Linux usbmon USB sniffing support" OFF) 5066f9cba8fSJoseph Mingroneendif() 507b00ab754SHans Petter Selaskyoption(DISABLE_BLUETOOTH "Disable Bluetooth sniffing support" OFF) 508b00ab754SHans Petter Selaskyoption(DISABLE_NETMAP "Disable netmap support" OFF) 5096f9cba8fSJoseph Mingroneoption(DISABLE_DPDK "Disable DPDK support" OFF) 5106f9cba8fSJoseph Mingrone 511b00ab754SHans Petter Selasky# 512b00ab754SHans Petter Selasky# We don't support D-Bus sniffing on macOS; see 513b00ab754SHans Petter Selasky# 514b00ab754SHans Petter Selasky# https://bugs.freedesktop.org/show_bug.cgi?id=74029 515b00ab754SHans Petter Selasky# 516b00ab754SHans Petter Selaskyif(APPLE) 517b00ab754SHans Petter Selasky option(DISABLE_DBUS "Disable D-Bus sniffing support" ON) 518b00ab754SHans Petter Selaskyelse(APPLE) 519b00ab754SHans Petter Selasky option(DISABLE_DBUS "Disable D-Bus sniffing support" OFF) 520b00ab754SHans Petter Selaskyendif(APPLE) 521b00ab754SHans Petter Selaskyoption(DISABLE_RDMA "Disable RDMA sniffing support" OFF) 522b00ab754SHans Petter Selasky 523b00ab754SHans Petter Selaskyoption(DISABLE_DAG "Disable Endace DAG card support" OFF) 524b00ab754SHans Petter Selasky 525b00ab754SHans Petter Selaskyoption(DISABLE_SEPTEL "Disable Septel card support" OFF) 52657e22627SCy Schubertset(SEPTEL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../septel" CACHE PATH "Path to directory with include and lib subdirectories for Septel API") 527b00ab754SHans Petter Selasky 528b00ab754SHans Petter Selaskyoption(DISABLE_SNF "Disable Myricom SNF support" OFF) 529b00ab754SHans Petter Selasky 530b00ab754SHans Petter Selaskyoption(DISABLE_TC "Disable Riverbed TurboCap support" OFF) 531b00ab754SHans Petter Selasky 532b00ab754SHans Petter Selasky# 533b00ab754SHans Petter Selasky# Debugging options. 534b00ab754SHans Petter Selasky# 535b00ab754SHans Petter Selaskyoption(BDEBUG "Build optimizer debugging code" OFF) 536b00ab754SHans Petter Selaskyoption(YYDEBUG "Build parser debugging code" OFF) 537b00ab754SHans Petter Selasky 538b00ab754SHans Petter Selasky################################################################### 539b00ab754SHans Petter Selasky# Versioning 540b00ab754SHans Petter Selasky################################################################### 541b00ab754SHans Petter Selasky 542b00ab754SHans Petter Selasky# Get, parse, format and set pcap's version string from [pcap_root]/VERSION 543b00ab754SHans Petter Selasky# for later use. 544b00ab754SHans Petter Selasky 545b00ab754SHans Petter Selasky# Get MAJOR, MINOR, PATCH & SUFFIX 546b00ab754SHans Petter Selaskyfile(STRINGS ${pcap_SOURCE_DIR}/VERSION 547b00ab754SHans Petter Selasky PACKAGE_VERSION 548b00ab754SHans Petter Selasky LIMIT_COUNT 1 # Read only the first line 549b00ab754SHans Petter Selasky) 550b00ab754SHans Petter Selasky 551b00ab754SHans Petter Selasky# Get "just" MAJOR 552b00ab754SHans Petter Selaskystring(REGEX MATCH "^([0-9]+)" PACKAGE_VERSION_MAJOR "${PACKAGE_VERSION}") 553b00ab754SHans Petter Selasky 554b00ab754SHans Petter Selasky# Get MAJOR, MINOR & PATCH 555b00ab754SHans Petter Selaskystring(REGEX MATCH "^([0-9]+.)?([0-9]+.)?([0-9]+)" PACKAGE_VERSION_NOSUFFIX "${PACKAGE_VERSION}") 556b00ab754SHans Petter Selasky 557b00ab754SHans Petter Selaskyif(WIN32) 558b00ab754SHans Petter Selasky # Convert PCAP_VERSION_NOSUFFIX to Windows preferred version format 559b00ab754SHans Petter Selasky string(REPLACE "." "," PACKAGE_VERSION_PREDLL ${PACKAGE_VERSION_NOSUFFIX}) 560b00ab754SHans Petter Selasky 561b00ab754SHans Petter Selasky # Append NANO (used for Windows internal versioning) to PCAP_VERSION_PREDLL 562b00ab754SHans Petter Selasky # 0 means unused. 563b00ab754SHans Petter Selasky set(PACKAGE_VERSION_DLL ${PACKAGE_VERSION_PREDLL},0) 564b00ab754SHans Petter Selaskyendif(WIN32) 565b00ab754SHans Petter Selasky 566b00ab754SHans Petter Selaskyset(PACKAGE_NAME "${LIBRARY_NAME}") 567b00ab754SHans Petter Selaskyset(PACKAGE_STRING "${LIBRARY_NAME} ${PACKAGE_VERSION}") 568b00ab754SHans Petter Selasky 569b00ab754SHans Petter Selasky###################################### 570b00ab754SHans Petter Selasky# Project settings 571b00ab754SHans Petter Selasky###################################### 572b00ab754SHans Petter Selasky 573b00ab754SHans Petter Selaskyinclude_directories( 574b00ab754SHans Petter Selasky ${CMAKE_CURRENT_BINARY_DIR} 575b00ab754SHans Petter Selasky ${pcap_SOURCE_DIR} 576b00ab754SHans Petter Selasky) 577b00ab754SHans Petter Selasky 578b00ab754SHans Petter Selaskyinclude(CheckFunctionExists) 579b00ab754SHans Petter Selaskyinclude(CMakePushCheckState) 58057e22627SCy Schubertinclude(CheckSymbolExists) 581b00ab754SHans Petter Selasky 582b00ab754SHans Petter Selaskyif(WIN32) 583b00ab754SHans Petter Selasky 584b00ab754SHans Petter Selasky if(IS_DIRECTORY ${CMAKE_HOME_DIRECTORY}/../../Common) 585b00ab754SHans Petter Selasky include_directories(${CMAKE_HOME_DIRECTORY}/../../Common) 586b00ab754SHans Petter Selasky endif(IS_DIRECTORY ${CMAKE_HOME_DIRECTORY}/../../Common) 587b00ab754SHans Petter Selasky 588b00ab754SHans Petter Selasky find_package(Packet) 5896f9cba8fSJoseph Mingrone if(Packet_FOUND) 590b00ab754SHans Petter Selasky set(HAVE_PACKET32 TRUE) 5916f9cba8fSJoseph Mingrone include_directories(${Packet_INCLUDE_DIRS}) 592b00ab754SHans Petter Selasky # 593b00ab754SHans Petter Selasky # Check whether we have the NPcap PacketIsLoopbackAdapter() 594b00ab754SHans Petter Selasky # function. 595b00ab754SHans Petter Selasky # 596b00ab754SHans Petter Selasky cmake_push_check_state() 5976f9cba8fSJoseph Mingrone set(CMAKE_REQUIRED_LIBRARIES ${Packet_LIBRARIES}) 598b00ab754SHans Petter Selasky check_function_exists(PacketIsLoopbackAdapter HAVE_PACKET_IS_LOOPBACK_ADAPTER) 5996f9cba8fSJoseph Mingrone check_function_exists(PacketGetTimestampModes HAVE_PACKET_GET_TIMESTAMP_MODES) 600b00ab754SHans Petter Selasky cmake_pop_check_state() 6016f9cba8fSJoseph Mingrone endif(Packet_FOUND) 602b00ab754SHans Petter Selasky 60357e22627SCy Schubert message(STATUS "checking for Npcap's version.h") 6046f9cba8fSJoseph Mingrone check_symbol_exists(WINPCAP_PRODUCT_NAME "${CMAKE_SOURCE_DIR}/../../version.h" HAVE_VERSION_H) 60557e22627SCy Schubert if(HAVE_VERSION_H) 60657e22627SCy Schubert message(STATUS "HAVE version.h") 60757e22627SCy Schubert else(HAVE_VERSION_H) 60857e22627SCy Schubert message(STATUS "MISSING version.h") 60957e22627SCy Schubert endif(HAVE_VERSION_H) 61057e22627SCy Schubert 611b00ab754SHans Petter Selaskyendif(WIN32) 612b00ab754SHans Petter Selasky 613b00ab754SHans Petter Selaskyif(MSVC) 614b00ab754SHans Petter Selasky add_definitions(-D__STDC__) 615b00ab754SHans Petter Selasky add_definitions(-D_CRT_SECURE_NO_WARNINGS) 616b00ab754SHans Petter Selaskyendif(MSVC) 617b00ab754SHans Petter Selasky 618b00ab754SHans Petter Selaskyif(USE_STATIC_RT) 619b00ab754SHans Petter Selasky message(STATUS "Use STATIC runtime") 620b00ab754SHans Petter Selasky if(MSVC) 621b00ab754SHans Petter Selasky foreach(RT_FLAG 622b00ab754SHans Petter Selasky CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE 623*afdbf109SJoseph Mingrone CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO) 624b00ab754SHans Petter Selasky string(REGEX REPLACE "/MD" "/MT" ${RT_FLAG} "${${RT_FLAG}}") 625b00ab754SHans Petter Selasky endforeach(RT_FLAG) 626b00ab754SHans Petter Selasky elseif(MINGW) 627b00ab754SHans Petter Selasky set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc") 628b00ab754SHans Petter Selasky endif() 629b00ab754SHans Petter Selaskyelse (USE_STATIC_RT) 630b00ab754SHans Petter Selasky message(STATUS "Use DYNAMIC runtime") 631b00ab754SHans Petter Selaskyendif(USE_STATIC_RT) 632b00ab754SHans Petter Selasky 633b00ab754SHans Petter Selasky################################################################### 634b00ab754SHans Petter Selasky# Detect available platform features 635b00ab754SHans Petter Selasky################################################################### 636b00ab754SHans Petter Selasky 637b00ab754SHans Petter Selaskyinclude(CheckIncludeFile) 638b00ab754SHans Petter Selaskyinclude(CheckIncludeFiles) 639b00ab754SHans Petter Selaskyinclude(CheckStructHasMember) 640b00ab754SHans Petter Selaskyinclude(CheckTypeSize) 641b00ab754SHans Petter Selasky 642b00ab754SHans Petter Selasky# 64357e22627SCy Schubert# Tests are a bit expensive with Visual Studio on Windows, so, on 64457e22627SCy Schubert# Windows, we skip tests for UN*X-only headers and functions. 64557e22627SCy Schubert# 64657e22627SCy Schubert 64757e22627SCy Schubert# 648b00ab754SHans Petter Selasky# Header files. 649b00ab754SHans Petter Selasky# 650b00ab754SHans Petter Selaskycheck_include_file(inttypes.h HAVE_INTTYPES_H) 651b00ab754SHans Petter Selaskycheck_include_file(stdint.h HAVE_STDINT_H) 652b00ab754SHans Petter Selaskycheck_include_file(unistd.h HAVE_UNISTD_H) 653b00ab754SHans Petter Selaskyif(NOT HAVE_UNISTD_H) 654b00ab754SHans Petter Selasky add_definitions(-DYY_NO_UNISTD_H) 655b00ab754SHans Petter Selaskyendif(NOT HAVE_UNISTD_H) 656b00ab754SHans Petter Selaskycheck_include_file(bitypes.h HAVE_SYS_BITYPES_H) 657b00ab754SHans Petter Selaskyif(NOT WIN32) 658b00ab754SHans Petter Selasky check_include_file(sys/ioccom.h HAVE_SYS_IOCCOM_H) 659b00ab754SHans Petter Selasky check_include_file(sys/sockio.h HAVE_SYS_SOCKIO_H) 660b00ab754SHans Petter Selasky check_include_file(sys/select.h HAVE_SYS_SELECT_H) 661b00ab754SHans Petter Selasky 6626f9cba8fSJoseph Mingrone check_include_file(netpacket/packet.h HAVE_NETPACKET_PACKET_H) 663b00ab754SHans Petter Selasky check_include_file(netinet/if_ether.h HAVE_NETINET_IF_ETHER_H) 664b00ab754SHans Petter Selaskyendif(NOT WIN32) 665b00ab754SHans Petter Selasky 666b00ab754SHans Petter Selasky# 667b00ab754SHans Petter Selasky# Functions. 668b00ab754SHans Petter Selasky# 6696f9cba8fSJoseph Mingrone# First, check for the __atomic_load_n() and __atomic_store_n() 6706f9cba8fSJoseph Mingrone# builtins. 6716f9cba8fSJoseph Mingrone# 6726f9cba8fSJoseph Mingrone# We can't use check_function_exists(), as it tries to declare 6736f9cba8fSJoseph Mingrone# the function, and attempting to declare a compiler builtin 6746f9cba8fSJoseph Mingrone# can produce an error. 6756f9cba8fSJoseph Mingrone# 6766f9cba8fSJoseph Mingrone# We don't use check_symbol_exists(), as it expects a header 6776f9cba8fSJoseph Mingrone# file to be specified to declare the function, but there isn't 6786f9cba8fSJoseph Mingrone# such a header file. 6796f9cba8fSJoseph Mingrone# 6806f9cba8fSJoseph Mingrone# So we use check_c_source_compiles(). 6816f9cba8fSJoseph Mingrone# 6826f9cba8fSJoseph Mingronecheck_c_source_compiles( 6836f9cba8fSJoseph Mingrone"int 6846f9cba8fSJoseph Mingronemain(void) 6856f9cba8fSJoseph Mingrone{ 6866f9cba8fSJoseph Mingrone int i = 17; 6876f9cba8fSJoseph Mingrone return __atomic_load_n(&i, __ATOMIC_RELAXED); 6886f9cba8fSJoseph Mingrone} 6896f9cba8fSJoseph Mingrone" 6906f9cba8fSJoseph Mingrone HAVE___ATOMIC_LOAD_N) 6916f9cba8fSJoseph Mingronecheck_c_source_compiles( 6926f9cba8fSJoseph Mingrone"int 6936f9cba8fSJoseph Mingronemain(void) 6946f9cba8fSJoseph Mingrone{ 6956f9cba8fSJoseph Mingrone int i; 6966f9cba8fSJoseph Mingrone __atomic_store_n(&i, 17, __ATOMIC_RELAXED); 6976f9cba8fSJoseph Mingrone return 0; 6986f9cba8fSJoseph Mingrone} 6996f9cba8fSJoseph Mingrone" 7006f9cba8fSJoseph Mingrone HAVE___ATOMIC_STORE_N) 7016f9cba8fSJoseph Mingrone 7026f9cba8fSJoseph Mingrone# 7036f9cba8fSJoseph Mingrone# Now check for various system functions. 7046f9cba8fSJoseph Mingrone# 705b00ab754SHans Petter Selaskycheck_function_exists(strerror_r HAVE_STRERROR_R) 70657e22627SCy Schubertif(HAVE_STRERROR_R) 70757e22627SCy Schubert # 70857e22627SCy Schubert # We have strerror_r; if we define _GNU_SOURCE, is it a 70957e22627SCy Schubert # POSIX-compliant strerror_r() or a GNU strerror_r()? 71057e22627SCy Schubert # 71157e22627SCy Schubert check_c_source_compiles( 71257e22627SCy Schubert"#define _GNU_SOURCE 71357e22627SCy Schubert#include <string.h> 71457e22627SCy Schubert 71557e22627SCy Schubert/* Define it GNU-style; that will cause an error if it's not GNU-style */ 71657e22627SCy Schubertextern char *strerror_r(int, char *, size_t); 71757e22627SCy Schubert 71857e22627SCy Schubertint 71957e22627SCy Schubertmain(void) 72057e22627SCy Schubert{ 72157e22627SCy Schubert return 0; 72257e22627SCy Schubert} 72357e22627SCy Schubert" 72457e22627SCy Schubert HAVE_GNU_STRERROR_R) 72557e22627SCy Schubert if(NOT HAVE_GNU_STRERROR_R) 72657e22627SCy Schubert set(HAVE_POSIX_STRERROR_R YES) 72757e22627SCy Schubert endif(NOT HAVE_GNU_STRERROR_R) 72857e22627SCy Schubertelse(HAVE_STRERROR_R) 72957e22627SCy Schubert # 7306f9cba8fSJoseph Mingrone # We don't have strerror_r; do we have _wcserror_s? 73157e22627SCy Schubert # 7326f9cba8fSJoseph Mingrone check_function_exists(_wcserror_s HAVE__WCSERROR_S) 73357e22627SCy Schubertendif(HAVE_STRERROR_R) 7346f9cba8fSJoseph Mingrone 7356f9cba8fSJoseph Mingrone# 7366f9cba8fSJoseph Mingrone# Make sure we have vsnprintf() and snprintf(); we require them. 7376f9cba8fSJoseph Mingrone# We use check_symbol_exists(), as they aren't necessarily external 7386f9cba8fSJoseph Mingrone# functions - in Visual Studio, for example, they're inline functions 7396f9cba8fSJoseph Mingrone# calling a common external function. 7406f9cba8fSJoseph Mingrone# 7416f9cba8fSJoseph Mingronecheck_symbol_exists(vsnprintf "stdio.h" HAVE_VSNPRINTF) 7426f9cba8fSJoseph Mingroneif(NOT HAVE_VSNPRINTF) 7436f9cba8fSJoseph Mingrone message(FATAL_ERROR "vsnprintf() is required but wasn't found") 7446f9cba8fSJoseph Mingroneendif(NOT HAVE_VSNPRINTF) 7456f9cba8fSJoseph Mingronecheck_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF) 7466f9cba8fSJoseph Mingroneif(NOT HAVE_SNPRINTF) 7476f9cba8fSJoseph Mingrone message(FATAL_ERROR "snprintf() is required but wasn't found") 7486f9cba8fSJoseph Mingroneendif() 7496f9cba8fSJoseph Mingrone 750b00ab754SHans Petter Selaskycheck_function_exists(strlcpy HAVE_STRLCPY) 751b00ab754SHans Petter Selaskycheck_function_exists(strlcat HAVE_STRLCAT) 75257e22627SCy Schubertcheck_function_exists(asprintf HAVE_ASPRINTF) 75357e22627SCy Schubertcheck_function_exists(vasprintf HAVE_VASPRINTF) 754b00ab754SHans Petter Selaskycheck_function_exists(strtok_r HAVE_STRTOK_R) 75557e22627SCy Schubertif(NOT WIN32) 75657e22627SCy Schubert check_function_exists(vsyslog HAVE_VSYSLOG) 75757e22627SCy Schubertendif() 758b00ab754SHans Petter Selasky 759b00ab754SHans Petter Selasky# 760*afdbf109SJoseph Mingrone# Look for various networking-related libraries that we may need. 761b00ab754SHans Petter Selasky# 762*afdbf109SJoseph Mingrone# We need getaddrinfo() to translate host names in filters to IP 763*afdbf109SJoseph Mingrone# addresses. We use getaddrinfo() because we want a portable 764*afdbf109SJoseph Mingrone# thread-safe way of getting information for a host name or port; 765*afdbf109SJoseph Mingrone# there exist _r versions of gethostbyname() and getservbyname() on 766*afdbf109SJoseph Mingrone# some platforms, but not on all platforms. 767b00ab754SHans Petter Selasky# 768*afdbf109SJoseph Mingrone# We may also need socket() and other socket functions to support: 769b00ab754SHans Petter Selasky# 770*afdbf109SJoseph Mingrone# Local packet capture with capture mechanisms that use sockets. 771b00ab754SHans Petter Selasky# 772*afdbf109SJoseph Mingrone# Local capture device enumeration if a socket call is needed to 773*afdbf109SJoseph Mingrone# enumerate devices or get device attributes. 774*afdbf109SJoseph Mingrone# 775*afdbf109SJoseph Mingrone# Packet capture from services that put captured packets on the 776*afdbf109SJoseph Mingrone# network, such as rpcap servers. 777*afdbf109SJoseph Mingrone# 778*afdbf109SJoseph Mingrone# We may also need getnameinfo() for packet capture from services 779*afdbf109SJoseph Mingrone# that put packets on the network. 780b00ab754SHans Petter Selasky# 781b00ab754SHans Petter Selaskyset(PCAP_LINK_LIBRARIES "") 7826f9cba8fSJoseph Mingroneset(LIBS "") 7836f9cba8fSJoseph Mingroneset(LIBS_STATIC "") 7846f9cba8fSJoseph Mingroneset(REQUIRES_PRIVATE "") 7856f9cba8fSJoseph Mingroneset(LIBS_PRIVATE "") 786b00ab754SHans Petter Selaskyinclude(CheckLibraryExists) 787b00ab754SHans Petter Selaskyif(WIN32) 788b00ab754SHans Petter Selasky # 789*afdbf109SJoseph Mingrone # Windows. 790*afdbf109SJoseph Mingrone # 791b00ab754SHans Petter Selasky # We need winsock2.h and ws2tcpip.h. 792b00ab754SHans Petter Selasky # 793*afdbf109SJoseph Mingrone # On Windows, getaddrinfo() is in the ws2_32 library. 794*afdbf109SJoseph Mingrone # 795b00ab754SHans Petter Selasky cmake_push_check_state() 796b00ab754SHans Petter Selasky set(CMAKE_REQUIRED_LIBRARIES ws2_32) 797b00ab754SHans Petter Selasky check_symbol_exists(getaddrinfo "winsock2.h;ws2tcpip.h" LIBWS2_32_HAS_GETADDRINFO) 798b00ab754SHans Petter Selasky cmake_pop_check_state() 799b00ab754SHans Petter Selasky if(LIBWS2_32_HAS_GETADDRINFO) 800b00ab754SHans Petter Selasky set(PCAP_LINK_LIBRARIES ws2_32 ${PCAP_LINK_LIBRARIES}) 801b00ab754SHans Petter Selasky else(LIBWS2_32_HAS_GETADDRINFO) 802b00ab754SHans Petter Selasky message(FATAL_ERROR "getaddrinfo is required, but wasn't found") 803b00ab754SHans Petter Selasky endif(LIBWS2_32_HAS_GETADDRINFO) 804b00ab754SHans Petter Selaskyelse(WIN32) 805b00ab754SHans Petter Selasky # 806*afdbf109SJoseph Mingrone # UN*X. 807*afdbf109SJoseph Mingrone # 808*afdbf109SJoseph Mingrone # Most UN*Xes have getaddrinfo(), and the other routines we may 809*afdbf109SJoseph Mingrone # need, in the default searched libraries (e.g., libc). 810*afdbf109SJoseph Mingrone # Check there first. 811*afdbf109SJoseph Mingrone # 812*afdbf109SJoseph Mingrone # NOTE: if you hand check_library_exists as its last argument a 813*afdbf109SJoseph Mingrone # variable that's been set, it skips the test, so we need different 814*afdbf109SJoseph Mingrone # variables for different libraries. 815b00ab754SHans Petter Selasky # 816b00ab754SHans Petter Selasky check_function_exists(getaddrinfo STDLIBS_HAVE_GETADDRINFO) 817b00ab754SHans Petter Selasky if(NOT STDLIBS_HAVE_GETADDRINFO) 818b00ab754SHans Petter Selasky # 819b00ab754SHans Petter Selasky # Not found in the standard system libraries. 820*afdbf109SJoseph Mingrone # 821*afdbf109SJoseph Mingrone # In some versions of Solaris, we need to link with libsocket 822*afdbf109SJoseph Mingrone # and libnsl, so check in libsocket and also link with liblnsl 823*afdbf109SJoseph Mingrone # when doing this test. 824*afdbf109SJoseph Mingrone # 825*afdbf109SJoseph Mingrone # Linking with libsocket and libnsl will find all the routines 826*afdbf109SJoseph Mingrone # we need. 827b00ab754SHans Petter Selasky # 828b00ab754SHans Petter Selasky cmake_push_check_state() 829b00ab754SHans Petter Selasky set(CMAKE_REQUIRED_LIBRARIES nsl) 830b00ab754SHans Petter Selasky check_library_exists(socket getaddrinfo "" LIBSOCKET_HAS_GETADDRINFO) 831b00ab754SHans Petter Selasky cmake_pop_check_state() 832b00ab754SHans Petter Selasky if(LIBSOCKET_HAS_GETADDRINFO) 833b00ab754SHans Petter Selasky # 834b00ab754SHans Petter Selasky # OK, we found it in libsocket. 835b00ab754SHans Petter Selasky # 836b00ab754SHans Petter Selasky set(PCAP_LINK_LIBRARIES socket nsl ${PCAP_LINK_LIBRARIES}) 8376f9cba8fSJoseph Mingrone set(LIBS "-lsocket -lnsl ${LIBS}") 8386f9cba8fSJoseph Mingrone set(LIBS_STATIC "-lsocket -lnsl ${LIBS_STATIC}") 8396f9cba8fSJoseph Mingrone set(LIBS_PRIVATE "-lsocket -lnsl ${LIBS_PRIVATE}") 840b00ab754SHans Petter Selasky else(LIBSOCKET_HAS_GETADDRINFO) 841*afdbf109SJoseph Mingrone # 842*afdbf109SJoseph Mingrone # Not found in libsocket; test for it in libnetwork, which 843*afdbf109SJoseph Mingrone # is where it is in Haiku. 844*afdbf109SJoseph Mingrone # 845*afdbf109SJoseph Mingrone # Linking with libnetwork will find all the routines we 846*afdbf109SJoseph Mingrone # need. 847*afdbf109SJoseph Mingrone # 8486f9cba8fSJoseph Mingrone check_library_exists(network getaddrinfo "" LIBNETWORK_HAS_GETADDRINFO) 8496f9cba8fSJoseph Mingrone if(LIBNETWORK_HAS_GETADDRINFO) 8506f9cba8fSJoseph Mingrone # 851*afdbf109SJoseph Mingrone # OK, we found it in libnetwork. 8526f9cba8fSJoseph Mingrone # 8536f9cba8fSJoseph Mingrone set(PCAP_LINK_LIBRARIES network ${PCAP_LINK_LIBRARIES}) 8546f9cba8fSJoseph Mingrone set(LIBS "-lnetwork ${LIBS}") 8556f9cba8fSJoseph Mingrone set(LIBS_STATIC "-lnetwork ${LIBS_STATIC}") 8566f9cba8fSJoseph Mingrone set(LIBS_PRIVATE "-lnetwork ${LIBS_PRIVATE}") 8576f9cba8fSJoseph Mingrone else(LIBNETWORK_HAS_GETADDRINFO) 858b00ab754SHans Petter Selasky # 859b00ab754SHans Petter Selasky # We didn't find it. 860b00ab754SHans Petter Selasky # 861b00ab754SHans Petter Selasky message(FATAL_ERROR "getaddrinfo is required, but wasn't found") 8626f9cba8fSJoseph Mingrone endif(LIBNETWORK_HAS_GETADDRINFO) 863b00ab754SHans Petter Selasky endif(LIBSOCKET_HAS_GETADDRINFO) 864b00ab754SHans Petter Selasky 865b00ab754SHans Petter Selasky # 866*afdbf109SJoseph Mingrone # We require a version of recvmsg() that conforms to the Single 867*afdbf109SJoseph Mingrone # UNIX Specification, so that we can check whether a datagram 868*afdbf109SJoseph Mingrone # received with recvmsg() was truncated when received due to the 869*afdbf109SJoseph Mingrone # buffer being too small. 870*afdbf109SJoseph Mingrone # 871*afdbf109SJoseph Mingrone # On most systems, the version of recvmsg() in the libraries 872*afdbf109SJoseph Mingrone # found above conforms to the SUS. 873*afdbf109SJoseph Mingrone # 874*afdbf109SJoseph Mingrone # On at least some versions of Solaris, it does not conform to 875*afdbf109SJoseph Mingrone # the SUS, and we need the version in libxnet, which does 876*afdbf109SJoseph Mingrone # conform. 877*afdbf109SJoseph Mingrone # 878*afdbf109SJoseph Mingrone # Check whether libxnet exists and has a version of recvmsg(); 879*afdbf109SJoseph Mingrone # if it does, link with libxnet before we link with libsocket, 880*afdbf109SJoseph Mingrone # to get that version. 881*afdbf109SJoseph Mingrone # 882*afdbf109SJoseph Mingrone # This test also links with libsocket and libnsl. 883b00ab754SHans Petter Selasky # 884b00ab754SHans Petter Selasky cmake_push_check_state() 885b00ab754SHans Petter Selasky set(CMAKE_REQUIRED_LIBRARIES socket nsl) 886b00ab754SHans Petter Selasky check_library_exists(xnet recvmsg "" LIBXNET_HAS_RECVMSG) 887b00ab754SHans Petter Selasky cmake_pop_check_state() 888b00ab754SHans Petter Selasky if(LIBXNET_HAS_RECVMSG) 889b00ab754SHans Petter Selasky # 890*afdbf109SJoseph Mingrone # libxnet has recvmsg(); link with it as well. 891b00ab754SHans Petter Selasky # 892b00ab754SHans Petter Selasky set(PCAP_LINK_LIBRARIES xnet ${PCAP_LINK_LIBRARIES}) 8936f9cba8fSJoseph Mingrone set(LIBSC "-lxnet ${LIBS_LIBS}") 8946f9cba8fSJoseph Mingrone set(LIBS_STATIC "-lxnet ${LIBS_STATIC}") 8956f9cba8fSJoseph Mingrone set(LIBS_PRIVATE "-lxnet ${LIBS_PRIVATE}") 896b00ab754SHans Petter Selasky endif(LIBXNET_HAS_RECVMSG) 897b00ab754SHans Petter Selasky endif(NOT STDLIBS_HAVE_GETADDRINFO) 898b00ab754SHans Petter Selasky 899*afdbf109SJoseph Mingrone # 900*afdbf109SJoseph Mingrone # DLPI needs putmsg under HP-UX, so test for -lstr while we're at it. 901*afdbf109SJoseph Mingrone # 902b00ab754SHans Petter Selasky check_function_exists(putmsg STDLIBS_HAVE_PUTMSG) 903b00ab754SHans Petter Selasky if(NOT STDLIBS_HAVE_PUTMSG) 904b00ab754SHans Petter Selasky check_library_exists(str putmsg "" LIBSTR_HAS_PUTMSG) 905b00ab754SHans Petter Selasky if(LIBSTR_HAS_PUTMSG) 906b00ab754SHans Petter Selasky set(PCAP_LINK_LIBRARIES str ${PCAP_LINK_LIBRARIES}) 9076f9cba8fSJoseph Mingrone set(LIBS "-lstr ${LIBS}") 9086f9cba8fSJoseph Mingrone set(LIBS_STATIC "-lstr ${LIBS_STATIC}") 9096f9cba8fSJoseph Mingrone set(LIBS_PRIVATE "-lstr ${LIBS_PRIVATE}") 910b00ab754SHans Petter Selasky endif(LIBSTR_HAS_PUTMSG) 911b00ab754SHans Petter Selasky endif(NOT STDLIBS_HAVE_PUTMSG) 9126f9cba8fSJoseph Mingrone 9136f9cba8fSJoseph Mingrone # Haiku has getpass in libbsd 9146f9cba8fSJoseph Mingrone check_function_exists(getpass STDLIBS_HAVE_GETPASS) 9156f9cba8fSJoseph Mingrone if(NOT STDLIBS_HAVE_GETPASS) 9166f9cba8fSJoseph Mingrone check_library_exists(bsd getpass "" LIBBSD_HAS_GETPASS) 9176f9cba8fSJoseph Mingrone if(LIBBSD_HAS_GETPASS) 9186f9cba8fSJoseph Mingrone set(PCAP_LINK_LIBRARIES bsd ${PCAP_LINK_LIBRARIES}) 9196f9cba8fSJoseph Mingrone endif(LIBBSD_HAS_GETPASS) 9206f9cba8fSJoseph Mingrone endif(NOT STDLIBS_HAVE_GETPASS) 921b00ab754SHans Petter Selaskyendif(WIN32) 922b00ab754SHans Petter Selasky 923b00ab754SHans Petter Selasky# 924b00ab754SHans Petter Selasky# Check for reentrant versions of getnetbyname_r(), as provided by 925b00ab754SHans Petter Selasky# Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!). 926b00ab754SHans Petter Selasky# If we don't find one, we just use getnetbyname(), which uses 927b00ab754SHans Petter Selasky# thread-specific data on many platforms, but doesn't use it on 928b00ab754SHans Petter Selasky# NetBSD or OpenBSD, and may not use it on older versions of other 929b00ab754SHans Petter Selasky# platforms. 930b00ab754SHans Petter Selasky# 931b00ab754SHans Petter Selasky# Only do the check if we have a declaration of getnetbyname_r(); 932b00ab754SHans Petter Selasky# without it, we can't check which API it has. (We assume that 933b00ab754SHans Petter Selasky# if there's a declaration, it has a prototype, so that the API 934b00ab754SHans Petter Selasky# can be checked.) 935b00ab754SHans Petter Selasky# 936b00ab754SHans Petter Selaskycmake_push_check_state() 937b00ab754SHans Petter Selaskyset(CMAKE_REQUIRED_LIBRARIES ${PCAP_LINK_LIBRARIES}) 938b00ab754SHans Petter Selaskycheck_symbol_exists(getnetbyname_r netdb.h NETDB_H_DECLARES_GETNETBYNAME_R) 939b00ab754SHans Petter Selaskyif(NETDB_H_DECLARES_GETNETBYNAME_R) 940b00ab754SHans Petter Selasky check_c_source_compiles( 941b00ab754SHans Petter Selasky"#include <netdb.h> 942b00ab754SHans Petter Selasky 943b00ab754SHans Petter Selaskyint 944b00ab754SHans Petter Selaskymain(void) 945b00ab754SHans Petter Selasky{ 946b00ab754SHans Petter Selasky struct netent netent_buf; 947b00ab754SHans Petter Selasky char buf[1024]; 948b00ab754SHans Petter Selasky struct netent *resultp; 949b00ab754SHans Petter Selasky int h_errnoval; 950b00ab754SHans Petter Selasky 951b00ab754SHans Petter Selasky return getnetbyname_r((const char *)0, &netent_buf, buf, sizeof buf, &resultp, &h_errnoval); 952b00ab754SHans Petter Selasky} 953b00ab754SHans Petter Selasky" 954b00ab754SHans Petter Selasky HAVE_LINUX_GETNETBYNAME_R) 955b00ab754SHans Petter Selasky if(NOT HAVE_LINUX_GETNETBYNAME_R) 956b00ab754SHans Petter Selasky check_c_source_compiles( 957b00ab754SHans Petter Selasky"#include <netdb.h> 958b00ab754SHans Petter Selasky 959b00ab754SHans Petter Selaskyint 960b00ab754SHans Petter Selaskymain(void) 961b00ab754SHans Petter Selasky{ 962b00ab754SHans Petter Selasky struct netent netent_buf; 963b00ab754SHans Petter Selasky char buf[1024]; 964b00ab754SHans Petter Selasky 965b00ab754SHans Petter Selasky return getnetbyname_r((const char *)0, &netent_buf, buf, (int)sizeof buf) != NULL; 966b00ab754SHans Petter Selasky} 967b00ab754SHans Petter Selasky" 968b00ab754SHans Petter Selasky HAVE_SOLARIS_IRIX_GETNETBYNAME_R) 969b00ab754SHans Petter Selasky if(NOT HAVE_SOLARIS_IRIX_GETNETBYNAME_R) 970b00ab754SHans Petter Selasky check_c_source_compiles( 971b00ab754SHans Petter Selasky"#include <netdb.h> 972b00ab754SHans Petter Selasky 973b00ab754SHans Petter Selaskyint 974b00ab754SHans Petter Selaskymain(void) 975b00ab754SHans Petter Selasky{ 976b00ab754SHans Petter Selasky struct netent netent_buf; 977b00ab754SHans Petter Selasky struct netent_data net_data; 978b00ab754SHans Petter Selasky 979b00ab754SHans Petter Selasky return getnetbyname_r((const char *)0, &netent_buf, &net_data); 980b00ab754SHans Petter Selasky} 981b00ab754SHans Petter Selasky" 982b00ab754SHans Petter Selasky HAVE_AIX_GETNETBYNAME_R) 983b00ab754SHans Petter Selasky endif(NOT HAVE_SOLARIS_IRIX_GETNETBYNAME_R) 984b00ab754SHans Petter Selasky endif(NOT HAVE_LINUX_GETNETBYNAME_R) 985b00ab754SHans Petter Selaskyendif(NETDB_H_DECLARES_GETNETBYNAME_R) 986b00ab754SHans Petter Selaskycmake_pop_check_state() 987b00ab754SHans Petter Selasky 988b00ab754SHans Petter Selasky# 989b00ab754SHans Petter Selasky# Check for reentrant versions of getprotobyname_r(), as provided by 990b00ab754SHans Petter Selasky# Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!). 991b00ab754SHans Petter Selasky# If we don't find one, we just use getprotobyname(), which uses 992b00ab754SHans Petter Selasky# thread-specific data on many platforms, but doesn't use it on 993b00ab754SHans Petter Selasky# NetBSD or OpenBSD, and may not use it on older versions of other 994b00ab754SHans Petter Selasky# platforms. 995b00ab754SHans Petter Selasky# 996b00ab754SHans Petter Selasky# Only do the check if we have a declaration of getprotobyname_r(); 997b00ab754SHans Petter Selasky# without it, we can't check which API it has. (We assume that 998b00ab754SHans Petter Selasky# if there's a declaration, it has a prototype, so that the API 999b00ab754SHans Petter Selasky# can be checked.) 1000b00ab754SHans Petter Selasky# 1001b00ab754SHans Petter Selaskycmake_push_check_state() 1002b00ab754SHans Petter Selaskyset(CMAKE_REQUIRED_LIBRARIES ${PCAP_LINK_LIBRARIES}) 1003b00ab754SHans Petter Selaskycheck_symbol_exists(getprotobyname_r netdb.h NETDB_H_DECLARES_GETPROTOBYNAME_R) 1004b00ab754SHans Petter Selaskyif(NETDB_H_DECLARES_GETPROTOBYNAME_R) 1005b00ab754SHans Petter Selasky check_c_source_compiles( 1006b00ab754SHans Petter Selasky"#include <netdb.h> 1007b00ab754SHans Petter Selasky 1008b00ab754SHans Petter Selaskyint 1009b00ab754SHans Petter Selaskymain(void) 1010b00ab754SHans Petter Selasky{ 1011b00ab754SHans Petter Selasky struct protoent protoent_buf; 1012b00ab754SHans Petter Selasky char buf[1024]; 1013b00ab754SHans Petter Selasky struct protoent *resultp; 1014b00ab754SHans Petter Selasky 1015b00ab754SHans Petter Selasky return getprotobyname_r((const char *)0, &protoent_buf, buf, sizeof buf, &resultp); 1016b00ab754SHans Petter Selasky} 1017b00ab754SHans Petter Selasky" 1018b00ab754SHans Petter Selasky HAVE_LINUX_GETPROTOBYNAME_R) 1019b00ab754SHans Petter Selasky if(NOT HAVE_LINUX_GETPROTOBYNAME_R) 1020b00ab754SHans Petter Selasky check_c_source_compiles( 1021b00ab754SHans Petter Selasky"#include <netdb.h> 1022b00ab754SHans Petter Selasky 1023b00ab754SHans Petter Selaskyint 1024b00ab754SHans Petter Selaskymain(void) 1025b00ab754SHans Petter Selasky{ 1026b00ab754SHans Petter Selasky struct protoent protoent_buf; 1027b00ab754SHans Petter Selasky char buf[1024]; 1028b00ab754SHans Petter Selasky 1029b00ab754SHans Petter Selasky return getprotobyname_r((const char *)0, &protoent_buf, buf, (int)sizeof buf) != NULL; 1030b00ab754SHans Petter Selasky} 1031b00ab754SHans Petter Selasky" 1032b00ab754SHans Petter Selasky HAVE_SOLARIS_IRIX_GETPROTOBYNAME_R) 1033b00ab754SHans Petter Selasky if(NOT HAVE_SOLARIS_IRIX_GETPROTOBYNAME_R) 1034b00ab754SHans Petter Selasky check_c_source_compiles( 1035b00ab754SHans Petter Selasky"#include <netdb.h> 1036b00ab754SHans Petter Selasky 1037b00ab754SHans Petter Selaskyint 1038b00ab754SHans Petter Selaskymain(void) 1039b00ab754SHans Petter Selasky{ 1040b00ab754SHans Petter Selasky struct protoent protoent_buf; 1041b00ab754SHans Petter Selasky struct protoent_data proto_data; 1042b00ab754SHans Petter Selasky 1043b00ab754SHans Petter Selasky return getprotobyname_r((const char *)0, &protoent_buf, &proto_data); 1044b00ab754SHans Petter Selasky} 1045b00ab754SHans Petter Selasky" 1046b00ab754SHans Petter Selasky HAVE_AIX_GETPROTOBYNAME_R) 1047b00ab754SHans Petter Selasky endif(NOT HAVE_SOLARIS_IRIX_GETPROTOBYNAME_R) 1048b00ab754SHans Petter Selasky endif(NOT HAVE_LINUX_GETPROTOBYNAME_R) 1049b00ab754SHans Petter Selaskyendif(NETDB_H_DECLARES_GETPROTOBYNAME_R) 1050b00ab754SHans Petter Selaskycmake_pop_check_state() 1051b00ab754SHans Petter Selasky 1052b00ab754SHans Petter Selasky# 1053b00ab754SHans Petter Selasky# Data types. 1054b00ab754SHans Petter Selasky# 1055b00ab754SHans Petter Selasky# XXX - there's no check_type() macro that's like check_type_size() 1056b00ab754SHans Petter Selasky# except that it only checks for the existence of the structure type, 1057b00ab754SHans Petter Selasky# so we use check_type_size() and ignore the size. 1058b00ab754SHans Petter Selasky# 1059b00ab754SHans Petter Selaskycmake_push_check_state() 1060b00ab754SHans Petter Selaskyif(WIN32) 1061b00ab754SHans Petter Selasky set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h) 1062b00ab754SHans Petter Selaskyelse(WIN32) 1063b00ab754SHans Petter Selasky set(CMAKE_EXTRA_INCLUDE_FILES unistd.h sys/socket.h) 1064b00ab754SHans Petter Selaskyendif(WIN32) 1065b00ab754SHans Petter Selaskycheck_type_size("struct sockaddr_storage" STRUCT_SOCKADDR_STORAGE) 1066b00ab754SHans Petter Selaskycheck_type_size("socklen_t" SOCKLEN_T) 1067b00ab754SHans Petter Selaskycmake_pop_check_state() 1068b00ab754SHans Petter Selasky 1069b00ab754SHans Petter Selasky# 1070b00ab754SHans Petter Selasky# Structure fields. 1071b00ab754SHans Petter Selasky# 1072b00ab754SHans Petter Selaskyif(WIN32) 1073b00ab754SHans Petter Selasky check_struct_has_member("struct sockaddr" sa_len winsock2.h HAVE_STRUCT_SOCKADDR_SA_LEN) 1074b00ab754SHans Petter Selaskyelse(WIN32) 1075b00ab754SHans Petter Selasky check_struct_has_member("struct sockaddr" sa_len sys/socket.h HAVE_STRUCT_SOCKADDR_SA_LEN) 1076b00ab754SHans Petter Selaskyendif(WIN32) 1077b00ab754SHans Petter Selasky 1078b00ab754SHans Petter Selasky# 1079b00ab754SHans Petter Selasky# Do we have ffs(), and is it declared in <strings.h>? 1080b00ab754SHans Petter Selasky# 1081b00ab754SHans Petter Selaskycheck_function_exists(ffs HAVE_FFS) 1082b00ab754SHans Petter Selaskyif(HAVE_FFS) 1083b00ab754SHans Petter Selasky # 1084b00ab754SHans Petter Selasky # OK, we have ffs(). Is it declared in <strings.h>? 1085b00ab754SHans Petter Selasky # 1086b00ab754SHans Petter Selasky # This test fails if we don't have <strings.h> or if we do 1087b00ab754SHans Petter Selasky # but it doesn't declare ffs(). 1088b00ab754SHans Petter Selasky # 1089b00ab754SHans Petter Selasky check_symbol_exists(ffs strings.h STRINGS_H_DECLARES_FFS) 1090b00ab754SHans Petter Selaskyendif() 1091b00ab754SHans Petter Selasky 1092b00ab754SHans Petter Selasky# 1093b00ab754SHans Petter Selasky# This requires the libraries that we require, as ether_hostton might be 1094b00ab754SHans Petter Selasky# in one of those libraries. That means we have to do this after 1095b00ab754SHans Petter Selasky# we check for those libraries. 1096b00ab754SHans Petter Selasky# 1097b00ab754SHans Petter Selasky# You are in a twisty little maze of UN*Xes, all different. 1098b00ab754SHans Petter Selasky# Some might not have ether_hostton(). 1099b00ab754SHans Petter Selasky# Some might have it and declare it in <net/ethernet.h>. 1100b00ab754SHans Petter Selasky# Some might have it and declare it in <netinet/ether.h> 1101b00ab754SHans Petter Selasky# Some might have it and declare it in <sys/ethernet.h>. 1102b00ab754SHans Petter Selasky# Some might have it and declare it in <arpa/inet.h>. 1103b00ab754SHans Petter Selasky# Some might have it and declare it in <netinet/if_ether.h>. 1104b00ab754SHans Petter Selasky# Some might have it and not declare it in any header file. 1105b00ab754SHans Petter Selasky# 1106b00ab754SHans Petter Selasky# Before you is a C compiler. 1107b00ab754SHans Petter Selasky# 1108b00ab754SHans Petter Selaskycmake_push_check_state() 1109b00ab754SHans Petter Selaskyset(CMAKE_REQUIRED_LIBRARIES ${PCAP_LINK_LIBRARIES}) 1110b00ab754SHans Petter Selaskycheck_function_exists(ether_hostton HAVE_ETHER_HOSTTON) 1111b00ab754SHans Petter Selaskyif(HAVE_ETHER_HOSTTON) 1112b00ab754SHans Petter Selasky # 1113b00ab754SHans Petter Selasky # OK, we have ether_hostton(). Is it declared in <net/ethernet.h>? 1114b00ab754SHans Petter Selasky # 1115b00ab754SHans Petter Selasky # This test fails if we don't have <net/ethernet.h> or if we do 1116b00ab754SHans Petter Selasky # but it doesn't declare ether_hostton(). 1117b00ab754SHans Petter Selasky # 1118b00ab754SHans Petter Selasky check_symbol_exists(ether_hostton net/ethernet.h NET_ETHERNET_H_DECLARES_ETHER_HOSTTON) 1119b00ab754SHans Petter Selasky if(NET_ETHERNET_H_DECLARES_ETHER_HOSTTON) 1120b00ab754SHans Petter Selasky # 1121b00ab754SHans Petter Selasky # Yes - we have it declared. 1122b00ab754SHans Petter Selasky # 1123b00ab754SHans Petter Selasky set(HAVE_DECL_ETHER_HOSTTON TRUE) 1124b00ab754SHans Petter Selasky endif() 1125b00ab754SHans Petter Selasky # 1126b00ab754SHans Petter Selasky # Did that succeed? 1127b00ab754SHans Petter Selasky # 1128b00ab754SHans Petter Selasky if(NOT HAVE_DECL_ETHER_HOSTTON) 1129b00ab754SHans Petter Selasky # 1130b00ab754SHans Petter Selasky # No - how about <netinet/ether.h>, as on Linux? 1131b00ab754SHans Petter Selasky # 1132b00ab754SHans Petter Selasky # This test fails if we don't have <netinet/ether.h> 1133b00ab754SHans Petter Selasky # or if we do but it doesn't declare ether_hostton(). 1134b00ab754SHans Petter Selasky # 1135b00ab754SHans Petter Selasky check_symbol_exists(ether_hostton netinet/ether.h NETINET_ETHER_H_DECLARES_ETHER_HOSTTON) 1136b00ab754SHans Petter Selasky if(NETINET_ETHER_H_DECLARES_ETHER_HOSTTON) 1137b00ab754SHans Petter Selasky # 1138b00ab754SHans Petter Selasky # Yes - we have it declared. 1139b00ab754SHans Petter Selasky # 1140b00ab754SHans Petter Selasky set(HAVE_DECL_ETHER_HOSTTON TRUE) 1141b00ab754SHans Petter Selasky endif() 1142b00ab754SHans Petter Selasky endif() 1143b00ab754SHans Petter Selasky # 1144b00ab754SHans Petter Selasky # Did that succeed? 1145b00ab754SHans Petter Selasky # 1146b00ab754SHans Petter Selasky if(NOT HAVE_DECL_ETHER_HOSTTON) 1147b00ab754SHans Petter Selasky # 1148b00ab754SHans Petter Selasky # No - how about <sys/ethernet.h>, as on Solaris 10 and later? 1149b00ab754SHans Petter Selasky # 1150b00ab754SHans Petter Selasky # This test fails if we don't have <sys/ethernet.h> 1151b00ab754SHans Petter Selasky # or if we do but it doesn't declare ether_hostton(). 1152b00ab754SHans Petter Selasky # 1153b00ab754SHans Petter Selasky check_symbol_exists(ether_hostton sys/ethernet.h SYS_ETHERNET_H_DECLARES_ETHER_HOSTTON) 1154b00ab754SHans Petter Selasky if(SYS_ETHERNET_H_DECLARES_ETHER_HOSTTON) 1155b00ab754SHans Petter Selasky # 1156b00ab754SHans Petter Selasky # Yes - we have it declared. 1157b00ab754SHans Petter Selasky # 1158b00ab754SHans Petter Selasky set(HAVE_DECL_ETHER_HOSTTON TRUE) 1159b00ab754SHans Petter Selasky endif() 1160b00ab754SHans Petter Selasky endif() 1161b00ab754SHans Petter Selasky # 1162b00ab754SHans Petter Selasky # Did that succeed? 1163b00ab754SHans Petter Selasky # 1164b00ab754SHans Petter Selasky if(NOT HAVE_DECL_ETHER_HOSTTON) 1165b00ab754SHans Petter Selasky # 1166b00ab754SHans Petter Selasky # No, how about <arpa/inet.h>, as on AIX? 1167b00ab754SHans Petter Selasky # 1168b00ab754SHans Petter Selasky # This test fails if we don't have <arpa/inet.h> 1169b00ab754SHans Petter Selasky # or if we do but it doesn't declare ether_hostton(). 1170b00ab754SHans Petter Selasky # 1171b00ab754SHans Petter Selasky check_symbol_exists(ether_hostton arpa/inet.h ARPA_INET_H_DECLARES_ETHER_HOSTTON) 1172b00ab754SHans Petter Selasky if(ARPA_INET_H_DECLARES_ETHER_HOSTTON) 1173b00ab754SHans Petter Selasky # 1174b00ab754SHans Petter Selasky # Yes - we have it declared. 1175b00ab754SHans Petter Selasky # 1176b00ab754SHans Petter Selasky set(HAVE_DECL_ETHER_HOSTTON TRUE) 1177b00ab754SHans Petter Selasky endif() 1178b00ab754SHans Petter Selasky endif() 1179b00ab754SHans Petter Selasky # 1180b00ab754SHans Petter Selasky # Did that succeed? 1181b00ab754SHans Petter Selasky # 1182b00ab754SHans Petter Selasky if(NOT HAVE_DECL_ETHER_HOSTTON) 1183b00ab754SHans Petter Selasky # 1184b00ab754SHans Petter Selasky # No, how about <netinet/if_ether.h>? 1185b00ab754SHans Petter Selasky # On some platforms, it requires <net/if.h> and 1186b00ab754SHans Petter Selasky # <netinet/in.h>, and we always include it with 1187b00ab754SHans Petter Selasky # both of them, so test it with both of them. 1188b00ab754SHans Petter Selasky # 1189b00ab754SHans Petter Selasky # This test fails if we don't have <netinet/if_ether.h> 1190b00ab754SHans Petter Selasky # and the headers we include before it, or if we do but 1191b00ab754SHans Petter Selasky # <netinet/if_ether.h> doesn't declare ether_hostton(). 1192b00ab754SHans Petter Selasky # 1193b00ab754SHans Petter Selasky check_symbol_exists(ether_hostton "sys/types.h;sys/socket.h;net/if.h;netinet/in.h;netinet/if_ether.h" NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON) 1194b00ab754SHans Petter Selasky if(NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON) 1195b00ab754SHans Petter Selasky # 1196b00ab754SHans Petter Selasky # Yes - we have it declared. 1197b00ab754SHans Petter Selasky # 1198b00ab754SHans Petter Selasky set(HAVE_DECL_ETHER_HOSTTON TRUE) 1199b00ab754SHans Petter Selasky endif() 1200b00ab754SHans Petter Selasky endif() 1201b00ab754SHans Petter Selasky # 1202b00ab754SHans Petter Selasky # After all that, is ether_hostton() declared? 1203b00ab754SHans Petter Selasky # 1204b00ab754SHans Petter Selasky if(NOT HAVE_DECL_ETHER_HOSTTON) 1205b00ab754SHans Petter Selasky # 1206b00ab754SHans Petter Selasky # No, we'll have to declare it ourselves. 1207b00ab754SHans Petter Selasky # Do we have "struct ether_addr" if we include <netinet/if_ether.h>? 1208b00ab754SHans Petter Selasky # 1209b00ab754SHans Petter Selasky # XXX - there's no check_type() macro that's like check_type_size() 1210b00ab754SHans Petter Selasky # except that it only checks for the existence of the structure type, 1211b00ab754SHans Petter Selasky # so we use check_type_size() and ignore the size. 1212b00ab754SHans Petter Selasky # 1213b00ab754SHans Petter Selasky cmake_push_check_state() 1214b00ab754SHans Petter Selasky set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h sys/socket.h net/if.h netinet/in.h netinet/if_ether.h) 1215b00ab754SHans Petter Selasky check_type_size("struct ether_addr" STRUCT_ETHER_ADDR) 1216b00ab754SHans Petter Selasky cmake_pop_check_state() 1217b00ab754SHans Petter Selasky endif() 1218b00ab754SHans Petter Selaskyendif() 1219b00ab754SHans Petter Selaskycmake_pop_check_state() 1220b00ab754SHans Petter Selasky 1221b00ab754SHans Petter Selasky# 1222b00ab754SHans Petter Selasky# Large file support on UN*X, a/k/a LFS. 1223b00ab754SHans Petter Selasky# 1224b00ab754SHans Petter Selaskyif(NOT WIN32) 1225b00ab754SHans Petter Selasky include(FindLFS) 1226b00ab754SHans Petter Selasky if(LFS_FOUND) 1227b00ab754SHans Petter Selasky # 1228b00ab754SHans Petter Selasky # Add the required #defines. 1229b00ab754SHans Petter Selasky # 1230b00ab754SHans Petter Selasky add_definitions(${LFS_DEFINITIONS}) 1231b00ab754SHans Petter Selasky endif() 1232b00ab754SHans Petter Selasky 1233b00ab754SHans Petter Selasky # 1234b00ab754SHans Petter Selasky # Check for fseeko as well. 1235b00ab754SHans Petter Selasky # 1236b00ab754SHans Petter Selasky include(FindFseeko) 1237b00ab754SHans Petter Selasky if(FSEEKO_FOUND) 1238b00ab754SHans Petter Selasky set(HAVE_FSEEKO ON) 1239b00ab754SHans Petter Selasky 1240b00ab754SHans Petter Selasky # 1241b00ab754SHans Petter Selasky # Add the required #defines. 1242b00ab754SHans Petter Selasky # 1243b00ab754SHans Petter Selasky add_definitions(${FSEEKO_DEFINITIONS}) 1244b00ab754SHans Petter Selasky endif() 1245b00ab754SHans Petter Selaskyendif() 1246b00ab754SHans Petter Selasky 1247b00ab754SHans Petter Selaskyif(INET6) 1248b00ab754SHans Petter Selasky message(STATUS "Support IPv6") 1249b00ab754SHans Petter Selaskyendif(INET6) 1250b00ab754SHans Petter Selasky 1251b00ab754SHans Petter Selasky# 1252b00ab754SHans Petter Selasky# Pthreads. 1253b00ab754SHans Petter Selasky# We might need them, because some libraries we use might use them, 1254b00ab754SHans Petter Selasky# but we don't necessarily need them. 1255b00ab754SHans Petter Selasky# That's only on UN*X; on Windows, if they use threads, we assume 1256b00ab754SHans Petter Selasky# they're native Windows threads. 1257b00ab754SHans Petter Selasky# 1258b00ab754SHans Petter Selaskyif(NOT WIN32) 1259b00ab754SHans Petter Selasky set(CMAKE_THREAD_PREFER_PTHREAD ON) 1260b00ab754SHans Petter Selasky find_package(Threads) 1261b00ab754SHans Petter Selasky if(NOT CMAKE_USE_PTHREADS_INIT) 1262b00ab754SHans Petter Selasky # 1263b00ab754SHans Petter Selasky # If it's not pthreads, we won't use it; we use it for libraries 1264b00ab754SHans Petter Selasky # that require it. 1265b00ab754SHans Petter Selasky # 1266b00ab754SHans Petter Selasky set(CMAKE_THREAD_LIBS_INIT "") 1267b00ab754SHans Petter Selasky endif(NOT CMAKE_USE_PTHREADS_INIT) 1268b00ab754SHans Petter Selaskyendif(NOT WIN32) 1269b00ab754SHans Petter Selasky 12706f9cba8fSJoseph Mingroneif(ENABLE_PROFILING) 12716f9cba8fSJoseph Mingrone if(NOT MSVC) 12726f9cba8fSJoseph Mingrone set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") 12736f9cba8fSJoseph Mingrone endif() 12746f9cba8fSJoseph Mingroneendif() 12756f9cba8fSJoseph Mingrone 12766f9cba8fSJoseph Mingrone# 12776f9cba8fSJoseph Mingrone# Based on 12786f9cba8fSJoseph Mingrone# 12796f9cba8fSJoseph Mingrone# https://github.com/commonmark/cmark/blob/master/FindAsan.cmake 12806f9cba8fSJoseph Mingrone# 12816f9cba8fSJoseph Mingrone# The MIT License (MIT) 12826f9cba8fSJoseph Mingrone# 12836f9cba8fSJoseph Mingrone# Copyright (c) 2013 Matthew Arsenault 12846f9cba8fSJoseph Mingrone# 12856f9cba8fSJoseph Mingrone# Permission is hereby granted, free of charge, to any person obtaining a copy 12866f9cba8fSJoseph Mingrone# of this software and associated documentation files (the "Software"), to deal 12876f9cba8fSJoseph Mingrone# in the Software without restriction, including without limitation the rights 12886f9cba8fSJoseph Mingrone# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12896f9cba8fSJoseph Mingrone# copies of the Software, and to permit persons to whom the Software is 12906f9cba8fSJoseph Mingrone# furnished to do so, subject to the following conditions: 12916f9cba8fSJoseph Mingrone# 12926f9cba8fSJoseph Mingrone# The above copyright notice and this permission notice shall be included in 12936f9cba8fSJoseph Mingrone# all copies or substantial portions of the Software. 12946f9cba8fSJoseph Mingrone# 12956f9cba8fSJoseph Mingrone# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12966f9cba8fSJoseph Mingrone# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12976f9cba8fSJoseph Mingrone# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 12986f9cba8fSJoseph Mingrone# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 12996f9cba8fSJoseph Mingrone# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 13006f9cba8fSJoseph Mingrone# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 13016f9cba8fSJoseph Mingrone# THE SOFTWARE. 13026f9cba8fSJoseph Mingrone# 13036f9cba8fSJoseph Mingrone# Test if the each of the sanitizers in the ENABLE_SANITIZERS list are 13046f9cba8fSJoseph Mingrone# supported by the compiler, and, if so, adds the appropriate flags to 1305*afdbf109SJoseph Mingrone# CMAKE_C_FLAGS, and SANITIZER_FLAGS. If not, it fails. 13066f9cba8fSJoseph Mingrone# 13076f9cba8fSJoseph Mingrone# Do this last, in the hope that it will prevent configuration on Linux 13086f9cba8fSJoseph Mingrone# from somehow deciding it doesn't need -lpthread when building rpcapd 13096f9cba8fSJoseph Mingrone# (it does require it, but somehow, in some mysterious fashion that no 13106f9cba8fSJoseph Mingrone# obvious CMake debugging flag reveals, it doesn't realize that if we 13116f9cba8fSJoseph Mingrone# turn sanitizer stuff on). 13126f9cba8fSJoseph Mingrone# 1313*afdbf109SJoseph Mingrone# Note: apparently, some projects have decided that ENABLE_SANITIZERS 1314*afdbf109SJoseph Mingrone# is a Boolean, with OFF meaning "no sanitizers" and ON meaning "all 1315*afdbf109SJoseph Mingrone# sanitizers". Whoever decided that didn't put it up as a common 1316*afdbf109SJoseph Mingrone# CMake idiom, as far as I can tell; we only discovered this because 1317*afdbf109SJoseph Mingrone# JetBrains' CLion "helpfully" appears to pass -DENABLE_SANITIZERS=OFF 1318*afdbf109SJoseph Mingrone# to CMake by default, which causes CMake to fail on libpcap. Thanks! 1319*afdbf109SJoseph Mingrone# 1320*afdbf109SJoseph Mingrone# We thus also allow a setting of OFF to mean "no sanitizers" and ON to 1321*afdbf109SJoseph Mingrone# mean "all supported sanitizers that we know about and that can all 1322*afdbf109SJoseph Mingrone# be used together". 1323*afdbf109SJoseph Mingrone# 1324*afdbf109SJoseph Mingronemacro(test_sanitizer _sanitizer _sanitizer_flag) 1325*afdbf109SJoseph Mingrone message(STATUS "Checking sanitizer ${_sanitizer}") 1326*afdbf109SJoseph Mingrone set(sanitizer_variable "sanitize_${_sanitizer}") 13276f9cba8fSJoseph Mingrone # Set -Werror to catch "argument unused during compilation" warnings 1328*afdbf109SJoseph Mingrone set(CMAKE_REQUIRED_FLAGS "-Werror -fsanitize=${_sanitizer}") 1329*afdbf109SJoseph Mingrone check_c_compiler_flag("-fsanitize=${_sanitizer}" ${sanitizer_variable}) 13306f9cba8fSJoseph Mingrone if(${${sanitizer_variable}}) 1331*afdbf109SJoseph Mingrone set(${_sanitizer_flag} "-fsanitize=${_sanitizer}") 13326f9cba8fSJoseph Mingrone else() 13336f9cba8fSJoseph Mingrone # 13346f9cba8fSJoseph Mingrone # Try the versions supported prior to Clang 3.2. 13356f9cba8fSJoseph Mingrone # If the sanitizer is "address", try -fsanitize-address. 13366f9cba8fSJoseph Mingrone # If it's "undefined", try -fcatch-undefined-behavior. 13376f9cba8fSJoseph Mingrone # Otherwise, give up. 13386f9cba8fSJoseph Mingrone # 13396f9cba8fSJoseph Mingrone set(sanitizer_variable "OLD_${sanitizer_variable}") 1340*afdbf109SJoseph Mingrone if ("${_sanitizer}" STREQUAL "address") 13416f9cba8fSJoseph Mingrone set(CMAKE_REQUIRED_FLAGS "-Werror -fsanitize-address") 13426f9cba8fSJoseph Mingrone check_c_compiler_flag("-fsanitize-address" ${sanitizer_variable}) 13436f9cba8fSJoseph Mingrone if(${${sanitizer_variable}}) 1344*afdbf109SJoseph Mingrone set(${_sanitizer_flag} "-fsanitize-address") 13456f9cba8fSJoseph Mingrone endif() 1346*afdbf109SJoseph Mingrone elseif("${_sanitizer}" STREQUAL "undefined") 13476f9cba8fSJoseph Mingrone set(CMAKE_REQUIRED_FLAGS "-Werror -fcatch-undefined-behavior") 13486f9cba8fSJoseph Mingrone check_c_compiler_flag("-fcatch-undefined-behavior" ${sanitizer_variable}) 13496f9cba8fSJoseph Mingrone if(${${sanitizer_variable}}) 1350*afdbf109SJoseph Mingrone set(${_sanitizer_flag} "-fcatch-undefined-behavior") 13516f9cba8fSJoseph Mingrone endif() 13526f9cba8fSJoseph Mingrone endif() 1353*afdbf109SJoseph Mingrone endif() 13546f9cba8fSJoseph Mingrone unset(CMAKE_REQUIRED_FLAGS) 1355*afdbf109SJoseph Mingroneendmacro(test_sanitizer) 1356*afdbf109SJoseph Mingrone 1357*afdbf109SJoseph Mingroneset(SANITIZER_FLAGS "") 1358*afdbf109SJoseph Mingroneif("${ENABLE_SANITIZERS}") 1359*afdbf109SJoseph Mingrone # 1360*afdbf109SJoseph Mingrone # This appears to indicate that ENABLE_SANITIZERS was set to a 1361*afdbf109SJoseph Mingrone # string value that is "one of the true constants", meaning 1362*afdbf109SJoseph Mingrone # "1, ON, YES, TRUE, Y, or a non-zero number". 1363*afdbf109SJoseph Mingrone # 1364*afdbf109SJoseph Mingrone # It does not appear to happen for other settings, including 1365*afdbf109SJoseph Mingrone # setting it to a list of one or more sanitizers. 1366*afdbf109SJoseph Mingrone # 1367*afdbf109SJoseph Mingrone # This setting means "enable all sanitizers that the compiler 1368*afdbf109SJoseph Mingrone # supports". 1369*afdbf109SJoseph Mingrone # 1370*afdbf109SJoseph Mingrone foreach(sanitizer "address" "undefined") 1371*afdbf109SJoseph Mingrone unset(SANITIZER_FLAG) 1372*afdbf109SJoseph Mingrone test_sanitizer(${sanitizer} SANITIZER_FLAG) 1373*afdbf109SJoseph Mingrone if(SANITIZER_FLAG) 1374*afdbf109SJoseph Mingrone message(STATUS "${sanitizer} sanitizer supported using ${SANITIZER_FLAG}") 1375*afdbf109SJoseph Mingrone set(SANITIZER_FLAGS "${SANITIZER_FLAGS} ${SANITIZER_FLAG}") 1376*afdbf109SJoseph Mingrone else() 1377*afdbf109SJoseph Mingrone message(STATUS "${sanitizer} isn't a supported sanitizer") 1378*afdbf109SJoseph Mingrone endif() 13796f9cba8fSJoseph Mingrone endforeach() 1380*afdbf109SJoseph Mingrone if("${SANITIZER_FLAGS}" STREQUAL "") 1381*afdbf109SJoseph Mingrone message(FATAL_ERROR "No supported sanitizers found") 1382*afdbf109SJoseph Mingrone endif() 1383*afdbf109SJoseph Mingroneelse() 1384*afdbf109SJoseph Mingrone # 1385*afdbf109SJoseph Mingrone # This appears to indicate that ENABLE_SANITIZERS was either: 1386*afdbf109SJoseph Mingrone # 1387*afdbf109SJoseph Mingrone # not set; 1388*afdbf109SJoseph Mingrone # set to a set to a string value that is not "one of the true 1389*afdbf109SJoseph Mingrone # constants", meaning "1, ON, YES, TRUE, Y, or a non-zero number". 1390*afdbf109SJoseph Mingrone # 1391*afdbf109SJoseph Mingrone # The latter includes setting it to "one of the false constants", 1392*afdbf109SJoseph Mingrone # meaning the string "is 0, OFF, NO, FALSE, N, IGNORE, NOTFOUND, 1393*afdbf109SJoseph Mingrone # the empty string, or ends in the suffix -NOTFOUND." 1394*afdbf109SJoseph Mingrone # 1395*afdbf109SJoseph Mingrone # It also includes setting it to a list of one or more sanitizers. 1396*afdbf109SJoseph Mingrone # 1397*afdbf109SJoseph Mingrone # We want to treat "not set" and "set to one of the false constants" 1398*afdbf109SJoseph Mingrone # as meaning "do not enable any sanitizers". 1399*afdbf109SJoseph Mingrone # 1400*afdbf109SJoseph Mingrone # We want to treat "set to a list of one or more sanitizers" as 1401*afdbf109SJoseph Mingrone # meaning "enable all the sanitizers in the list". 1402*afdbf109SJoseph Mingrone # 1403*afdbf109SJoseph Mingrone # This requires that we distinguish between those two cases. 1404*afdbf109SJoseph Mingrone # 1405*afdbf109SJoseph Mingrone if(ENABLE_SANITIZERS) 1406*afdbf109SJoseph Mingrone # 1407*afdbf109SJoseph Mingrone # This appears to indicate that ENABLE_SANITIZERS was set to 1408*afdbf109SJoseph Mingrone # a string value that is "not one of the false constants". 1409*afdbf109SJoseph Mingrone # 1410*afdbf109SJoseph Mingrone # We already know it's "not one of the true constants", so 1411*afdbf109SJoseph Mingrone # we treat it as a list of sanitizers. 1412*afdbf109SJoseph Mingrone # 1413*afdbf109SJoseph Mingrone foreach(sanitizer IN LISTS ENABLE_SANITIZERS) 1414*afdbf109SJoseph Mingrone unset(SANITIZER_FLAG) 1415*afdbf109SJoseph Mingrone test_sanitizer(${sanitizer} SANITIZER_FLAG) 1416*afdbf109SJoseph Mingrone if(SANITIZER_FLAG) 1417*afdbf109SJoseph Mingrone message(STATUS "${sanitizer} sanitizer supported using ${SANITIZER_FLAG}") 1418*afdbf109SJoseph Mingrone set(SANITIZER_FLAGS "${SANITIZER_FLAGS} ${SANITIZER_FLAG}") 1419*afdbf109SJoseph Mingrone else() 1420*afdbf109SJoseph Mingrone message(FATAL_ERROR "${sanitizer} isn't a supported sanitizer") 1421*afdbf109SJoseph Mingrone endif() 1422*afdbf109SJoseph Mingrone endforeach() 1423*afdbf109SJoseph Mingrone else() 1424*afdbf109SJoseph Mingrone # 1425*afdbf109SJoseph Mingrone # This appears to indicate that ENABLE_SANITIZERS was either: 1426*afdbf109SJoseph Mingrone # 1427*afdbf109SJoseph Mingrone # not set; 1428*afdbf109SJoseph Mingrone # set to a value that's "one of the false constants"; 1429*afdbf109SJoseph Mingrone # 1430*afdbf109SJoseph Mingrone # so we don't enable any sanitizers. 1431*afdbf109SJoseph Mingrone # 1432*afdbf109SJoseph Mingrone message(STATUS "Not enabling sanitizers") 1433*afdbf109SJoseph Mingrone endif() 1434*afdbf109SJoseph Mingroneendif() 14356f9cba8fSJoseph Mingrone 14366f9cba8fSJoseph Mingroneif(NOT "${SANITIZER_FLAGS}" STREQUAL "") 14376f9cba8fSJoseph Mingrone set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O1 -g ${SANITIZER_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls") 14386f9cba8fSJoseph Mingroneendif() 14396f9cba8fSJoseph Mingrone 1440*afdbf109SJoseph Mingroneif(ENABLE_REMOTE) 14416f9cba8fSJoseph Mingrone # 14426f9cba8fSJoseph Mingrone # OpenSSL/libressl. 14436f9cba8fSJoseph Mingrone # 14446f9cba8fSJoseph Mingrone find_package(OpenSSL) 14456f9cba8fSJoseph Mingrone if(OPENSSL_FOUND) 14466f9cba8fSJoseph Mingrone # 14476f9cba8fSJoseph Mingrone # We have OpenSSL. 14486f9cba8fSJoseph Mingrone # 14496f9cba8fSJoseph Mingrone include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR}) 14506f9cba8fSJoseph Mingrone set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${OPENSSL_LIBRARIES}) 14516f9cba8fSJoseph Mingrone 14526f9cba8fSJoseph Mingrone # 14536f9cba8fSJoseph Mingrone # The find_package() module CMake provides for OpenSSL uses does not 14546f9cba8fSJoseph Mingrone # give us a defined indication of whether it found OpenSSL with 14556f9cba8fSJoseph Mingrone # pkg-config or not. We need to know that as, if it was found with 14566f9cba8fSJoseph Mingrone # pkg-config, we should set the Requires.private value in libpcap.pc 14576f9cba8fSJoseph Mingrone # to include its package name, openssl, otherwise we should add the 14586f9cba8fSJoseph Mingrone # names for the static libraries to Libs.private. 14596f9cba8fSJoseph Mingrone # 14606f9cba8fSJoseph Mingrone # On UN*X, FindOpenSSL happens to use pkg-config to find OpenSSL, but 14616f9cba8fSJoseph Mingrone # it doesn't appear to be documented as doing so; therefore, we don't 14626f9cba8fSJoseph Mingrone # assume that, if we got here, we have pkg-config. 14636f9cba8fSJoseph Mingrone # 14646f9cba8fSJoseph Mingrone # So we use pkg_get_link_info() to run pkg-config ourselves, both 14656f9cba8fSJoseph Mingrone # because FindOpenSSL doesn't set the OPENSSL_LDFLAGS or 14666f9cba8fSJoseph Mingrone # OPENSSL_STATIC_LDFLAGS variables and because, for reasons explained 14676f9cba8fSJoseph Mingrone # in the comment before the pkg_get_link_info() macro, even if it did, 14686f9cba8fSJoseph Mingrone # it wouldn't be what we want anyway. 14696f9cba8fSJoseph Mingrone # 14706f9cba8fSJoseph Mingrone if (PKG_CONFIG_EXECUTABLE) 14716f9cba8fSJoseph Mingrone pkg_get_link_info(OPENSSL openssl) 14726f9cba8fSJoseph Mingrone if (OPENSSL_FOUND_WITH_PKG_CONFIG) 14736f9cba8fSJoseph Mingrone # 14746f9cba8fSJoseph Mingrone # pkg-config failed; assume that means that there is no openssl 14756f9cba8fSJoseph Mingrone # package for it to find. Just add OPENSSL_LIBRARIES to 14766f9cba8fSJoseph Mingrone # LIBS_PRIVATE AND LIBS_STATIC, as that's the 14776f9cba8fSJoseph Mingrone # best we can do. XXX - need list of -l and -L flags to add.... 14786f9cba8fSJoseph Mingrone # 14796f9cba8fSJoseph Mingrone set(LIBS "${LIBS} ${OPENSSL_LIBS}") 14806f9cba8fSJoseph Mingrone set(LIBS_STATIC "${LIBS_STATIC} ${OPENSSL_LIBS_STATIC}") 14816f9cba8fSJoseph Mingrone set(REQUIRES_PRIVATE "${REQUIRES_PRIVATE} ${OPENSSL_PACKAGE_NAME}") 14826f9cba8fSJoseph Mingrone endif() 14836f9cba8fSJoseph Mingrone else() 14846f9cba8fSJoseph Mingrone # Get it from OPENSSL_LIBRARIES 14856f9cba8fSJoseph Mingrone foreach(_lib IN LISTS OPENSSL_LIBRARIES) 14866f9cba8fSJoseph Mingrone # 14876f9cba8fSJoseph Mingrone # Get the directory in which the library resides. 14886f9cba8fSJoseph Mingrone # 14896f9cba8fSJoseph Mingrone get_filename_component(_lib_directory "${_lib}" DIRECTORY) 14906f9cba8fSJoseph Mingrone 14916f9cba8fSJoseph Mingrone # 14926f9cba8fSJoseph Mingrone # Is the library directory in CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES? 14936f9cba8fSJoseph Mingrone # (See comment above on why we use that.) 14946f9cba8fSJoseph Mingrone # 14956f9cba8fSJoseph Mingrone list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${_lib_directory}" _lib_index) 14966f9cba8fSJoseph Mingrone if(_lib_index EQUAL -1) 14976f9cba8fSJoseph Mingrone # 14986f9cba8fSJoseph Mingrone # No, so add a -L flag to get the linker to search in that 14996f9cba8fSJoseph Mingrone # directory. 15006f9cba8fSJoseph Mingrone # 15016f9cba8fSJoseph Mingrone set(LIBS "${LIBS} -L${_lib_directory}") 15026f9cba8fSJoseph Mingrone set(LIBS_STATIC "${LIBS_STATIC} -L${_lib_directory}") 15036f9cba8fSJoseph Mingrone set(LIBS_PRIVATE "${LIBS_PRIVATE} -L${_lib_directory}") 15046f9cba8fSJoseph Mingrone endif() 15056f9cba8fSJoseph Mingrone 15066f9cba8fSJoseph Mingrone # 15076f9cba8fSJoseph Mingrone # Get the file name of the library, without the extension. 15086f9cba8fSJoseph Mingrone # 15096f9cba8fSJoseph Mingrone get_filename_component(_lib_filename "${_lib}" NAME_WE) 15106f9cba8fSJoseph Mingrone 15116f9cba8fSJoseph Mingrone # 15126f9cba8fSJoseph Mingrone # Strip off the "lib" prefix to get the library name, and 15136f9cba8fSJoseph Mingrone # add a -l flag based on that. 15146f9cba8fSJoseph Mingrone # 15156f9cba8fSJoseph Mingrone string(REGEX REPLACE "^lib" "" _library_name "${_lib_filename}") 15166f9cba8fSJoseph Mingrone set(LIBS "${LIBS} -l${_library_name}") 15176f9cba8fSJoseph Mingrone set(LIBS_STATIC "${LIBS_STATIC} -l${_library_name}") 15186f9cba8fSJoseph Mingrone set(LIBS_PRIVATE "${LIBS_PRIVATE} -l${_library_name}") 15196f9cba8fSJoseph Mingrone endforeach() 15206f9cba8fSJoseph Mingrone endif() 15216f9cba8fSJoseph Mingrone set(HAVE_OPENSSL YES) 15226f9cba8fSJoseph Mingrone endif(OPENSSL_FOUND) 1523*afdbf109SJoseph Mingroneendif(ENABLE_REMOTE) 1524*afdbf109SJoseph Mingrone 1525*afdbf109SJoseph Mingrone# 1526*afdbf109SJoseph Mingrone# On macOS, build libpcap for the appropriate architectures, if 1527*afdbf109SJoseph Mingrone# CMAKE_OSX_ARCHITECTURES isn't set (if it is, let that control 1528*afdbf109SJoseph Mingrone# the architectures for which to build it). 1529*afdbf109SJoseph Mingrone# 1530*afdbf109SJoseph Mingroneif(APPLE AND "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "") 1531*afdbf109SJoseph Mingrone # 1532*afdbf109SJoseph Mingrone # Get the major version of Darwin. 1533*afdbf109SJoseph Mingrone # 1534*afdbf109SJoseph Mingrone string(REGEX MATCH "^([0-9]+)" SYSTEM_VERSION_MAJOR "${CMAKE_SYSTEM_VERSION}") 1535*afdbf109SJoseph Mingrone 1536*afdbf109SJoseph Mingrone if(SYSTEM_VERSION_MAJOR LESS 8) 1537*afdbf109SJoseph Mingrone # 1538*afdbf109SJoseph Mingrone # Pre-Tiger. 1539*afdbf109SJoseph Mingrone # 1540*afdbf109SJoseph Mingrone # Build libraries and executables only for 32-bit PowerPC, as 1541*afdbf109SJoseph Mingrone # that's all that is supported. 1542*afdbf109SJoseph Mingrone # 1543*afdbf109SJoseph Mingrone set(OSX_LIBRARY_ARCHITECTURES "ppc") 1544*afdbf109SJoseph Mingrone set(OSX_EXECUTABLE_ARCHITECTURES "ppc") 1545*afdbf109SJoseph Mingrone elseif(SYSTEM_VERSION_MAJOR EQUAL 8) 1546*afdbf109SJoseph Mingrone # 1547*afdbf109SJoseph Mingrone # Tiger. Is this prior to, or with, Intel support? 1548*afdbf109SJoseph Mingrone # 1549*afdbf109SJoseph Mingrone # Get the minor version of Darwin. 1550*afdbf109SJoseph Mingrone # 1551*afdbf109SJoseph Mingrone string(REPLACE "${SYSTEM_VERSION_MAJOR}." "" SYSTEM_MINOR_AND_PATCH_VERSION ${CMAKE_SYSTEM_VERSION}) 1552*afdbf109SJoseph Mingrone string(REGEX MATCH "^([0-9]+)" SYSTEM_VERSION_MINOR "${SYSTEM_MINOR_AND_PATCH_VERSION}") 1553*afdbf109SJoseph Mingrone if(SYSTEM_VERSION_MINOR LESS 4) 1554*afdbf109SJoseph Mingrone # 1555*afdbf109SJoseph Mingrone # Prior to Intel support. 1556*afdbf109SJoseph Mingrone # 1557*afdbf109SJoseph Mingrone # Build libraries and executables for 32-bit PowerPC and 1558*afdbf109SJoseph Mingrone # 64-bit PowerPC, with 32-bit PowerPC first, as those 1559*afdbf109SJoseph Mingrone # are both supported. (I'm guessing that's what Apple 1560*afdbf109SJoseph Mingrone # does.) 1561*afdbf109SJoseph Mingrone # 1562*afdbf109SJoseph Mingrone set(OSX_LIBRARY_ARCHITECTURES "ppc;ppc64") 1563*afdbf109SJoseph Mingrone set(OSX_EXECUTABLE_ARCHITECTURES "ppc;ppc64") 1564*afdbf109SJoseph Mingrone elseif(SYSTEM_VERSION_MINOR LESS 7) 1565*afdbf109SJoseph Mingrone # 1566*afdbf109SJoseph Mingrone # With Intel support but prior to x86-64 support. 1567*afdbf109SJoseph Mingrone # 1568*afdbf109SJoseph Mingrone # Build for 32-bit PowerPC, 64-bit PowerPC, and 32-bit x86, 1569*afdbf109SJoseph Mingrone # with 32-bit PowerPC first, as those are all supported. 1570*afdbf109SJoseph Mingrone # (I'm guessing that's what Apple does.) 1571*afdbf109SJoseph Mingrone # 1572*afdbf109SJoseph Mingrone set(OSX_LIBRARY_ARCHITECTURES "ppc;ppc64;i386") 1573*afdbf109SJoseph Mingrone set(OSX_EXECUTABLE_ARCHITECTURES "ppc;ppc64;i386") 1574*afdbf109SJoseph Mingrone else() 1575*afdbf109SJoseph Mingrone # 1576*afdbf109SJoseph Mingrone # With Intel support including x86-64 support. 1577*afdbf109SJoseph Mingrone # 1578*afdbf109SJoseph Mingrone # Build for 32-bit PowerPC, 64-bit PowerPC, 32-bit x86, 1579*afdbf109SJoseph Mingrone # and x86-64, with 32-bit PowerPC first, as those are 1580*afdbf109SJoseph Mingrone # all supported. (I'm guessing that's what Apple does.) 1581*afdbf109SJoseph Mingrone # 1582*afdbf109SJoseph Mingrone set(OSX_LIBRARY_ARCHITECTURES "ppc;ppc64;i386;x86_64") 1583*afdbf109SJoseph Mingrone set(OSX_EXECUTABLE_ARCHITECTURES "ppc;ppc64;i386;x86_64") 1584*afdbf109SJoseph Mingrone endif() 1585*afdbf109SJoseph Mingrone elseif(SYSTEM_VERSION_MAJOR EQUAL 9) 1586*afdbf109SJoseph Mingrone # 1587*afdbf109SJoseph Mingrone # Leopard. 1588*afdbf109SJoseph Mingrone # 1589*afdbf109SJoseph Mingrone # Build libraries and executables for 32-bit PowerPC, 64-bit 1590*afdbf109SJoseph Mingrone # PowerPC, 32-bit x86, and x86-64, with 32-bit PowerPC 1591*afdbf109SJoseph Mingrone # first, as those are all supported. (That's what Apple 1592*afdbf109SJoseph Mingrone # does.) 1593*afdbf109SJoseph Mingrone # 1594*afdbf109SJoseph Mingrone set(OSX_LIBRARY_ARCHITECTURES "ppc;ppc64;i386;x86_64") 1595*afdbf109SJoseph Mingrone set(OSX_EXECUTABLE_ARCHITECTURES "ppc;ppc64;i386;x86_64") 1596*afdbf109SJoseph Mingrone elseif(SYSTEM_VERSION_MAJOR EQUAL 10) 1597*afdbf109SJoseph Mingrone # 1598*afdbf109SJoseph Mingrone # Snow Leopard. 1599*afdbf109SJoseph Mingrone # 1600*afdbf109SJoseph Mingrone # Build libraries for x86-64, 32-bit x86, and 32-bit PowerPC, 1601*afdbf109SJoseph Mingrone # with x86-64 first, because 32-bit PowerPC executables are 1602*afdbf109SJoseph Mingrone # supported with Rosetta. (That's what Apple does, even though 1603*afdbf109SJoseph Mingrone # Snow Leopard doesn't run on PPC, so PPC libpcap runs under 1604*afdbf109SJoseph Mingrone # Rosetta, and Rosetta doesn't support BPF ioctls, so PPC 1605*afdbf109SJoseph Mingrone # executables can't do live captures.) 1606*afdbf109SJoseph Mingrone # 1607*afdbf109SJoseph Mingrone set(OSX_LIBRARY_ARCHITECTURES "x86_64;i386;ppc") 1608*afdbf109SJoseph Mingrone 1609*afdbf109SJoseph Mingrone # 1610*afdbf109SJoseph Mingrone # Build executables only for 32-bit x86 and 64-bit x86, as PPC 1611*afdbf109SJoseph Mingrone # machines are no longer supported. 1612*afdbf109SJoseph Mingrone # 1613*afdbf109SJoseph Mingrone set(OSX_EXECUTABLE_ARCHITECTURES "x86_64;i386") 1614*afdbf109SJoseph Mingrone elseif(SYSTEM_VERSION_MAJOR GREATER 10 AND SYSTEM_VERSION_MAJOR LESS 19) 1615*afdbf109SJoseph Mingrone # 1616*afdbf109SJoseph Mingrone # Post-Snow Leopard, pre-Catalina. 1617*afdbf109SJoseph Mingrone # 1618*afdbf109SJoseph Mingrone # Build libraries for 64-bit x86 and 32-bit x86, with 64-bit x86 1619*afdbf109SJoseph Mingrone # first, as PPC machines are no longer supported, but 32-bit 1620*afdbf109SJoseph Mingrone # x86 executables are. (That's what Apple does.) 1621*afdbf109SJoseph Mingrone # 1622*afdbf109SJoseph Mingrone # First, check whether we're building with OpenSSL. 1623*afdbf109SJoseph Mingrone # If so, don't bother trying to build fat. 1624*afdbf109SJoseph Mingrone # 1625*afdbf109SJoseph Mingrone if(HAVE_OPENSSL) 1626*afdbf109SJoseph Mingrone set(X86_32_BIT_SUPPORTED NO) 1627*afdbf109SJoseph Mingrone set(OSX_LIBRARY_ARCHITECTURES "x86_64") 1628*afdbf109SJoseph Mingrone set(OSX_EXECUTABLE_ARCHITECTURES "x86_64") 1629*afdbf109SJoseph Mingrone message(WARNING "We're assuming the OpenSSL libraries are 64-bit only, so we're not compiling for 32-bit x86") 1630*afdbf109SJoseph Mingrone else() 1631*afdbf109SJoseph Mingrone # 1632*afdbf109SJoseph Mingrone # Now, check whether we *can* build for i386. 1633*afdbf109SJoseph Mingrone # 1634*afdbf109SJoseph Mingrone cmake_push_check_state() 1635*afdbf109SJoseph Mingrone set(CMAKE_REQUIRED_FLAGS "-arch i386") 1636*afdbf109SJoseph Mingrone check_c_source_compiles( 1637*afdbf109SJoseph Mingrone"int 1638*afdbf109SJoseph Mingronemain(void) 1639*afdbf109SJoseph Mingrone{ 1640*afdbf109SJoseph Mingrone return 0; 1641*afdbf109SJoseph Mingrone} 1642*afdbf109SJoseph Mingrone" 1643*afdbf109SJoseph Mingrone X86_32_BIT_SUPPORTED) 1644*afdbf109SJoseph Mingrone cmake_pop_check_state() 1645*afdbf109SJoseph Mingrone if(X86_32_BIT_SUPPORTED) 1646*afdbf109SJoseph Mingrone set(OSX_LIBRARY_ARCHITECTURES "x86_64;i386") 1647*afdbf109SJoseph Mingrone else() 1648*afdbf109SJoseph Mingrone set(OSX_LIBRARY_ARCHITECTURES "x86_64") 1649*afdbf109SJoseph Mingrone # 1650*afdbf109SJoseph Mingrone # We can't build fat; suggest that the user install the 1651*afdbf109SJoseph Mingrone # /usr/include headers if they want to build fat. 1652*afdbf109SJoseph Mingrone # 1653*afdbf109SJoseph Mingrone if(SYSTEM_VERSION_MAJOR LESS 18) 1654*afdbf109SJoseph Mingrone # 1655*afdbf109SJoseph Mingrone # Pre-Mojave; the command-line tools should be sufficient to 1656*afdbf109SJoseph Mingrone # enable 32-bit x86 builds. 1657*afdbf109SJoseph Mingrone # 1658*afdbf109SJoseph Mingrone message(WARNING "Compiling for 32-bit x86 gives an error; try installing the command-line tools") 1659*afdbf109SJoseph Mingrone else() 1660*afdbf109SJoseph Mingrone message(WARNING "Compiling for 32-bit x86 gives an error; try installing the command-line tools and, after that, installing the /usr/include headers from the /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg package") 1661*afdbf109SJoseph Mingrone endif() 1662*afdbf109SJoseph Mingrone endif() 1663*afdbf109SJoseph Mingrone endif() 1664*afdbf109SJoseph Mingrone 1665*afdbf109SJoseph Mingrone # 1666*afdbf109SJoseph Mingrone # Build executables only for 64-bit x86, as 32-bit x86 machines 1667*afdbf109SJoseph Mingrone # are no longer supported. 1668*afdbf109SJoseph Mingrone # 1669*afdbf109SJoseph Mingrone set(OSX_EXECUTABLE_ARCHITECTURES "x86_64") 1670*afdbf109SJoseph Mingrone elseif(SYSTEM_VERSION_MAJOR EQUAL 19) 1671*afdbf109SJoseph Mingrone # 1672*afdbf109SJoseph Mingrone # Catalina. 1673*afdbf109SJoseph Mingrone # 1674*afdbf109SJoseph Mingrone # Build libraries and executables only for x86-64, as 32-bit 1675*afdbf109SJoseph Mingrone # executables are no longer supported. (That's what Apple 1676*afdbf109SJoseph Mingrone # does.) 1677*afdbf109SJoseph Mingrone # 1678*afdbf109SJoseph Mingrone set(OSX_LIBRARY_ARCHITECTURES "x86_64") 1679*afdbf109SJoseph Mingrone set(OSX_EXECUTABLE_ARCHITECTURES "x86_64") 1680*afdbf109SJoseph Mingrone else() 1681*afdbf109SJoseph Mingrone # 1682*afdbf109SJoseph Mingrone # Post-Catalina. Build libraries and 1683*afdbf109SJoseph Mingrone # executables for x86-64 and ARM64. 1684*afdbf109SJoseph Mingrone # (That's what Apple does, except they 1685*afdbf109SJoseph Mingrone # build for arm64e, which may include 1686*afdbf109SJoseph Mingrone # some of the pointer-checking extensions.) 1687*afdbf109SJoseph Mingrone # 1688*afdbf109SJoseph Mingrone # If we're building with libssl, make sure 1689*afdbf109SJoseph Mingrone # we can build fat with it (i.e., that it 1690*afdbf109SJoseph Mingrone # was built fat); if we can't, don't set 1691*afdbf109SJoseph Mingrone # the target architectures, and just 1692*afdbf109SJoseph Mingrone # build for the host we're on. 1693*afdbf109SJoseph Mingrone # 1694*afdbf109SJoseph Mingrone # Otherwise, just add both of them. 1695*afdbf109SJoseph Mingrone # 1696*afdbf109SJoseph Mingrone if(HAVE_OPENSSL) 1697*afdbf109SJoseph Mingrone cmake_push_check_state() 1698*afdbf109SJoseph Mingrone set(CMAKE_REQUIRED_FLAGS "-arch x86_64 -arch arm64") 1699*afdbf109SJoseph Mingrone set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) 1700*afdbf109SJoseph Mingrone set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) 1701*afdbf109SJoseph Mingrone # 1702*afdbf109SJoseph Mingrone # We must test whether this compiles and links, so 1703*afdbf109SJoseph Mingrone # check_symbol_exists() isn't sufficient. 1704*afdbf109SJoseph Mingrone # 1705*afdbf109SJoseph Mingrone # SSL_library_init() may be a macro that's #defined 1706*afdbf109SJoseph Mingrone # to be the real function to call, so we have to 1707*afdbf109SJoseph Mingrone # include <openssl/ssl.h>, and check_function_exists() 1708*afdbf109SJoseph Mingrone # isn't sufficient. 1709*afdbf109SJoseph Mingrone # 1710*afdbf109SJoseph Mingrone check_c_source_compiles( 1711*afdbf109SJoseph Mingrone"#include <openssl/ssl.h> 1712*afdbf109SJoseph Mingroneint 1713*afdbf109SJoseph Mingronemain(void) 1714*afdbf109SJoseph Mingrone{ 1715*afdbf109SJoseph Mingrone SSL_library_init(); 1716*afdbf109SJoseph Mingrone return 0; 1717*afdbf109SJoseph Mingrone} 1718*afdbf109SJoseph Mingrone" 1719*afdbf109SJoseph Mingrone FAT_SSL_BUILDS_SUPPORTED) 1720*afdbf109SJoseph Mingrone cmake_pop_check_state() 1721*afdbf109SJoseph Mingrone if(FAT_SSL_BUILDS_SUPPORTED) 1722*afdbf109SJoseph Mingrone set(OSX_LIBRARY_ARCHITECTURES "x86_64;arm64") 1723*afdbf109SJoseph Mingrone set(OSX_EXECUTABLE_ARCHITECTURES "x86_64;arm64") 1724*afdbf109SJoseph Mingrone endif() 1725*afdbf109SJoseph Mingrone else() 1726*afdbf109SJoseph Mingrone set(OSX_LIBRARY_ARCHITECTURES "x86_64;arm64") 1727*afdbf109SJoseph Mingrone set(OSX_EXECUTABLE_ARCHITECTURES "x86_64;arm64") 1728*afdbf109SJoseph Mingrone endif() 1729*afdbf109SJoseph Mingrone endif() 1730*afdbf109SJoseph Mingroneendif() 17316f9cba8fSJoseph Mingrone 17326f9cba8fSJoseph Mingrone# 17336f9cba8fSJoseph Mingrone# Additional linker flags. 17346f9cba8fSJoseph Mingrone# 17356f9cba8fSJoseph Mingroneset(LINKER_FLAGS "${SANITIZER_FLAGS}") 17366f9cba8fSJoseph Mingroneif(ENABLE_PROFILING) 17376f9cba8fSJoseph Mingrone if(MSVC) 17386f9cba8fSJoseph Mingrone set(LINKER_FLAGS " /PROFILE") 17396f9cba8fSJoseph Mingrone else() 17406f9cba8fSJoseph Mingrone set(LINKER_FLAGS " -pg") 17416f9cba8fSJoseph Mingrone endif() 17426f9cba8fSJoseph Mingroneendif() 17436f9cba8fSJoseph Mingrone 1744b00ab754SHans Petter Selasky###################################### 1745b00ab754SHans Petter Selasky# Input files 1746b00ab754SHans Petter Selasky###################################### 1747b00ab754SHans Petter Selasky 1748b00ab754SHans Petter Selaskyset(PROJECT_SOURCE_LIST_C 1749b00ab754SHans Petter Selasky bpf_dump.c 1750b00ab754SHans Petter Selasky bpf_filter.c 1751b00ab754SHans Petter Selasky bpf_image.c 1752b00ab754SHans Petter Selasky etherent.c 1753b00ab754SHans Petter Selasky fmtutils.c 1754b00ab754SHans Petter Selasky gencode.c 1755b00ab754SHans Petter Selasky nametoaddr.c 1756b00ab754SHans Petter Selasky optimize.c 1757b00ab754SHans Petter Selasky pcap-common.c 17586f9cba8fSJoseph Mingrone pcap-util.c 1759b00ab754SHans Petter Selasky pcap.c 1760b00ab754SHans Petter Selasky savefile.c 1761b00ab754SHans Petter Selasky sf-pcapng.c 1762b00ab754SHans Petter Selasky sf-pcap.c 1763b00ab754SHans Petter Selasky) 1764b00ab754SHans Petter Selasky 1765b00ab754SHans Petter Selaskyif(WIN32) 176657e22627SCy Schubert # 17676f9cba8fSJoseph Mingrone # We add the character set conversion routines; they're Windows-only 17686f9cba8fSJoseph Mingrone # for now. 176957e22627SCy Schubert # 17706f9cba8fSJoseph Mingrone # We assume we don't have asprintf(), and provide an implementation 177157e22627SCy Schubert # that uses _vscprintf() to determine how big the string needs to be. 177257e22627SCy Schubert # 177357e22627SCy Schubert set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} 17746f9cba8fSJoseph Mingrone charconv.c missing/win_asprintf.c) 1775b00ab754SHans Petter Selaskyelse() 17766f9cba8fSJoseph Mingrone if(NOT HAVE_ASPRINTF) 177757e22627SCy Schubert set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/asprintf.c) 177857e22627SCy Schubert endif() 177957e22627SCy Schubert if(NOT HAVE_STRLCAT) 178057e22627SCy Schubert set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/strlcat.c) 178157e22627SCy Schubert endif(NOT HAVE_STRLCAT) 178257e22627SCy Schubert if(NOT HAVE_STRLCPY) 178357e22627SCy Schubert set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/strlcpy.c) 178457e22627SCy Schubert endif(NOT HAVE_STRLCPY) 1785b00ab754SHans Petter Selasky if(NOT HAVE_STRTOK_R) 1786b00ab754SHans Petter Selasky set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/strtok_r.c) 1787b00ab754SHans Petter Selasky endif(NOT HAVE_STRTOK_R) 1788b00ab754SHans Petter Selaskyendif(WIN32) 1789b00ab754SHans Petter Selasky 1790b00ab754SHans Petter Selasky# 1791b00ab754SHans Petter Selasky# Determine the main pcap-XXX.c file to use, and the libraries with 1792b00ab754SHans Petter Selasky# which we need to link libpcap, if any. 1793b00ab754SHans Petter Selasky# 1794b00ab754SHans Petter Selaskyif(WIN32) 1795b00ab754SHans Petter Selasky # 1796b00ab754SHans Petter Selasky # Windows. 1797b00ab754SHans Petter Selasky # 1798b00ab754SHans Petter Selasky # Has the user explicitly specified a capture type? 1799b00ab754SHans Petter Selasky # 1800b00ab754SHans Petter Selasky if(PCAP_TYPE STREQUAL "") 1801b00ab754SHans Petter Selasky # 1802b00ab754SHans Petter Selasky # The user didn't explicitly specify a capture mechanism. 1803b00ab754SHans Petter Selasky # Check whether we have packet.dll. 1804b00ab754SHans Petter Selasky # 1805b00ab754SHans Petter Selasky if(HAVE_PACKET32) 1806b00ab754SHans Petter Selasky # 1807b00ab754SHans Petter Selasky # We have packet.dll. 1808b00ab754SHans Petter Selasky # Set the capture type to NPF. 1809b00ab754SHans Petter Selasky # 1810b00ab754SHans Petter Selasky set(PCAP_TYPE npf) 1811b00ab754SHans Petter Selasky else() 1812b00ab754SHans Petter Selasky # 1813*afdbf109SJoseph Mingrone # We don't have any capture type we know about. 1814*afdbf109SJoseph Mingrone # Report an error, and tell the user to configure with 1815*afdbf109SJoseph Mingrone # -DPCAP_TYPE=null if they want a libpcap that can't 1816*afdbf109SJoseph Mingrone # capture but that can read capture files. That way, 1817*afdbf109SJoseph Mingrone # nobody gets surprised by getting a no-capture 1818*afdbf109SJoseph Mingrone # libpcap without asking for that. 1819b00ab754SHans Petter Selasky # 1820*afdbf109SJoseph Mingrone message(FATAL_ERROR "No supported packet capture interface was found. 1821*afdbf109SJoseph MingroneIn order to build a version of libpcap that supports packet capture 1822*afdbf109SJoseph Mingroneon Windows, you will need to install Npcap and the Npcap SDK, or 1823*afdbf109SJoseph MingroneWinPcap and the WinPcap SDK, and run cmake with -DPacket_ROOT={path of SDK}, 1824*afdbf109SJoseph Mingronewhere {path of SDK} is the path name of the top-level directory of the SDK. 1825*afdbf109SJoseph MingroneThat argument may have to be quoted if the path contains blanks. 1826*afdbf109SJoseph MingroneIf you want a libpcap that cannot capture packets but that can read 1827*afdbf109SJoseph Mingronepcap and pcapng files, run cmake with -DPCAP_TYPE=null.") 1828b00ab754SHans Petter Selasky endif() 1829b00ab754SHans Petter Selasky endif() 1830b00ab754SHans Petter Selaskyelse() 1831b00ab754SHans Petter Selasky # 1832b00ab754SHans Petter Selasky # UN*X. 1833b00ab754SHans Petter Selasky # 1834b00ab754SHans Petter Selasky # Figure out what type of packet capture mechanism we have, and 1835b00ab754SHans Petter Selasky # what libraries we'd need to link libpcap with, if any. 1836b00ab754SHans Petter Selasky # 1837b00ab754SHans Petter Selasky 1838b00ab754SHans Petter Selasky # 1839b00ab754SHans Petter Selasky # Has the user explicitly specified a capture type? 1840b00ab754SHans Petter Selasky # 1841b00ab754SHans Petter Selasky if(PCAP_TYPE STREQUAL "") 1842b00ab754SHans Petter Selasky # 1843b00ab754SHans Petter Selasky # Check for a bunch of headers for various packet capture mechanisms. 1844b00ab754SHans Petter Selasky # 1845b00ab754SHans Petter Selasky check_include_files("sys/types.h;net/bpf.h" HAVE_NET_BPF_H) 1846b00ab754SHans Petter Selasky if(HAVE_NET_BPF_H) 1847b00ab754SHans Petter Selasky # 1848b00ab754SHans Petter Selasky # Does it define BIOCSETIF? 1849b00ab754SHans Petter Selasky # I.e., is it a header for an LBL/BSD-style capture 1850b00ab754SHans Petter Selasky # mechanism, or is it just a header for a BPF filter 1851b00ab754SHans Petter Selasky # engine? Some versions of Arch Linux, for example, 1852b00ab754SHans Petter Selasky # have a net/bpf.h that doesn't define BIOCSETIF; 1853b00ab754SHans Petter Selasky # as it's a Linux, it should use packet sockets, 1854b00ab754SHans Petter Selasky # instead. 1855b00ab754SHans Petter Selasky # 1856b00ab754SHans Petter Selasky # We need: 1857b00ab754SHans Petter Selasky # 1858b00ab754SHans Petter Selasky # sys/types.h, because FreeBSD 10's net/bpf.h 1859b00ab754SHans Petter Selasky # requires that various BSD-style integer types 1860b00ab754SHans Petter Selasky # be defined; 1861b00ab754SHans Petter Selasky # 186257e22627SCy Schubert # sys/time.h, because AIX 5.2 and 5.3's net/bpf.h 186357e22627SCy Schubert # doesn't include it but does use struct timeval 186457e22627SCy Schubert # in ioctl definitions; 186557e22627SCy Schubert # 1866b00ab754SHans Petter Selasky # sys/ioctl.h and, if we have it, sys/ioccom.h, 1867b00ab754SHans Petter Selasky # because net/bpf.h defines ioctls; 1868b00ab754SHans Petter Selasky # 1869b00ab754SHans Petter Selasky # net/if.h, because it defines some structures 1870b00ab754SHans Petter Selasky # used in ioctls defined by net/bpf.h; 1871b00ab754SHans Petter Selasky # 1872b00ab754SHans Petter Selasky # sys/socket.h, because OpenBSD 5.9's net/bpf.h 1873b00ab754SHans Petter Selasky # defines some structure fields as being 1874b00ab754SHans Petter Selasky # struct sockaddrs; 1875b00ab754SHans Petter Selasky # 1876b00ab754SHans Petter Selasky # and net/bpf.h doesn't necessarily include all 1877b00ab754SHans Petter Selasky # of those headers itself. 1878b00ab754SHans Petter Selasky # 1879b00ab754SHans Petter Selasky if(HAVE_SYS_IOCCOM_H) 188057e22627SCy Schubert check_symbol_exists(BIOCSETIF "sys/types.h;sys/time.h;sys/ioctl.h;sys/socket.h;sys/ioccom.h;net/bpf.h;net/if.h" BPF_H_DEFINES_BIOCSETIF) 1881b00ab754SHans Petter Selasky else(HAVE_SYS_IOCCOM_H) 188257e22627SCy Schubert check_symbol_exists(BIOCSETIF "sys/types.h;sys/time.h;sys/ioctl.h;sys/socket.h;net/bpf.h;net/if.h" BPF_H_DEFINES_BIOCSETIF) 1883b00ab754SHans Petter Selasky endif(HAVE_SYS_IOCCOM_H) 1884b00ab754SHans Petter Selasky endif(HAVE_NET_BPF_H) 1885b00ab754SHans Petter Selasky check_include_file(net/pfilt.h HAVE_NET_PFILT_H) 1886b00ab754SHans Petter Selasky check_include_file(net/enet.h HAVE_NET_ENET_H) 1887b00ab754SHans Petter Selasky check_include_file(net/nit.h HAVE_NET_NIT_H) 1888b00ab754SHans Petter Selasky check_include_file(sys/net/nit.h HAVE_SYS_NET_NIT_H) 1889b00ab754SHans Petter Selasky check_include_file(linux/socket.h HAVE_LINUX_SOCKET_H) 1890b00ab754SHans Petter Selasky check_include_file(net/raw.h HAVE_NET_RAW_H) 1891b00ab754SHans Petter Selasky check_include_file(sys/dlpi.h HAVE_SYS_DLPI_H) 18926f9cba8fSJoseph Mingrone check_include_file(config/HaikuConfig.h HAVE_CONFIG_HAIKUCONFIG_H) 1893b00ab754SHans Petter Selasky 1894b00ab754SHans Petter Selasky if(BPF_H_DEFINES_BIOCSETIF) 1895b00ab754SHans Petter Selasky # 1896b00ab754SHans Petter Selasky # BPF. 1897b00ab754SHans Petter Selasky # Check this before DLPI, so that we pick BPF on 1898b00ab754SHans Petter Selasky # Solaris 11 and later. 1899b00ab754SHans Petter Selasky # 1900b00ab754SHans Petter Selasky set(PCAP_TYPE bpf) 1901b00ab754SHans Petter Selasky elseif(HAVE_LINUX_SOCKET_H) 1902b00ab754SHans Petter Selasky # 1903b00ab754SHans Petter Selasky # No prizes for guessing this one. 1904b00ab754SHans Petter Selasky # 1905b00ab754SHans Petter Selasky set(PCAP_TYPE linux) 1906b00ab754SHans Petter Selasky elseif(HAVE_NET_PFILT_H) 1907b00ab754SHans Petter Selasky # 1908b00ab754SHans Petter Selasky # DEC OSF/1, Digital UNIX, Tru64 UNIX 1909b00ab754SHans Petter Selasky # 1910b00ab754SHans Petter Selasky set(PCAP_TYPE pf) 1911b00ab754SHans Petter Selasky elseif(HAVE_NET_ENET_H) 1912b00ab754SHans Petter Selasky # 1913b00ab754SHans Petter Selasky # Stanford Enetfilter. 1914b00ab754SHans Petter Selasky # 1915b00ab754SHans Petter Selasky set(PCAP_TYPE enet) 1916b00ab754SHans Petter Selasky elseif(HAVE_NET_NIT_H) 1917b00ab754SHans Petter Selasky # 1918b00ab754SHans Petter Selasky # SunOS 4.x STREAMS NIT. 1919b00ab754SHans Petter Selasky # 1920b00ab754SHans Petter Selasky set(PCAP_TYPE snit) 1921b00ab754SHans Petter Selasky elseif(HAVE_SYS_NET_NIT_H) 1922b00ab754SHans Petter Selasky # 1923b00ab754SHans Petter Selasky # Pre-SunOS 4.x non-STREAMS NIT. 1924b00ab754SHans Petter Selasky # 1925b00ab754SHans Petter Selasky set(PCAP_TYPE nit) 1926b00ab754SHans Petter Selasky elseif(HAVE_NET_RAW_H) 1927b00ab754SHans Petter Selasky # 1928b00ab754SHans Petter Selasky # IRIX snoop. 1929b00ab754SHans Petter Selasky # 1930b00ab754SHans Petter Selasky set(PCAP_TYPE snoop) 1931b00ab754SHans Petter Selasky elseif(HAVE_SYS_DLPI_H) 1932b00ab754SHans Petter Selasky # 1933b00ab754SHans Petter Selasky # DLPI on pre-Solaris 11 SunOS 5, HP-UX, possibly others. 1934b00ab754SHans Petter Selasky # 1935b00ab754SHans Petter Selasky set(PCAP_TYPE dlpi) 19366f9cba8fSJoseph Mingrone elseif(HAVE_CONFIG_HAIKUCONFIG_H) 19376f9cba8fSJoseph Mingrone # 19386f9cba8fSJoseph Mingrone # Haiku. 19396f9cba8fSJoseph Mingrone # 19406f9cba8fSJoseph Mingrone set(PCAP_TYPE haiku) 1941b00ab754SHans Petter Selasky else() 1942b00ab754SHans Petter Selasky # 1943*afdbf109SJoseph Mingrone # We don't have any capture type we know about. 1944*afdbf109SJoseph Mingrone # Report an error, and tell the user to configure with 1945*afdbf109SJoseph Mingrone # -DPCAP_TYPE=null if they want a libpcap that can't 1946*afdbf109SJoseph Mingrone # capture but that can read capture files. That way, 1947*afdbf109SJoseph Mingrone # nobody gets surprised by getting a no-capture 1948*afdbf109SJoseph Mingrone # libpcap without asking for that. 1949b00ab754SHans Petter Selasky # 1950*afdbf109SJoseph Mingrone message(FATAL_ERROR "No supported packet capture interface was found. 1951*afdbf109SJoseph MingroneSee the INSTALL.md file for information on packet capture support in 1952*afdbf109SJoseph Mingronevarious operating systems. 1953*afdbf109SJoseph MingroneIf you want a libpcap that cannot capture packets but that can read 1954*afdbf109SJoseph Mingronepcap and pcapng files, run cmake with -DPCAP_TYPE=null.") 1955b00ab754SHans Petter Selasky endif() 1956b00ab754SHans Petter Selasky endif() 1957b00ab754SHans Petter Selaskyendif(WIN32) 1958b00ab754SHans Petter Selaskymessage(STATUS "Packet capture mechanism type: ${PCAP_TYPE}") 1959b00ab754SHans Petter Selasky 19606f9cba8fSJoseph Mingronefind_package(PkgConfig QUIET) 19616f9cba8fSJoseph Mingrone 1962b00ab754SHans Petter Selasky# 1963b00ab754SHans Petter Selasky# Do capture-mechanism-dependent tests. 1964b00ab754SHans Petter Selasky# 1965b00ab754SHans Petter Selaskyif(WIN32) 1966b00ab754SHans Petter Selasky if(PCAP_TYPE STREQUAL "npf") 1967b00ab754SHans Petter Selasky # 19686f9cba8fSJoseph Mingrone # Link with packet.dll before Winsock2. 1969b00ab754SHans Petter Selasky # 19706f9cba8fSJoseph Mingrone set(PCAP_LINK_LIBRARIES ${Packet_LIBRARIES} ${PCAP_LINK_LIBRARIES}) 1971b00ab754SHans Petter Selasky elseif(PCAP_TYPE STREQUAL "null") 1972b00ab754SHans Petter Selasky else() 19736f9cba8fSJoseph Mingrone message(FATAL_ERROR "${PCAP_TYPE} is not a valid pcap type") 1974b00ab754SHans Petter Selasky endif() 1975b00ab754SHans Petter Selaskyelse(WIN32) 1976b00ab754SHans Petter Selasky if(PCAP_TYPE STREQUAL "dlpi") 1977b00ab754SHans Petter Selasky # 1978b00ab754SHans Petter Selasky # Needed for common functions used by pcap-[dlpi,libdlpi].c 1979b00ab754SHans Petter Selasky # 1980b00ab754SHans Petter Selasky set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} dlpisubs.c) 1981b00ab754SHans Petter Selasky 1982b00ab754SHans Petter Selasky # 1983b00ab754SHans Petter Selasky # Checks for some header files. 1984b00ab754SHans Petter Selasky # 1985b00ab754SHans Petter Selasky check_include_file(sys/bufmod.h HAVE_SYS_BUFMOD_H) 1986b00ab754SHans Petter Selasky check_include_file(sys/dlpi_ext.h HAVE_SYS_DLPI_EXT_H) 1987b00ab754SHans Petter Selasky 1988b00ab754SHans Petter Selasky # 1989b00ab754SHans Petter Selasky # Checks to see if Solaris has the public libdlpi(3LIB) library. 1990b00ab754SHans Petter Selasky # Note: The existence of /usr/include/libdlpi.h does not mean it is the 1991b00ab754SHans Petter Selasky # public libdlpi(3LIB) version. Before libdlpi was made public, a 1992b00ab754SHans Petter Selasky # private version also existed, which did not have the same APIs. 1993b00ab754SHans Petter Selasky # Due to a gcc bug, the default search path for 32-bit libraries does 1994b00ab754SHans Petter Selasky # not include /lib, we add it explicitly here. 1995b00ab754SHans Petter Selasky # [http://bugs.opensolaris.org/view_bug.do?bug_id=6619485]. 1996b00ab754SHans Petter Selasky # Also, due to the bug above applications that link to libpcap with 1997b00ab754SHans Petter Selasky # libdlpi will have to add "-L/lib" option to "configure". 1998b00ab754SHans Petter Selasky # 1999b00ab754SHans Petter Selasky cmake_push_check_state() 2000b00ab754SHans Petter Selasky set(CMAKE_REQUIRED_FLAGS "-L/lib") 2001b00ab754SHans Petter Selasky set(CMAKE_REQUIRED_LIBRARIES dlpi) 2002b00ab754SHans Petter Selasky check_function_exists(dlpi_walk HAVE_LIBDLPI) 2003b00ab754SHans Petter Selasky cmake_pop_check_state() 2004b00ab754SHans Petter Selasky if(HAVE_LIBDLPI) 2005b00ab754SHans Petter Selasky # 2006b00ab754SHans Petter Selasky # XXX - add -L/lib 2007b00ab754SHans Petter Selasky # 2008b00ab754SHans Petter Selasky set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} dlpi) 20096f9cba8fSJoseph Mingrone set(LIBS "${LIBS} -ldlpi") 20106f9cba8fSJoseph Mingrone set(LIBS_STATIC "${LIBS_STATIC} -ldlpi") 20116f9cba8fSJoseph Mingrone set(LIBS_PRIVATE "${LIBS_PRIVATE} -ldlpi") 2012b00ab754SHans Petter Selasky set(PCAP_TYPE libdlpi) 2013b00ab754SHans Petter Selasky endif() 2014b00ab754SHans Petter Selasky 2015b00ab754SHans Petter Selasky # 2016b00ab754SHans Petter Selasky # This check is for Solaris with DLPI support for passive modes. 2017b00ab754SHans Petter Selasky # See dlpi(7P) for more details. 2018b00ab754SHans Petter Selasky # 2019b00ab754SHans Petter Selasky # XXX - there's no check_type() macro that's like check_type_size() 2020b00ab754SHans Petter Selasky # except that it only checks for the existence of the structure type, 2021b00ab754SHans Petter Selasky # so we use check_type_size() and ignore the size. 2022b00ab754SHans Petter Selasky # 2023b00ab754SHans Petter Selasky cmake_push_check_state() 2024b00ab754SHans Petter Selasky set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h sys/dlpi.h) 2025b00ab754SHans Petter Selasky check_type_size(dl_passive_req_t DL_PASSIVE_REQ_T) 2026b00ab754SHans Petter Selasky cmake_pop_check_state() 2027b00ab754SHans Petter Selasky elseif(PCAP_TYPE STREQUAL "linux") 2028b00ab754SHans Petter Selasky # 2029b00ab754SHans Petter Selasky # Do we have the wireless extensions? 2030b00ab754SHans Petter Selasky # linux/wireless.h requires sys/socket.h. 2031b00ab754SHans Petter Selasky # 2032b00ab754SHans Petter Selasky check_include_files("sys/socket.h;linux/wireless.h" HAVE_LINUX_WIRELESS_H) 2033b00ab754SHans Petter Selasky 2034b00ab754SHans Petter Selasky # 2035b00ab754SHans Petter Selasky # Do we have libnl? 20366f9cba8fSJoseph Mingrone # We only want version 3. Version 2 was, apparently, 20376f9cba8fSJoseph Mingrone # short-lived, and version 1 is source and binary 20386f9cba8fSJoseph Mingrone # incompatible with version 3, and it appears that, 20396f9cba8fSJoseph Mingrone # these days, everybody's using version 3. We're 20406f9cba8fSJoseph Mingrone # not supporting older versions of the Linux kernel; 20416f9cba8fSJoseph Mingrone # let's drop support for older versions of libnl, too. 2042b00ab754SHans Petter Selasky # 2043b00ab754SHans Petter Selasky if(BUILD_WITH_LIBNL) 20446f9cba8fSJoseph Mingrone pkg_check_modules(LIBNL libnl-genl-3.0) 20456f9cba8fSJoseph Mingrone if(LIBNL_FOUND) 20466f9cba8fSJoseph Mingrone set(PCAP_LINK_LIBRARIES ${LIBNL_LIBRARIES} ${PCAP_LINK_LIBRARIES}) 20476f9cba8fSJoseph Mingrone 2048b00ab754SHans Petter Selasky # 20496f9cba8fSJoseph Mingrone # Get raw link flags from pkg-config. 2050b00ab754SHans Petter Selasky # 20516f9cba8fSJoseph Mingrone pkg_get_link_info(LIBNL libnl-genl-3.0) 20526f9cba8fSJoseph Mingrone set(LIBS "${LIBNL_LIBS} ${LIBS}") 20536f9cba8fSJoseph Mingrone set(LIBS_STATIC "${LIBNL_LIBS_STATIC} ${LIBS_STATIC}") 20546f9cba8fSJoseph Mingrone set(REQUIRES_PRIVATE "${LIBNL_PACKAGE_NAME} ${REQUIRES_PRIVATE}") 20556f9cba8fSJoseph Mingrone else() 2056b00ab754SHans Petter Selasky cmake_push_check_state() 2057b00ab754SHans Petter Selasky set(CMAKE_REQUIRED_LIBRARIES nl-3) 2058b00ab754SHans Petter Selasky check_function_exists(nl_socket_alloc HAVE_LIBNL) 2059b00ab754SHans Petter Selasky cmake_pop_check_state() 2060b00ab754SHans Petter Selasky if(HAVE_LIBNL) 2061b00ab754SHans Petter Selasky # 2062b00ab754SHans Petter Selasky # Yes, we have libnl 3.x. 2063b00ab754SHans Petter Selasky # 2064b00ab754SHans Petter Selasky set(PCAP_LINK_LIBRARIES nl-genl-3 nl-3 ${PCAP_LINK_LIBRARIES}) 2065b00ab754SHans Petter Selasky include_directories("/usr/include/libnl3") 20666f9cba8fSJoseph Mingrone set(LIBS "-lnl-genl-3 -lnl-3 ${LIBS}") 20676f9cba8fSJoseph Mingrone set(LIBS_STATIC "-lnl-genl-3 -lnl-3 ${LIBS_STATIC}") 20686f9cba8fSJoseph Mingrone set(LIBS_PRIVATE "-lnl-genl-3 -lnl-3 ${LIBS_PRIVATE}") 20696f9cba8fSJoseph Mingrone endif() 20706f9cba8fSJoseph Mingrone endif() 2071b00ab754SHans Petter Selasky else() 20726f9cba8fSJoseph Mingrone unset(HAVE_LIBNL CACHE) # check_function_exists stores results in cache 2073b00ab754SHans Petter Selasky endif() 2074b00ab754SHans Petter Selasky 2075b00ab754SHans Petter Selasky check_struct_has_member("struct tpacket_auxdata" tp_vlan_tci linux/if_packet.h HAVE_STRUCT_TPACKET_AUXDATA_TP_VLAN_TCI) 2076b00ab754SHans Petter Selasky elseif(PCAP_TYPE STREQUAL "bpf") 2077b00ab754SHans Petter Selasky # 2078b00ab754SHans Petter Selasky # Check whether we have the *BSD-style ioctls. 2079b00ab754SHans Petter Selasky # 2080b00ab754SHans Petter Selasky check_include_files("sys/types.h;net/if_media.h" HAVE_NET_IF_MEDIA_H) 2081b00ab754SHans Petter Selasky 2082b00ab754SHans Petter Selasky # 2083b00ab754SHans Petter Selasky # Check whether we have struct BPF_TIMEVAL. 2084b00ab754SHans Petter Selasky # 2085b00ab754SHans Petter Selasky # XXX - there's no check_type() macro that's like check_type_size() 2086b00ab754SHans Petter Selasky # except that it only checks for the existence of the structure type, 2087b00ab754SHans Petter Selasky # so we use check_type_size() and ignore the size. 2088b00ab754SHans Petter Selasky # 2089b00ab754SHans Petter Selasky cmake_push_check_state() 2090b00ab754SHans Petter Selasky if(HAVE_SYS_IOCCOM_H) 2091b00ab754SHans Petter Selasky set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h sys/ioccom.h net/bpf.h) 2092b00ab754SHans Petter Selasky check_type_size("struct BPF_TIMEVAL" STRUCT_BPF_TIMEVAL) 2093b00ab754SHans Petter Selasky else() 2094b00ab754SHans Petter Selasky set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h net/bpf.h) 2095b00ab754SHans Petter Selasky check_type_size("struct BPF_TIMEVAL" STRUCT_BPF_TIMEVAL) 2096b00ab754SHans Petter Selasky endif() 2097b00ab754SHans Petter Selasky cmake_pop_check_state() 2098*afdbf109SJoseph Mingrone 2099*afdbf109SJoseph Mingrone # 2100*afdbf109SJoseph Mingrone # Check whether there's a inet/ipnet.h header and, 2101*afdbf109SJoseph Mingrone # if so, whether it defines IPNET_ANY_LINK - if so, 2102*afdbf109SJoseph Mingrone # we assume we have the "any" device (that's a 2103*afdbf109SJoseph Mingrone # Solaris header, and later versions of Solaris 2104*afdbf109SJoseph Mingrone # have an "any" device). 2105*afdbf109SJoseph Mingrone # 2106*afdbf109SJoseph Mingrone # Attempting to include it at compile time could 2107*afdbf109SJoseph Mingrone # be a pain, as it's a kernel header. 2108*afdbf109SJoseph Mingrone # 2109*afdbf109SJoseph Mingrone message(STATUS "Checking whether the Solaris \"any\" device is supported") 2110*afdbf109SJoseph Mingrone if(EXISTS /usr/include/inet/ipnet.h) 2111*afdbf109SJoseph Mingrone file(STRINGS /usr/include/inet/ipnet.h IPNET_ANY_LINK_LINES REGEX IPNET_ANY_LINK) 2112*afdbf109SJoseph Mingrone if(NOT IPNET_ANY_LINK_LINES STREQUAL "") 2113*afdbf109SJoseph Mingrone set(HAVE_SOLARIS_ANY_DEVICE TRUE) 2114*afdbf109SJoseph Mingrone endif() 2115*afdbf109SJoseph Mingrone endif() 2116*afdbf109SJoseph Mingrone if(HAVE_SOLARIS_ANY_DEVICE) 2117*afdbf109SJoseph Mingrone message(STATUS "Checking whether the Solaris \"any\" device is supported - supported") 2118*afdbf109SJoseph Mingrone else() 2119*afdbf109SJoseph Mingrone message(STATUS "Checking whether the Solaris \"any\" device is supported - not supported") 2120*afdbf109SJoseph Mingrone endif() 21216f9cba8fSJoseph Mingrone elseif(PCAP_TYPE STREQUAL "haiku") 21226f9cba8fSJoseph Mingrone # 21236f9cba8fSJoseph Mingrone # Check for some headers just in case. 21246f9cba8fSJoseph Mingrone # 21256f9cba8fSJoseph Mingrone check_include_files("net/if.h;net/if_dl.h;net/if_types.h" HAVE_NET_IF_TYPES_H) 2126*afdbf109SJoseph Mingrone set(PCAP_SRC pcap-${PCAP_TYPE}.c) 2127b00ab754SHans Petter Selasky elseif(PCAP_TYPE STREQUAL "null") 2128b00ab754SHans Petter Selasky else() 2129b00ab754SHans Petter Selasky message(FATAL_ERROR "${PCAP_TYPE} is not a valid pcap type") 2130b00ab754SHans Petter Selasky endif() 2131b00ab754SHans Petter Selaskyendif(WIN32) 2132b00ab754SHans Petter Selasky 21336f9cba8fSJoseph Mingroneif(NOT DEFINED PCAP_SRC) 21346f9cba8fSJoseph Mingroneset(PCAP_SRC pcap-${PCAP_TYPE}.c) 21356f9cba8fSJoseph Mingroneendif() 21366f9cba8fSJoseph Mingrone 21376f9cba8fSJoseph Mingroneset(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} ${PCAP_SRC}) 2138b00ab754SHans Petter Selasky 2139b00ab754SHans Petter Selasky# 2140b00ab754SHans Petter Selasky# Now figure out how we get a list of interfaces and addresses, 2141b00ab754SHans Petter Selasky# if we support capturing. Don't bother if we don't support 2142b00ab754SHans Petter Selasky# capturing. 2143b00ab754SHans Petter Selasky# 2144b00ab754SHans Petter Selaskyif(NOT WIN32) 2145b00ab754SHans Petter Selasky # 2146b00ab754SHans Petter Selasky # UN*X - figure out what type of interface list mechanism we 2147b00ab754SHans Petter Selasky # have. 2148b00ab754SHans Petter Selasky # 2149b00ab754SHans Petter Selasky # If the capture type is null, that means we can't capture, 2150b00ab754SHans Petter Selasky # so we can't open any capture devices, so we won't return 2151b00ab754SHans Petter Selasky # any interfaces. 2152b00ab754SHans Petter Selasky # 2153b00ab754SHans Petter Selasky if(NOT PCAP_TYPE STREQUAL "null") 2154b00ab754SHans Petter Selasky cmake_push_check_state() 2155b00ab754SHans Petter Selasky set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LINK_LIBRARIES}) 2156b00ab754SHans Petter Selasky check_function_exists(getifaddrs HAVE_GETIFADDRS) 2157b00ab754SHans Petter Selasky cmake_pop_check_state() 2158b00ab754SHans Petter Selasky if(NOT HAVE_GETIFADDRS) 2159b00ab754SHans Petter Selasky # 2160b00ab754SHans Petter Selasky # It's not in the libraries that, at this point, we've 2161b00ab754SHans Petter Selasky # found we need to link libpcap with. 2162b00ab754SHans Petter Selasky # 2163b00ab754SHans Petter Selasky # It's in libsocket on Solaris and possibly other OSes; 2164b00ab754SHans Petter Selasky # as long as we're not linking with libxnet, check there. 2165b00ab754SHans Petter Selasky # 2166b00ab754SHans Petter Selasky # NOTE: if you hand check_library_exists as its last 2167b00ab754SHans Petter Selasky # argument a variable that's been set, it skips the test, 2168b00ab754SHans Petter Selasky # so we need different variables. 2169b00ab754SHans Petter Selasky # 2170b00ab754SHans Petter Selasky if(NOT LIBXNET_HAS_GETHOSTBYNAME) 2171b00ab754SHans Petter Selasky check_library_exists(socket getifaddrs "" SOCKET_HAS_GETIFADDRS) 2172b00ab754SHans Petter Selasky if(SOCKET_HAS_GETIFADDRS) 2173b00ab754SHans Petter Selasky set(PCAP_LINK_LIBRARIES socket ${PCAP_LINK_LIBRARIES}) 21746f9cba8fSJoseph Mingrone set(LIBS "-lsocket ${LIBS}") 21756f9cba8fSJoseph Mingrone set(LIBS_STATIC "-lsocket ${LIBS_STATIC}") 21766f9cba8fSJoseph Mingrone set(LIBS_PRIVATE "-lsocket ${LIBS_PRIVATE}") 2177b00ab754SHans Petter Selasky set(HAVE_GETIFADDRS TRUE) 2178b00ab754SHans Petter Selasky endif() 2179b00ab754SHans Petter Selasky endif() 2180b00ab754SHans Petter Selasky endif() 2181b00ab754SHans Petter Selasky if(HAVE_GETIFADDRS) 2182b00ab754SHans Petter Selasky # 2183b00ab754SHans Petter Selasky # We have "getifaddrs()"; make sure we have <ifaddrs.h> 2184b00ab754SHans Petter Selasky # as well, just in case some platform is really weird. 2185b00ab754SHans Petter Selasky # It may require that sys/types.h be included first, 2186b00ab754SHans Petter Selasky # so include it first. 2187b00ab754SHans Petter Selasky # 2188b00ab754SHans Petter Selasky check_include_files("sys/types.h;ifaddrs.h" HAVE_IFADDRS_H) 2189b00ab754SHans Petter Selasky if(HAVE_IFADDRS_H) 2190b00ab754SHans Petter Selasky # 2191b00ab754SHans Petter Selasky # We have the header, so we use "getifaddrs()" to 2192b00ab754SHans Petter Selasky # get the list of interfaces. 2193b00ab754SHans Petter Selasky # 2194b00ab754SHans Petter Selasky set(FINDALLDEVS_TYPE getad) 2195b00ab754SHans Petter Selasky else() 2196b00ab754SHans Petter Selasky # 2197b00ab754SHans Petter Selasky # We don't have the header - give up. 2198b00ab754SHans Petter Selasky # XXX - we could also fall back on some other 2199b00ab754SHans Petter Selasky # mechanism, but, for now, this'll catch this 2200b00ab754SHans Petter Selasky # problem so that we can at least try to figure 2201b00ab754SHans Petter Selasky # out something to do on systems with "getifaddrs()" 2202b00ab754SHans Petter Selasky # but without "ifaddrs.h", if there is something 2203b00ab754SHans Petter Selasky # we can do on those systems. 2204b00ab754SHans Petter Selasky # 2205b00ab754SHans Petter Selasky message(FATAL_ERROR "Your system has getifaddrs() but doesn't have a usable <ifaddrs.h>.") 2206b00ab754SHans Petter Selasky endif() 2207b00ab754SHans Petter Selasky else() 2208b00ab754SHans Petter Selasky # 2209b00ab754SHans Petter Selasky # Well, we don't have "getifaddrs()", at least not with the 2210b00ab754SHans Petter Selasky # libraries with which we've decided we need to link 2211b00ab754SHans Petter Selasky # libpcap with, so we have to use some other mechanism. 2212b00ab754SHans Petter Selasky # 2213b00ab754SHans Petter Selasky # Note that this may happen on Solaris, which has 2214b00ab754SHans Petter Selasky # getifaddrs(), but in -lsocket, not in -lxnet, so we 2215b00ab754SHans Petter Selasky # won't find it if we link with -lxnet, which we want 2216b00ab754SHans Petter Selasky # to do for other reasons. 2217b00ab754SHans Petter Selasky # 2218b00ab754SHans Petter Selasky # For now, we use either the SIOCGIFCONF ioctl or the 2219b00ab754SHans Petter Selasky # SIOCGLIFCONF ioctl, preferring the latter if we have 2220b00ab754SHans Petter Selasky # it; the latter is a Solarisism that first appeared 2221b00ab754SHans Petter Selasky # in Solaris 8. (Solaris's getifaddrs() appears to 2222b00ab754SHans Petter Selasky # be built atop SIOCGLIFCONF; using it directly 2223b00ab754SHans Petter Selasky # avoids a not-all-that-useful middleman.) 2224b00ab754SHans Petter Selasky # 2225b00ab754SHans Petter Selasky try_compile(HAVE_SIOCGLIFCONF ${CMAKE_CURRENT_BINARY_DIR} "${pcap_SOURCE_DIR}/cmake/have_siocglifconf.c" ) 2226b00ab754SHans Petter Selasky if(HAVE_SIOCGLIFCONF) 2227b00ab754SHans Petter Selasky set(FINDALLDEVS_TYPE glifc) 2228b00ab754SHans Petter Selasky else() 2229b00ab754SHans Petter Selasky set(FINDALLDEVS_TYPE gifc) 2230b00ab754SHans Petter Selasky endif() 2231b00ab754SHans Petter Selasky endif() 2232b00ab754SHans Petter Selasky message(STATUS "Find-interfaces mechanism type: ${FINDALLDEVS_TYPE}") 2233b00ab754SHans Petter Selasky set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} fad-${FINDALLDEVS_TYPE}.c) 2234b00ab754SHans Petter Selasky endif() 2235b00ab754SHans Petter Selaskyendif() 2236b00ab754SHans Petter Selasky 2237b00ab754SHans Petter Selasky# Check for hardware timestamp support. 2238b00ab754SHans Petter Selaskyif(CMAKE_SYSTEM_NAME STREQUAL "Linux") 2239b00ab754SHans Petter Selasky check_include_file(linux/net_tstamp.h HAVE_LINUX_NET_TSTAMP_H) 2240b00ab754SHans Petter Selaskyendif() 2241b00ab754SHans Petter Selasky 2242b00ab754SHans Petter Selasky# 2243b00ab754SHans Petter Selasky# Check for additional native sniffing capabilities. 2244b00ab754SHans Petter Selasky# 2245b00ab754SHans Petter Selasky 22466f9cba8fSJoseph Mingrone# 22476f9cba8fSJoseph Mingrone# Various Linux-specific mechanisms. 22486f9cba8fSJoseph Mingrone# 2249b00ab754SHans Petter Selaskyif(CMAKE_SYSTEM_NAME STREQUAL "Linux") 22506f9cba8fSJoseph Mingrone # Check for usbmon USB sniffing support. 22516f9cba8fSJoseph Mingrone if(NOT DISABLE_LINUX_USBMON) 22526f9cba8fSJoseph Mingrone set(PCAP_SUPPORT_LINUX_USBMON TRUE) 2253b00ab754SHans Petter Selasky set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-usb-linux.c) 2254b00ab754SHans Petter Selasky # 2255b00ab754SHans Petter Selasky # Do we have a version of <linux/compiler.h> available? 2256b00ab754SHans Petter Selasky # If so, we might need it for <linux/usbdevice_fs.h>. 2257b00ab754SHans Petter Selasky # 2258b00ab754SHans Petter Selasky check_include_files("linux/compiler.h" HAVE_LINUX_COMPILER_H) 2259b00ab754SHans Petter Selasky if(HAVE_LINUX_COMPILER_H) 2260b00ab754SHans Petter Selasky # 2261b00ab754SHans Petter Selasky # Yes - include it when testing for <linux/usbdevice_fs.h>. 2262b00ab754SHans Petter Selasky # 2263b00ab754SHans Petter Selasky check_include_files("linux/compiler.h;linux/usbdevice_fs.h" HAVE_LINUX_USBDEVICE_FS_H) 2264b00ab754SHans Petter Selasky else(HAVE_LINUX_COMPILER_H) 2265b00ab754SHans Petter Selasky check_include_files("linux/usbdevice_fs.h" HAVE_LINUX_USBDEVICE_FS_H) 2266b00ab754SHans Petter Selasky endif(HAVE_LINUX_COMPILER_H) 2267b00ab754SHans Petter Selasky if(HAVE_LINUX_USBDEVICE_FS_H) 2268b00ab754SHans Petter Selasky # 2269b00ab754SHans Petter Selasky # OK, does it define bRequestType? Older versions of the kernel 2270b00ab754SHans Petter Selasky # define fields with names like "requesttype, "request", and 2271b00ab754SHans Petter Selasky # "value", rather than "bRequestType", "bRequest", and 2272b00ab754SHans Petter Selasky # "wValue". 2273b00ab754SHans Petter Selasky # 2274b00ab754SHans Petter Selasky if(HAVE_LINUX_COMPILER_H) 2275b00ab754SHans Petter Selasky check_struct_has_member("struct usbdevfs_ctrltransfer" bRequestType "linux/compiler.h;linux/usbdevice_fs.h" HAVE_STRUCT_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE) 2276b00ab754SHans Petter Selasky else(HAVE_LINUX_COMPILER_H) 2277b00ab754SHans Petter Selasky check_struct_has_member("struct usbdevfs_ctrltransfer" bRequestType "linux/usbdevice_fs.h" HAVE_STRUCT_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE) 2278b00ab754SHans Petter Selasky endif(HAVE_LINUX_COMPILER_H) 2279b00ab754SHans Petter Selasky endif() 2280b00ab754SHans Petter Selasky endif() 2281b00ab754SHans Petter Selasky 22826f9cba8fSJoseph Mingrone # 2283b00ab754SHans Petter Selasky # Check for netfilter sniffing support. 2284b00ab754SHans Petter Selasky # 2285b00ab754SHans Petter Selasky # Life's too short to deal with trying to get this to compile 2286b00ab754SHans Petter Selasky # if you don't get the right types defined with 2287b00ab754SHans Petter Selasky # __KERNEL_STRICT_NAMES getting defined by some other include. 2288b00ab754SHans Petter Selasky # 2289b00ab754SHans Petter Selasky # Check whether the includes Just Work. If not, don't turn on 2290b00ab754SHans Petter Selasky # netfilter support. 2291b00ab754SHans Petter Selasky # 2292b00ab754SHans Petter Selasky check_c_source_compiles( 2293b00ab754SHans Petter Selasky"#include <sys/socket.h> 2294b00ab754SHans Petter Selasky#include <netinet/in.h> 2295b00ab754SHans Petter Selasky#include <linux/types.h> 2296b00ab754SHans Petter Selasky 2297b00ab754SHans Petter Selasky#include <linux/netlink.h> 2298b00ab754SHans Petter Selasky#include <linux/netfilter.h> 2299b00ab754SHans Petter Selasky#include <linux/netfilter/nfnetlink.h> 2300b00ab754SHans Petter Selasky#include <linux/netfilter/nfnetlink_log.h> 2301b00ab754SHans Petter Selasky#include <linux/netfilter/nfnetlink_queue.h> 2302b00ab754SHans Petter Selasky 2303b00ab754SHans Petter Selaskyint 2304b00ab754SHans Petter Selaskymain(void) 2305b00ab754SHans Petter Selasky{ 2306b00ab754SHans Petter Selasky return 0; 2307b00ab754SHans Petter Selasky} 2308b00ab754SHans Petter Selasky" 2309b00ab754SHans Petter Selasky PCAP_SUPPORT_NETFILTER) 2310b00ab754SHans Petter Selasky if(PCAP_SUPPORT_NETFILTER) 2311b00ab754SHans Petter Selasky set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-netfilter-linux.c) 2312b00ab754SHans Petter Selasky endif(PCAP_SUPPORT_NETFILTER) 2313b00ab754SHans Petter Selaskyendif() 2314b00ab754SHans Petter Selasky 2315b00ab754SHans Petter Selasky# Check for netmap sniffing support. 2316b00ab754SHans Petter Selaskyif(NOT DISABLE_NETMAP) 2317b00ab754SHans Petter Selasky # 2318b00ab754SHans Petter Selasky # Check whether net/netmap_user.h is usable if NETMAP_WITH_LIBS is 2319b00ab754SHans Petter Selasky # defined; it's not usable on DragonFly BSD 4.6 if NETMAP_WITH_LIBS 2320*afdbf109SJoseph Mingrone # is defined, for example, as it includes a nonexistent malloc.h 2321b00ab754SHans Petter Selasky # header. 2322b00ab754SHans Petter Selasky # 2323b00ab754SHans Petter Selasky check_c_source_compiles( 2324b00ab754SHans Petter Selasky"#define NETMAP_WITH_LIBS 2325b00ab754SHans Petter Selasky#include <net/netmap_user.h> 2326b00ab754SHans Petter Selasky 2327b00ab754SHans Petter Selaskyint 2328b00ab754SHans Petter Selaskymain(void) 2329b00ab754SHans Petter Selasky{ 2330b00ab754SHans Petter Selasky return 0; 2331b00ab754SHans Petter Selasky} 2332b00ab754SHans Petter Selasky" 2333b00ab754SHans Petter Selasky PCAP_SUPPORT_NETMAP) 2334b00ab754SHans Petter Selasky if(PCAP_SUPPORT_NETMAP) 2335b00ab754SHans Petter Selasky set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-netmap.c) 2336b00ab754SHans Petter Selasky endif(PCAP_SUPPORT_NETMAP) 2337b00ab754SHans Petter Selaskyendif() 2338b00ab754SHans Petter Selasky 23396f9cba8fSJoseph Mingrone# Check for DPDK sniffing support 23406f9cba8fSJoseph Mingroneif(NOT DISABLE_DPDK) 23416f9cba8fSJoseph Mingrone find_package(dpdk) 23426f9cba8fSJoseph Mingrone if(dpdk_FOUND) 23436f9cba8fSJoseph Mingrone # 23446f9cba8fSJoseph Mingrone # We call rte_eth_dev_count_avail(), and older versions of DPDK 23456f9cba8fSJoseph Mingrone # didn't have it, so check for it. 23466f9cba8fSJoseph Mingrone # 23476f9cba8fSJoseph Mingrone cmake_push_check_state() 23486f9cba8fSJoseph Mingrone set(CMAKE_REQUIRED_INCLUDES ${dpdk_INCLUDE_DIRS}) 23496f9cba8fSJoseph Mingrone set(CMAKE_REQUIRED_LIBRARIES ${dpdk_LIBRARIES}) 23506f9cba8fSJoseph Mingrone check_function_exists(rte_eth_dev_count_avail HAVE_RTE_ETH_DEV_COUNT_AVAIL) 23516f9cba8fSJoseph Mingrone cmake_pop_check_state() 23526f9cba8fSJoseph Mingrone if(HAVE_RTE_ETH_DEV_COUNT_AVAIL) 23536f9cba8fSJoseph Mingrone set(DPDK_C_FLAGS "-march=native") 2354*afdbf109SJoseph Mingrone set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DPDK_C_FLAGS}") 23556f9cba8fSJoseph Mingrone include_directories(AFTER ${dpdk_INCLUDE_DIRS}) 23566f9cba8fSJoseph Mingrone link_directories(AFTER ${dpdk_LIBRARIES}) 23576f9cba8fSJoseph Mingrone set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${dpdk_LIBRARIES}) 23586f9cba8fSJoseph Mingrone set(LIBS "${LIBS} ${dpdk_LIBS}") 23596f9cba8fSJoseph Mingrone set(LIBS_STATIC "${LIBS_STATIC} ${dpdk_LIBS_STATIC}") 23606f9cba8fSJoseph Mingrone set(REQUIRES_PRIVATE "${REQUIRES_PRIVATE} ${dpdk_PACKAGE_NAME}") 23616f9cba8fSJoseph Mingrone set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-dpdk.c) 23626f9cba8fSJoseph Mingrone set(PCAP_SUPPORT_DPDK TRUE) 23636f9cba8fSJoseph Mingrone 23646f9cba8fSJoseph Mingrone # 23656f9cba8fSJoseph Mingrone # Check whether the rte_ether.h file defines 23666f9cba8fSJoseph Mingrone # struct ether_addr or struct rte_ether_addr. 23676f9cba8fSJoseph Mingrone # 23686f9cba8fSJoseph Mingrone # ("API compatibility? That's for losers!") 23696f9cba8fSJoseph Mingrone # 23706f9cba8fSJoseph Mingrone cmake_push_check_state() 23716f9cba8fSJoseph Mingrone set(CMAKE_REQUIRED_INCLUDES ${dpdk_INCLUDE_DIRS}) 23726f9cba8fSJoseph Mingrone set(CMAKE_EXTRA_INCLUDE_FILES rte_ether.h) 23736f9cba8fSJoseph Mingrone check_type_size("struct rte_ether_addr" STRUCT_RTE_ETHER_ADDR) 23746f9cba8fSJoseph Mingrone cmake_pop_check_state() 23756f9cba8fSJoseph Mingrone endif() 23766f9cba8fSJoseph Mingrone else() 23776f9cba8fSJoseph Mingrone message(WARNING, 23786f9cba8fSJoseph Mingrone"We couldn't find DPDK with pkg-config. If you want DPDK support, 23796f9cba8fSJoseph Mingronemake sure that pkg-config is installed, that DPDK 18.02.2 or later is 23806f9cba8fSJoseph Mingroneinstalled, and that DPDK provides a .pc file.") 23816f9cba8fSJoseph Mingrone endif() 23826f9cba8fSJoseph Mingroneendif() 23836f9cba8fSJoseph Mingrone 2384b00ab754SHans Petter Selasky# Check for Bluetooth sniffing support 2385b00ab754SHans Petter Selaskyif(NOT DISABLE_BLUETOOTH) 2386b00ab754SHans Petter Selasky if(CMAKE_SYSTEM_NAME STREQUAL "Linux") 2387b00ab754SHans Petter Selasky check_include_file(bluetooth/bluetooth.h HAVE_BLUETOOTH_BLUETOOTH_H) 2388b00ab754SHans Petter Selasky if(HAVE_BLUETOOTH_BLUETOOTH_H) 2389b00ab754SHans Petter Selasky set(PCAP_SUPPORT_BT TRUE) 2390b00ab754SHans Petter Selasky set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-bt-linux.c) 2391b00ab754SHans Petter Selasky # 2392b00ab754SHans Petter Selasky # OK, does struct sockaddr_hci have an hci_channel 2393b00ab754SHans Petter Selasky # member? 2394b00ab754SHans Petter Selasky # 2395b00ab754SHans Petter Selasky check_struct_has_member("struct sockaddr_hci" hci_channel "bluetooth/bluetooth.h;bluetooth/hci.h" HAVE_STRUCT_SOCKADDR_HCI_HCI_CHANNEL) 2396b00ab754SHans Petter Selasky if(HAVE_STRUCT_SOCKADDR_HCI_HCI_CHANNEL) 2397b00ab754SHans Petter Selasky # 2398b00ab754SHans Petter Selasky # OK, is HCI_CHANNEL_MONITOR defined? 2399b00ab754SHans Petter Selasky # 2400b00ab754SHans Petter Selasky check_c_source_compiles( 2401b00ab754SHans Petter Selasky"#include <bluetooth/bluetooth.h> 2402b00ab754SHans Petter Selasky#include <bluetooth/hci.h> 2403b00ab754SHans Petter Selasky 2404b00ab754SHans Petter Selaskyint 2405b00ab754SHans Petter Selaskymain(void) 2406b00ab754SHans Petter Selasky{ 2407*afdbf109SJoseph Mingrone int i = HCI_CHANNEL_MONITOR; 2408b00ab754SHans Petter Selasky return 0; 2409b00ab754SHans Petter Selasky} 2410b00ab754SHans Petter Selasky" 2411b00ab754SHans Petter Selasky PCAP_SUPPORT_BT_MONITOR) 2412b00ab754SHans Petter Selasky if(PCAP_SUPPORT_BT_MONITOR) 2413b00ab754SHans Petter Selasky # 2414b00ab754SHans Petter Selasky # Yes, so we can also support Bluetooth monitor 2415b00ab754SHans Petter Selasky # sniffing. 2416b00ab754SHans Petter Selasky # 2417b00ab754SHans Petter Selasky set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-bt-monitor-linux.c) 2418b00ab754SHans Petter Selasky endif(PCAP_SUPPORT_BT_MONITOR) 2419b00ab754SHans Petter Selasky endif(HAVE_STRUCT_SOCKADDR_HCI_HCI_CHANNEL) 2420b00ab754SHans Petter Selasky endif(HAVE_BLUETOOTH_BLUETOOTH_H) 2421b00ab754SHans Petter Selasky endif() 24226f9cba8fSJoseph Mingroneelse() 24236f9cba8fSJoseph Mingrone unset(PCAP_SUPPORT_BT_MONITOR CACHE) 2424b00ab754SHans Petter Selaskyendif() 2425b00ab754SHans Petter Selasky 24266f9cba8fSJoseph Mingrone# Check for D-Bus sniffing support 2427b00ab754SHans Petter Selaskyif(NOT DISABLE_DBUS) 2428b00ab754SHans Petter Selasky # 2429b00ab754SHans Petter Selasky # We don't support D-Bus sniffing on macOS; see 2430b00ab754SHans Petter Selasky # 2431b00ab754SHans Petter Selasky # https://bugs.freedesktop.org/show_bug.cgi?id=74029 2432b00ab754SHans Petter Selasky # 2433b00ab754SHans Petter Selasky if(APPLE) 2434b00ab754SHans Petter Selasky message(FATAL_ERROR "Due to freedesktop.org bug 74029, D-Bus capture support is not available on macOS") 2435b00ab754SHans Petter Selasky endif(APPLE) 2436b00ab754SHans Petter Selasky pkg_check_modules(DBUS dbus-1) 2437b00ab754SHans Petter Selasky if(DBUS_FOUND) 2438b00ab754SHans Petter Selasky set(PCAP_SUPPORT_DBUS TRUE) 2439b00ab754SHans Petter Selasky set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-dbus.c) 2440b00ab754SHans Petter Selasky include_directories(${DBUS_INCLUDE_DIRS}) 244157e22627SCy Schubert 244257e22627SCy Schubert # 244357e22627SCy Schubert # This "helpfully" supplies DBUS_LIBRARIES as a bunch of 244457e22627SCy Schubert # library names - not paths - and DBUS_LIBRARY_DIRS as 244557e22627SCy Schubert # a bunch of directories. 244657e22627SCy Schubert # 244757e22627SCy Schubert # CMake *really* doesn't like the notion of specifying "here are 244857e22627SCy Schubert # the directories in which to look for libraries" except in 244957e22627SCy Schubert # find_library() calls; it *really* prefers using full paths to 245057e22627SCy Schubert # library files, rather than library names. 245157e22627SCy Schubert # 245257e22627SCy Schubert # Find the libraries and add their full paths. 245357e22627SCy Schubert # 245457e22627SCy Schubert set(DBUS_LIBRARY_FULLPATHS) 245557e22627SCy Schubert foreach(_lib IN LISTS DBUS_LIBRARIES) 245657e22627SCy Schubert # 245757e22627SCy Schubert # Try to find this library, so we get its full path. 245857e22627SCy Schubert # 245957e22627SCy Schubert find_library(_libfullpath ${_lib} HINTS ${DBUS_LIBRARY_DIRS}) 246057e22627SCy Schubert list(APPEND DBUS_LIBRARY_FULLPATHS ${_libfullpath}) 246157e22627SCy Schubert endforeach() 246257e22627SCy Schubert set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${DBUS_LIBRARY_FULLPATHS}) 24636f9cba8fSJoseph Mingrone 24646f9cba8fSJoseph Mingrone # 24656f9cba8fSJoseph Mingrone # Get library information for DPDK. 24666f9cba8fSJoseph Mingrone # 24676f9cba8fSJoseph Mingrone pkg_get_link_info(DBUS dbus-1) 24686f9cba8fSJoseph Mingrone set(LIBS "${LIBS} ${DBUS_LIBS}") 24696f9cba8fSJoseph Mingrone set(LIBS_STATIC "${LIBS_STATIC} ${DBUS_LIBS_STATIC}") 24706f9cba8fSJoseph Mingrone set(REQUIRES_PRIVATE "${REQUIRES_PRIVATE} ${DBUS_PACKAGE_NAME}") 2471b00ab754SHans Petter Selasky endif(DBUS_FOUND) 2472b00ab754SHans Petter Selaskyendif(NOT DISABLE_DBUS) 2473b00ab754SHans Petter Selasky 2474b00ab754SHans Petter Selasky# Check for RDMA sniffing support 2475b00ab754SHans Petter Selaskyif(NOT DISABLE_RDMA) 24766f9cba8fSJoseph Mingrone pkg_check_modules(LIBIBVERBS libibverbs) 24776f9cba8fSJoseph Mingrone if(LIBIBVERBS_FOUND) 24786f9cba8fSJoseph Mingrone # 24796f9cba8fSJoseph Mingrone # pkg-config found it; remember its pkg-config name. 24806f9cba8fSJoseph Mingrone # 24816f9cba8fSJoseph Mingrone set(LIBIBVERBS_REQUIRES_PRIVATE ${LIBIBVERBS_PACKAGE_NAME}) 24826f9cba8fSJoseph Mingrone 24836f9cba8fSJoseph Mingrone # 24846f9cba8fSJoseph Mingrone # Get static linking information for it. 24856f9cba8fSJoseph Mingrone # 24866f9cba8fSJoseph Mingrone pkg_get_link_info(LIBIBVERBS libibverbs) 24876f9cba8fSJoseph Mingrone else() 24886f9cba8fSJoseph Mingrone # 24896f9cba8fSJoseph Mingrone # pkg-config didn't find it; try to look for it ourselves 24906f9cba8fSJoseph Mingrone # 2491b00ab754SHans Petter Selasky check_library_exists(ibverbs ibv_get_device_list "" LIBIBVERBS_HAS_IBV_GET_DEVICE_LIST) 2492b00ab754SHans Petter Selasky if(LIBIBVERBS_HAS_IBV_GET_DEVICE_LIST) 24936f9cba8fSJoseph Mingrone set(LIBIBVERBS_FOUND TRUE) 24946f9cba8fSJoseph Mingrone set(LIBIBVERBS_LIBRARIES ibverbs) 24956f9cba8fSJoseph Mingrone # XXX - at least on Ubuntu 20.04, there are many more 24966f9cba8fSJoseph Mingrone # libraries needed; is there any platform where 24976f9cba8fSJoseph Mingrone # libibverbs is available but where pkg-config 24986f9cba8fSJoseph Mingrone # isn't available or libibverbs doesn't use it? 24996f9cba8fSJoseph Mingrone # If not, we should only use pkg-config for it. 25006f9cba8fSJoseph Mingrone set(LIBIBVERBS_STATIC_LIBRARIES ibverbs) 25016f9cba8fSJoseph Mingrone set(LIBIBVERBS_LIBS -libverbs) 25026f9cba8fSJoseph Mingrone set(LIBIBVERBS_LIBS_STATIC -libverbs) 25036f9cba8fSJoseph Mingrone set(LIBIBVERBS_LIBS_PRIVATE -libverbs) 25046f9cba8fSJoseph Mingrone endif() 25056f9cba8fSJoseph Mingrone endif() 25066f9cba8fSJoseph Mingrone if(LIBIBVERBS_FOUND) 25076f9cba8fSJoseph Mingrone # 25086f9cba8fSJoseph Mingrone # For unknown reasons, check_include_file() doesn't just attempt 25096f9cba8fSJoseph Mingrone # to compile a test program that includes the header in 25106f9cba8fSJoseph Mingrone # question, it also attempts to link it. 25116f9cba8fSJoseph Mingrone # 25126f9cba8fSJoseph Mingrone # For unknown reasons, at least some of the static inline 25136f9cba8fSJoseph Mingrone # functions defined in infiniband/verbs.h are not inlined by the 25146f9cba8fSJoseph Mingrone # Sun^WOracle Studio C compiler, so the compiler generates code 25156f9cba8fSJoseph Mingrone # for them as part of the object code resulting from compiling 25166f9cba8fSJoseph Mingrone # the test program. At lest some of those functions call 25176f9cba8fSJoseph Mingrone # routines in -libverbs, so, in order to keep the compile and 25186f9cba8fSJoseph Mingrone # link from failing, even though the header file exists and is 25196f9cba8fSJoseph Mingrone # usable, we need to link with -libverbs. 25206f9cba8fSJoseph Mingrone # 25216f9cba8fSJoseph Mingrone cmake_push_check_state() 25226f9cba8fSJoseph Mingrone set(CMAKE_REQUIRED_LIBRARIES ${LIBIBVERBS_LIBRARIES}) 2523b00ab754SHans Petter Selasky check_include_file(infiniband/verbs.h HAVE_INFINIBAND_VERBS_H) 2524b00ab754SHans Petter Selasky if(HAVE_INFINIBAND_VERBS_H) 2525b00ab754SHans Petter Selasky check_symbol_exists(ibv_create_flow infiniband/verbs.h PCAP_SUPPORT_RDMASNIFF) 2526b00ab754SHans Petter Selasky if(PCAP_SUPPORT_RDMASNIFF) 2527b00ab754SHans Petter Selasky set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-rdmasniff.c) 25286f9cba8fSJoseph Mingrone set(PCAP_LINK_LIBRARIES ${LIBIBVERBS_LIBRARIES} ${PCAP_LINK_LIBRARIES}) 25296f9cba8fSJoseph Mingrone set(LIBS "${LIBIBVERBS_LIBS} ${LIBS}") 25306f9cba8fSJoseph Mingrone set(LIBS_STATIC "${LIBIBVERBS_LIBS_STATIC} ${LIBS_STATIC}") 25316f9cba8fSJoseph Mingrone set(LIBS_PRIVATE "${LIBIBVERBS_LIBS_PRIVATE} ${LIBS_PRIVATE}") 25326f9cba8fSJoseph Mingrone set(REQUIRES_PRIVATE "${REQUIRES_PRIVATE} ${LIBIBVERBS_PACKAGE_NAME}") 2533b00ab754SHans Petter Selasky endif(PCAP_SUPPORT_RDMASNIFF) 2534b00ab754SHans Petter Selasky endif(HAVE_INFINIBAND_VERBS_H) 25356f9cba8fSJoseph Mingrone cmake_pop_check_state() 25366f9cba8fSJoseph Mingrone endif(LIBIBVERBS_FOUND) 2537b00ab754SHans Petter Selaskyendif(NOT DISABLE_RDMA) 2538b00ab754SHans Petter Selasky 2539b00ab754SHans Petter Selasky# 2540b00ab754SHans Petter Selasky# Check for sniffing capabilities using third-party APIs. 2541b00ab754SHans Petter Selasky# 2542b00ab754SHans Petter Selasky 2543b00ab754SHans Petter Selasky# Check for Endace DAG card support. 2544b00ab754SHans Petter Selaskyif(NOT DISABLE_DAG) 2545b00ab754SHans Petter Selasky # 2546b00ab754SHans Petter Selasky # Try to find the DAG header file and library. 2547b00ab754SHans Petter Selasky # 2548b00ab754SHans Petter Selasky find_package(DAG) 2549b00ab754SHans Petter Selasky 2550b00ab754SHans Petter Selasky # 2551b00ab754SHans Petter Selasky # Did we succeed? 2552b00ab754SHans Petter Selasky # 2553b00ab754SHans Petter Selasky if(DAG_FOUND) 2554b00ab754SHans Petter Selasky # 2555b00ab754SHans Petter Selasky # Yes. 2556b00ab754SHans Petter Selasky # Check for various DAG API functions. 2557b00ab754SHans Petter Selasky # 2558b00ab754SHans Petter Selasky cmake_push_check_state() 2559b00ab754SHans Petter Selasky set(CMAKE_REQUIRED_INCLUDES ${DAG_INCLUDE_DIRS}) 2560b00ab754SHans Petter Selasky set(CMAKE_REQUIRED_LIBRARIES ${DAG_LIBRARIES}) 2561b00ab754SHans Petter Selasky check_function_exists(dag_attach_stream HAVE_DAG_STREAMS_API) 2562b00ab754SHans Petter Selasky if(NOT HAVE_DAG_STREAMS_API) 2563b00ab754SHans Petter Selasky message(FATAL_ERROR "DAG library lacks streams support") 2564b00ab754SHans Petter Selasky endif() 2565b00ab754SHans Petter Selasky check_function_exists(dag_attach_stream64 HAVE_DAG_LARGE_STREAMS_API) 2566b00ab754SHans Petter Selasky check_function_exists(dag_get_erf_types HAVE_DAG_GET_ERF_TYPES) 2567b00ab754SHans Petter Selasky check_function_exists(dag_get_stream_erf_types HAVE_DAG_GET_STREAM_ERF_TYPES) 2568b00ab754SHans Petter Selasky cmake_pop_check_state() 2569b00ab754SHans Petter Selasky 2570b00ab754SHans Petter Selasky include_directories(AFTER ${DAG_INCLUDE_DIRS}) 2571b00ab754SHans Petter Selasky set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-dag.c) 2572b00ab754SHans Petter Selasky set(HAVE_DAG_API TRUE) 2573b00ab754SHans Petter Selasky set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${DAG_LIBRARIES}) 25746f9cba8fSJoseph Mingrone set(LIBS "${LIBS} ${DAG_LIBS}") 25756f9cba8fSJoseph Mingrone set(LIBS_STATIC "${LIBS_STATIC} ${DAG_LIBS_STATIC}") 25766f9cba8fSJoseph Mingrone set(LIBS_PRIVATE "${LIBS_PRIVATE} ${DAG_LIBS_PRIVATE}") 2577b00ab754SHans Petter Selasky 2578b00ab754SHans Petter Selasky if(HAVE_DAG_LARGE_STREAMS_API) 2579b00ab754SHans Petter Selasky get_filename_component(DAG_LIBRARY_DIR ${DAG_LIBRARY} PATH) 2580b00ab754SHans Petter Selasky check_library_exists(vdag vdag_set_device_info ${DAG_LIBRARY_DIR} HAVE_DAG_VDAG) 2581b00ab754SHans Petter Selasky if(HAVE_DAG_VDAG) 2582b00ab754SHans Petter Selasky set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 25836f9cba8fSJoseph Mingrone set(LIBS "${LIBS} ${CMAKE_THREAD_LIBS_INIT}") 25846f9cba8fSJoseph Mingrone set(LIBS_STATIC "${LIBS_STATIC} ${CMAKE_THREAD_LIBS_INIT}") 25856f9cba8fSJoseph Mingrone set(LIBS_PRIVATE "${LIBS_PRIVATE} ${CMAKE_THREAD_LIBS_INIT}") 2586b00ab754SHans Petter Selasky endif() 2587b00ab754SHans Petter Selasky endif() 2588b00ab754SHans Petter Selasky endif() 2589b00ab754SHans Petter Selaskyendif() 2590b00ab754SHans Petter Selasky 2591b00ab754SHans Petter Selasky# Check for Septel card support. 2592b00ab754SHans Petter Selaskyset(PROJECT_EXTERNAL_OBJECT_LIST "") 2593b00ab754SHans Petter Selaskyif(NOT DISABLE_SEPTEL) 2594b00ab754SHans Petter Selasky # 2595b00ab754SHans Petter Selasky # Do we have the msg.h header? 2596b00ab754SHans Petter Selasky # 2597b00ab754SHans Petter Selasky set(SEPTEL_INCLUDE_DIRS "${SEPTEL_ROOT}/INC") 2598b00ab754SHans Petter Selasky cmake_push_check_state() 2599b00ab754SHans Petter Selasky set(CMAKE_REQUIRED_INCLUDES ${SEPTEL_INCLUDE_DIRS}) 2600b00ab754SHans Petter Selasky check_include_file(msg.h HAVE_INC_MSG_H) 2601b00ab754SHans Petter Selasky cmake_pop_check_state() 2602b00ab754SHans Petter Selasky if(HAVE_INC_MSG_H) 2603b00ab754SHans Petter Selasky # 2604b00ab754SHans Petter Selasky # Yes. 2605b00ab754SHans Petter Selasky # 2606b00ab754SHans Petter Selasky include_directories(AFTER ${SEPTEL_INCLUDE_DIRS}) 2607b00ab754SHans Petter Selasky set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-septel.c) 2608b00ab754SHans Petter Selasky set(PROJECT_EXTERNAL_OBJECT_LIST ${PROJECT_EXTERNAL_OBJECT_LIST} "${SEPTEL_ROOT}/asciibin.o ${SEPTEL_ROOT}/bit2byte.o ${SEPTEL_ROOT}/confirm.o ${SEPTEL_ROOT}/fmtmsg.o ${SEPTEL_ROOT}/gct_unix.o ${SEPTEL_ROOT}/hqueue.o ${SEPTEL_ROOT}/ident.o ${SEPTEL_ROOT}/mem.o ${SEPTEL_ROOT}/pack.o ${SEPTEL_ROOT}/parse.o ${SEPTEL_ROOT}/pool.o ${SEPTEL_ROOT}/sdlsig.o ${SEPTEL_ROOT}/strtonum.o ${SEPTEL_ROOT}/timer.o ${SEPTEL_ROOT}/trace.o") 2609b00ab754SHans Petter Selasky set(HAVE_SEPTEL_API TRUE) 2610b00ab754SHans Petter Selasky endif() 2611b00ab754SHans Petter Selaskyendif() 2612b00ab754SHans Petter Selasky 2613b00ab754SHans Petter Selasky# Check for Myricom SNF support. 2614b00ab754SHans Petter Selaskyif(NOT DISABLE_SNF) 2615b00ab754SHans Petter Selasky # 2616b00ab754SHans Petter Selasky # Try to find the SNF header file and library. 2617b00ab754SHans Petter Selasky # 2618b00ab754SHans Petter Selasky find_package(SNF) 2619b00ab754SHans Petter Selasky 2620b00ab754SHans Petter Selasky # 2621b00ab754SHans Petter Selasky # Did we succeed? 2622b00ab754SHans Petter Selasky # 2623b00ab754SHans Petter Selasky if(SNF_FOUND) 2624b00ab754SHans Petter Selasky # 2625b00ab754SHans Petter Selasky # Yes. 2626b00ab754SHans Petter Selasky # 2627b00ab754SHans Petter Selasky include_directories(AFTER ${SNF_INCLUDE_DIRS}) 2628b00ab754SHans Petter Selasky set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-snf.c) 2629b00ab754SHans Petter Selasky set(HAVE_SNF_API TRUE) 2630b00ab754SHans Petter Selasky set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${SNF_LIBRARIES}) 26316f9cba8fSJoseph Mingrone set(LIBS "${LIBS_STATIC} ${SNF_LIBS}") 26326f9cba8fSJoseph Mingrone set(LIBS_STATIC "${LIBS_STATIC} ${SNF_LIBS_STATIC}") 26336f9cba8fSJoseph Mingrone set(LIBS_PRIVATE "${LIBS_PRIVATE} ${SNF_LIBS_PRIVATE}") 26346f9cba8fSJoseph Mingrone endif() 26356f9cba8fSJoseph Mingroneendif() 26366f9cba8fSJoseph Mingrone 26376f9cba8fSJoseph Mingrone# Check for Riverbed AirPcap support. 26386f9cba8fSJoseph Mingroneif(NOT DISABLE_AIRPCAP) 26396f9cba8fSJoseph Mingrone # 26406f9cba8fSJoseph Mingrone # Try to find the AirPcap header file and library. 26416f9cba8fSJoseph Mingrone # 26426f9cba8fSJoseph Mingrone find_package(AirPcap) 26436f9cba8fSJoseph Mingrone 26446f9cba8fSJoseph Mingrone # 26456f9cba8fSJoseph Mingrone # Did we succeed? 26466f9cba8fSJoseph Mingrone # 26476f9cba8fSJoseph Mingrone if(AirPcap_FOUND) 26486f9cba8fSJoseph Mingrone # 26496f9cba8fSJoseph Mingrone # Yes. 26506f9cba8fSJoseph Mingrone # 26516f9cba8fSJoseph Mingrone include_directories(AFTER ${AirPcap_INCLUDE_DIRS}) 26526f9cba8fSJoseph Mingrone set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-airpcap.c) 26536f9cba8fSJoseph Mingrone set(HAVE_AIRPCAP_API TRUE) 26546f9cba8fSJoseph Mingrone set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${AirPcap_LIBRARIES}) 2655b00ab754SHans Petter Selasky endif() 2656b00ab754SHans Petter Selaskyendif() 2657b00ab754SHans Petter Selasky 2658b00ab754SHans Petter Selasky# Check for Riverbed TurboCap support. 2659b00ab754SHans Petter Selaskyif(NOT DISABLE_TC) 2660b00ab754SHans Petter Selasky # 2661b00ab754SHans Petter Selasky # Try to find the TurboCap header file and library. 2662b00ab754SHans Petter Selasky # 2663b00ab754SHans Petter Selasky find_package(TC) 2664b00ab754SHans Petter Selasky 2665b00ab754SHans Petter Selasky # 2666b00ab754SHans Petter Selasky # Did we succeed? 2667b00ab754SHans Petter Selasky # 2668b00ab754SHans Petter Selasky if(TC_FOUND) 2669b00ab754SHans Petter Selasky # 2670b00ab754SHans Petter Selasky # Yes. 2671b00ab754SHans Petter Selasky # 2672b00ab754SHans Petter Selasky include_directories(AFTER ${TC_INCLUDE_DIRS}) 2673b00ab754SHans Petter Selasky set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-tc.c) 2674b00ab754SHans Petter Selasky set(HAVE_TC_API TRUE) 26756f9cba8fSJoseph Mingrone set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${TC_LIBRARIES} ${CMAKE_USE_PTHREADS_INIT} stdc++) 2676b00ab754SHans Petter Selasky endif() 2677b00ab754SHans Petter Selaskyendif() 2678b00ab754SHans Petter Selasky 2679b00ab754SHans Petter Selasky# 2680b00ab754SHans Petter Selasky# Remote capture support. 2681b00ab754SHans Petter Selasky# 2682b00ab754SHans Petter Selasky 2683b00ab754SHans Petter Selaskyif(ENABLE_REMOTE) 2684b00ab754SHans Petter Selasky # 2685b00ab754SHans Petter Selasky # Check for various members of struct msghdr. 2686b00ab754SHans Petter Selasky # We need to include ftmacros.h on some platforms, to make sure we 2687b00ab754SHans Petter Selasky # get the POSIX/Single USER Specification version of struct msghdr, 2688b00ab754SHans Petter Selasky # which has those members, rather than the backwards-compatible 2689b00ab754SHans Petter Selasky # version, which doesn't. That's not a system header file, and 2690b00ab754SHans Petter Selasky # at least some versions of CMake include it as <ftmacros.h>, which 2691b00ab754SHans Petter Selasky # won't check the current directory, so we add the top-level 2692b00ab754SHans Petter Selasky # source directory to the list of include directories when we do 2693b00ab754SHans Petter Selasky # the check. 2694b00ab754SHans Petter Selasky # 2695b00ab754SHans Petter Selasky cmake_push_check_state() 269657e22627SCy Schubert set(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}) 2697b00ab754SHans Petter Selasky check_struct_has_member("struct msghdr" msg_control "ftmacros.h;sys/socket.h" HAVE_STRUCT_MSGHDR_MSG_CONTROL) 2698b00ab754SHans Petter Selasky check_struct_has_member("struct msghdr" msg_flags "ftmacros.h;sys/socket.h" HAVE_STRUCT_MSGHDR_MSG_FLAGS) 2699b00ab754SHans Petter Selasky cmake_pop_check_state() 2700b00ab754SHans Petter Selasky set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} 27016f9cba8fSJoseph Mingrone pcap-new.c pcap-rpcap.c rpcap-protocol.c sockutils.c sslutils.c) 2702b00ab754SHans Petter Selaskyendif(ENABLE_REMOTE) 2703b00ab754SHans Petter Selasky 2704b00ab754SHans Petter Selasky################################################################### 2705b00ab754SHans Petter Selasky# Warning options 2706b00ab754SHans Petter Selasky################################################################### 2707b00ab754SHans Petter Selasky 2708b00ab754SHans Petter Selasky# 2709b00ab754SHans Petter Selasky# Check and add warning options if we have a .devel file. 2710b00ab754SHans Petter Selasky# 271157e22627SCy Schubertif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.devel OR EXISTS ${CMAKE_BINARY_DIR}/.devel) 2712b00ab754SHans Petter Selasky # 2713b00ab754SHans Petter Selasky # Warning options. 2714b00ab754SHans Petter Selasky # 2715b00ab754SHans Petter Selasky if(MSVC AND NOT ${CMAKE_C_COMPILER} MATCHES "clang*") 2716b00ab754SHans Petter Selasky # 2717b00ab754SHans Petter Selasky # MSVC, with Microsoft's front end and code generator. 2718b00ab754SHans Petter Selasky # "MSVC" is also set for Microsoft's compiler with a Clang 2719b00ab754SHans Petter Selasky # front end and their code generator ("Clang/C2"), so we 2720b00ab754SHans Petter Selasky # check for clang.exe and treat that differently. 2721b00ab754SHans Petter Selasky # 2722b00ab754SHans Petter Selasky check_and_add_compiler_option(-Wall) 2723b00ab754SHans Petter Selasky # 2724b00ab754SHans Petter Selasky # Disable some pointless warnings that /Wall turns on. 2725b00ab754SHans Petter Selasky # 2726b00ab754SHans Petter Selasky # Unfortunately, MSVC does not appear to have an equivalent 2727b00ab754SHans Petter Selasky # to "__attribute__((unused))" to mark a particular function 2728b00ab754SHans Petter Selasky # parameter as being known to be unused, so that the compiler 2729b00ab754SHans Petter Selasky # won't warn about it (for example, the function might have 2730b00ab754SHans Petter Selasky # that parameter because a pointer to it is being used, and 2731b00ab754SHans Petter Selasky # the signature of that function includes that parameter). 2732b00ab754SHans Petter Selasky # C++ lets you give a parameter a type but no name, but C 2733b00ab754SHans Petter Selasky # doesn't have that. 2734b00ab754SHans Petter Selasky # 2735b00ab754SHans Petter Selasky check_and_add_compiler_option(-wd4100) 2736b00ab754SHans Petter Selasky # 2737b00ab754SHans Petter Selasky # In theory, we care whether somebody uses f() rather than 2738b00ab754SHans Petter Selasky # f(void) to declare a function with no arguments, but, in 2739b00ab754SHans Petter Selasky # practice, there are places in the Windows header files 2740b00ab754SHans Petter Selasky # that appear to do that, so we squelch that warning. 2741b00ab754SHans Petter Selasky # 2742b00ab754SHans Petter Selasky check_and_add_compiler_option(-wd4255) 2743b00ab754SHans Petter Selasky # 2744b00ab754SHans Petter Selasky # Windows FD_SET() generates this, so we suppress it. 2745b00ab754SHans Petter Selasky # 2746b00ab754SHans Petter Selasky check_and_add_compiler_option(-wd4548) 2747b00ab754SHans Petter Selasky # 2748b00ab754SHans Petter Selasky # Perhaps testing something #defined to be 0 with #ifdef is an 2749b00ab754SHans Petter Selasky # error, and it should be tested with #if, but perhaps it's 2750b00ab754SHans Petter Selasky # not, and Microsoft does that in its headers, so we squelch 2751b00ab754SHans Petter Selasky # that warning. 2752b00ab754SHans Petter Selasky # 2753b00ab754SHans Petter Selasky check_and_add_compiler_option(-wd4574) 2754b00ab754SHans Petter Selasky # 2755b00ab754SHans Petter Selasky # The Windows headers also test not-defined values in #if, so 2756b00ab754SHans Petter Selasky # we don't want warnings about that, either. 2757b00ab754SHans Petter Selasky # 2758b00ab754SHans Petter Selasky check_and_add_compiler_option(-wd4668) 2759b00ab754SHans Petter Selasky # 2760b00ab754SHans Petter Selasky # We do *not* care whether some function is, or isn't, going to be 2761b00ab754SHans Petter Selasky # expanded inline. 2762b00ab754SHans Petter Selasky # 2763b00ab754SHans Petter Selasky check_and_add_compiler_option(-wd4710) 2764b00ab754SHans Petter Selasky check_and_add_compiler_option(-wd4711) 2765b00ab754SHans Petter Selasky # 2766b00ab754SHans Petter Selasky # We do *not* care whether we're adding padding bytes after 2767b00ab754SHans Petter Selasky # structure members. 2768b00ab754SHans Petter Selasky # 2769b00ab754SHans Petter Selasky check_and_add_compiler_option(-wd4820) 27706f9cba8fSJoseph Mingrone # 27716f9cba8fSJoseph Mingrone # We do *not* care about every single place the compiler would 27726f9cba8fSJoseph Mingrone # have inserted Spectre mitigation if only we had told it to 27736f9cba8fSJoseph Mingrone # do so with /Qspectre. Maybe it's worth it, as that's in 27746f9cba8fSJoseph Mingrone # Bison-generated code that we don't control. 27756f9cba8fSJoseph Mingrone # 27766f9cba8fSJoseph Mingrone # XXX - add /Qspectre if that is really worth doing. 27776f9cba8fSJoseph Mingrone # 27786f9cba8fSJoseph Mingrone check_and_add_compiler_option(-wd5045) 27796f9cba8fSJoseph Mingrone 27806f9cba8fSJoseph Mingrone # 27816f9cba8fSJoseph Mingrone # Treat all (remaining) warnings as errors. 27826f9cba8fSJoseph Mingrone # 27836f9cba8fSJoseph Mingrone check_and_add_compiler_option(-WX) 2784b00ab754SHans Petter Selasky else() 2785b00ab754SHans Petter Selasky # 2786b00ab754SHans Petter Selasky # Other compilers, including MSVC with a Clang front end and 2787b00ab754SHans Petter Selasky # Microsoft's code generator. We currently treat them as if 2788b00ab754SHans Petter Selasky # they might support GCC-style -W options. 2789b00ab754SHans Petter Selasky # 2790*afdbf109SJoseph Mingrone check_and_add_compiler_option(-W) 2791b00ab754SHans Petter Selasky check_and_add_compiler_option(-Wall) 2792b00ab754SHans Petter Selasky check_and_add_compiler_option(-Wcomma) 2793b00ab754SHans Petter Selasky # Warns about safeguards added in case the enums are extended 2794b00ab754SHans Petter Selasky # check_and_add_compiler_option(-Wcovered-switch-default) 27956f9cba8fSJoseph Mingrone check_and_add_compiler_option(-Wdocumentation) 2796b00ab754SHans Petter Selasky check_and_add_compiler_option(-Wformat-nonliteral) 27976f9cba8fSJoseph Mingrone check_and_add_compiler_option(-Wmissing-noreturn) 27986f9cba8fSJoseph Mingrone check_and_add_compiler_option(-Wmissing-prototypes) 27996f9cba8fSJoseph Mingrone check_and_add_compiler_option(-Wmissing-variable-declarations) 2800*afdbf109SJoseph Mingrone check_and_add_compiler_option(-Wnull-pointer-subtraction) 28016f9cba8fSJoseph Mingrone check_and_add_compiler_option(-Wpointer-arith) 28026f9cba8fSJoseph Mingrone check_and_add_compiler_option(-Wpointer-sign) 28036f9cba8fSJoseph Mingrone check_and_add_compiler_option(-Wshadow) 28046f9cba8fSJoseph Mingrone check_and_add_compiler_option(-Wshorten-64-to-32) 2805*afdbf109SJoseph Mingrone check_and_add_compiler_option(-Wsign-compare) 28066f9cba8fSJoseph Mingrone check_and_add_compiler_option(-Wstrict-prototypes) 2807*afdbf109SJoseph Mingrone check_and_add_compiler_option(-Wundef) 2808b00ab754SHans Petter Selasky check_and_add_compiler_option(-Wunreachable-code) 2809*afdbf109SJoseph Mingrone check_and_add_compiler_option(-Wunused-but-set-parameter) 2810*afdbf109SJoseph Mingrone check_and_add_compiler_option(-Wunused-but-set-variable) 28116f9cba8fSJoseph Mingrone check_and_add_compiler_option(-Wunused-parameter) 28126f9cba8fSJoseph Mingrone check_and_add_compiler_option(-Wused-but-marked-unused) 2813b00ab754SHans Petter Selasky endif() 2814b00ab754SHans Petter Selaskyendif() 2815b00ab754SHans Petter Selasky 2816b00ab754SHans Petter Selasky# 2817b00ab754SHans Petter Selasky# Suppress some warnings we get with MSVC even without /Wall. 2818b00ab754SHans Petter Selasky# 2819b00ab754SHans Petter Selaskyif(MSVC AND NOT ${CMAKE_C_COMPILER} MATCHES "clang*") 2820b00ab754SHans Petter Selasky # 2821b00ab754SHans Petter Selasky # Yes, we have some functions that never return but that 2822b00ab754SHans Petter Selasky # have a non-void return type. That's because, on some 2823b00ab754SHans Petter Selasky # platforms, they *do* return values but, on other 2824b00ab754SHans Petter Selasky # platforms, including Windows, they just fail and 2825b00ab754SHans Petter Selasky # longjmp out by calling bpf_error(). 2826b00ab754SHans Petter Selasky # 2827b00ab754SHans Petter Selasky check_and_add_compiler_option(-wd4646) 2828b00ab754SHans Petter Selaskyendif() 2829b00ab754SHans Petter Selasky 2830b00ab754SHans Petter Selaskyfile(GLOB PROJECT_SOURCE_LIST_H 2831b00ab754SHans Petter Selasky *.h 2832b00ab754SHans Petter Selasky pcap/*.h 2833b00ab754SHans Petter Selasky) 2834b00ab754SHans Petter Selasky 2835b00ab754SHans Petter Selasky# 2836b00ab754SHans Petter Selasky# Try to have the compiler default to hiding symbols, so that only 2837b00ab754SHans Petter Selasky# symbols explicitly exported with PCAP_API will be visible outside 2838b00ab754SHans Petter Selasky# (shared) libraries. 2839b00ab754SHans Petter Selasky# 2840b00ab754SHans Petter Selasky# Not necessary with MSVC, as that's the default. 2841b00ab754SHans Petter Selasky# 2842b00ab754SHans Petter Selasky# XXX - we don't use ADD_COMPILER_EXPORT_FLAGS, because, as of CMake 2843b00ab754SHans Petter Selasky# 2.8.12.2, it doesn't know about Sun C/Oracle Studio, and, as of 2844b00ab754SHans Petter Selasky# CMake 2.8.6, it only sets the C++ compiler flags, rather than 2845b00ab754SHans Petter Selasky# allowing an arbitrary variable to be set with the "hide symbols 2846b00ab754SHans Petter Selasky# not explicitly exported" flag. 2847b00ab754SHans Petter Selasky# 2848b00ab754SHans Petter Selaskyif(NOT MSVC) 2849b00ab754SHans Petter Selasky if(CMAKE_C_COMPILER_ID MATCHES "SunPro") 2850b00ab754SHans Petter Selasky # 2851b00ab754SHans Petter Selasky # Sun C/Oracle Studio. 2852b00ab754SHans Petter Selasky # 2853b00ab754SHans Petter Selasky check_and_add_compiler_option(-xldscope=hidden) 2854b00ab754SHans Petter Selasky else() 2855b00ab754SHans Petter Selasky # 2856b00ab754SHans Petter Selasky # Try this for all other compilers; it's what GCC uses, 2857b00ab754SHans Petter Selasky # and a number of other compilers, such as Clang and Intel C, 2858b00ab754SHans Petter Selasky # use it as well. 2859b00ab754SHans Petter Selasky # 2860b00ab754SHans Petter Selasky check_and_add_compiler_option(-fvisibility=hidden) 2861b00ab754SHans Petter Selasky endif() 2862b00ab754SHans Petter Selaskyendif(NOT MSVC) 2863b00ab754SHans Petter Selasky 2864b00ab754SHans Petter Selasky# 28656f9cba8fSJoseph Mingrone# Extra compiler options for the build matrix scripts to request -Werror or 28666f9cba8fSJoseph Mingrone# its equivalent if required. The CMake variable name cannot be CFLAGS 28676f9cba8fSJoseph Mingrone# because that is already used for a different purpose in CMake. Example 28686f9cba8fSJoseph Mingrone# usage: cmake -DEXTRA_CFLAGS='-Wall -Wextra -Werror' ... 28696f9cba8fSJoseph Mingrone# 28706f9cba8fSJoseph Mingroneif(NOT "${EXTRA_CFLAGS}" STREQUAL "") 2871*afdbf109SJoseph Mingrone # The meaning of EXTRA_CFLAGS is "use the exact specified options, or the 2872*afdbf109SJoseph Mingrone # build risks failing to fail", not "try every specified option, omit those 2873*afdbf109SJoseph Mingrone # that do not work and use the rest". Thus use add_compile_options(), not 2874*afdbf109SJoseph Mingrone # foreach()/check_and_add_compiler_option(). Another reason to do that is 2875*afdbf109SJoseph Mingrone # that the effect lasts in testprogs/ and testprogs/fuzz/. 2876*afdbf109SJoseph Mingrone string(REPLACE " " ";" _extra_cflags_list ${EXTRA_CFLAGS}) 2877*afdbf109SJoseph Mingrone add_compile_options(${_extra_cflags_list}) 28786f9cba8fSJoseph Mingrone message(STATUS "Added extra compile options (${EXTRA_CFLAGS})") 28796f9cba8fSJoseph Mingroneendif() 28806f9cba8fSJoseph Mingrone 28816f9cba8fSJoseph Mingrone# 2882b00ab754SHans Petter Selasky# Flex/Lex and YACC/Berkeley YACC/Bison. 2883b00ab754SHans Petter Selasky# From a mail message to the CMake mailing list by Andy Cedilnik of 2884b00ab754SHans Petter Selasky# Kitware. 2885b00ab754SHans Petter Selasky# 2886b00ab754SHans Petter Selasky 2887b00ab754SHans Petter Selasky# 2888b00ab754SHans Petter Selasky# Try to find Flex, a Windows version of Flex, or Lex. 2889b00ab754SHans Petter Selasky# 2890b00ab754SHans Petter Selaskyfind_program(LEX_EXECUTABLE NAMES flex win_flex lex) 2891b00ab754SHans Petter Selaskyif(LEX_EXECUTABLE STREQUAL "LEX_EXECUTABLE-NOTFOUND") 2892b00ab754SHans Petter Selasky message(FATAL_ERROR "Neither flex nor win_flex nor lex was found.") 2893b00ab754SHans Petter Selaskyendif() 2894b00ab754SHans Petter Selaskymessage(STATUS "Lexical analyzer generator: ${LEX_EXECUTABLE}") 2895b00ab754SHans Petter Selasky 28966f9cba8fSJoseph Mingrone# 28976f9cba8fSJoseph Mingrone# Make sure {f}lex supports the -P, --header-file, and --nounput flags 28986f9cba8fSJoseph Mingrone# and supports processing our scanner.l. 28996f9cba8fSJoseph Mingrone# 29006f9cba8fSJoseph Mingroneif(WIN32) 29016f9cba8fSJoseph Mingrone set(NULL_DEVICE "NUL:") 29026f9cba8fSJoseph Mingroneelse() 29036f9cba8fSJoseph Mingrone set(NULL_DEVICE "/dev/null") 29046f9cba8fSJoseph Mingroneendif() 29056f9cba8fSJoseph Mingroneexecute_process(COMMAND ${LEX_EXECUTABLE} -P pcap_ --header-file=${NULL_DEVICE} --nounput -t ${pcap_SOURCE_DIR}/scanner.l 29066f9cba8fSJoseph Mingrone OUTPUT_QUIET RESULT_VARIABLE EXIT_STATUS) 29076f9cba8fSJoseph Mingroneif(NOT EXIT_STATUS EQUAL 0) 29086f9cba8fSJoseph Mingrone message(FATAL_ERROR "${LEX_EXECUTABLE} is insufficient to compile libpcap. 29096f9cba8fSJoseph Mingronelibpcap requires Flex 2.5.31 or later, or a compatible version of lex. 29106f9cba8fSJoseph MingroneIf a suitable version of Lex/Flex is available as a non-standard command 29116f9cba8fSJoseph Mingroneand/or not in the PATH, you can specify it using the LEX environment 29126f9cba8fSJoseph Mingronevariable. That said, on some systems the error can mean that Flex/Lex is 29136f9cba8fSJoseph Mingroneactually acceptable, but m4 is not. Likewise, if a suitable version of 29146f9cba8fSJoseph Mingronem4 (such as GNU M4) is available but has not been detected, you can 29156f9cba8fSJoseph Mingronespecify it using the M4 environment variable.") 29166f9cba8fSJoseph Mingroneendif() 29176f9cba8fSJoseph Mingrone 2918b00ab754SHans Petter Selaskyadd_custom_command( 2919b00ab754SHans Petter Selasky OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/scanner.c ${CMAKE_CURRENT_BINARY_DIR}/scanner.h 2920b00ab754SHans Petter Selasky SOURCE ${pcap_SOURCE_DIR}/scanner.l 2921b00ab754SHans Petter Selasky COMMAND ${LEX_EXECUTABLE} -P pcap_ --header-file=scanner.h --nounput -o${CMAKE_CURRENT_BINARY_DIR}/scanner.c ${pcap_SOURCE_DIR}/scanner.l 2922b00ab754SHans Petter Selasky DEPENDS ${pcap_SOURCE_DIR}/scanner.l 2923b00ab754SHans Petter Selasky) 2924b00ab754SHans Petter Selasky 2925b00ab754SHans Petter Selasky# 2926b00ab754SHans Petter Selasky# Since scanner.c does not exist yet when cmake is run, mark 2927b00ab754SHans Petter Selasky# it as generated. 2928b00ab754SHans Petter Selasky# 2929b00ab754SHans Petter Selasky# Since scanner.c includes grammar.h, mark that as a dependency. 2930b00ab754SHans Petter Selasky# 2931b00ab754SHans Petter Selaskyset_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/scanner.c PROPERTIES 2932b00ab754SHans Petter Selasky GENERATED TRUE 2933b00ab754SHans Petter Selasky OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/grammar.h 2934b00ab754SHans Petter Selasky) 2935b00ab754SHans Petter Selasky 2936b00ab754SHans Petter Selasky# 2937b00ab754SHans Petter Selasky# Add scanner.c to the list of sources. 2938b00ab754SHans Petter Selasky# 2939b00ab754SHans Petter Selasky#set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} ${CMAKE_CURRENT_BINARY_DIR}/scanner.c) 2940b00ab754SHans Petter Selasky 2941b00ab754SHans Petter Selasky# 2942b00ab754SHans Petter Selasky# Try to find YACC or Bison. 2943b00ab754SHans Petter Selasky# 2944b00ab754SHans Petter Selaskyfind_program(YACC_EXECUTABLE NAMES bison win_bison byacc yacc) 2945b00ab754SHans Petter Selaskyif(YACC_EXECUTABLE STREQUAL "YACC_EXECUTABLE-NOTFOUND") 2946b00ab754SHans Petter Selasky message(FATAL_ERROR "Neither bison nor win_bison nor byacc nor yacc was found.") 2947b00ab754SHans Petter Selaskyendif() 29486f9cba8fSJoseph Mingrone 29496f9cba8fSJoseph Mingroneif(YACC_EXECUTABLE MATCHES "byacc" OR YACC_EXECUTABLE MATCHES "yacc") 29506f9cba8fSJoseph Mingrone # 29516f9cba8fSJoseph Mingrone # Make sure this is Berkeley YACC, not AT&T YACC; 29526f9cba8fSJoseph Mingrone # the latter doesn't support reentrant parsers. 29536f9cba8fSJoseph Mingrone # Run it with "-V"; that succeeds and reports the 29546f9cba8fSJoseph Mingrone # version number with Berkeley YACC, but will 29556f9cba8fSJoseph Mingrone # (probably) fail with various vendor flavors 29566f9cba8fSJoseph Mingrone # of AT&T YACC. 29576f9cba8fSJoseph Mingrone # 29586f9cba8fSJoseph Mingrone # Hopefully this also eliminates any versions 29596f9cba8fSJoseph Mingrone # of Berkeley YACC that don't support reentrant 29606f9cba8fSJoseph Mingrone # parsers, if there are any. 29616f9cba8fSJoseph Mingrone # 29626f9cba8fSJoseph Mingrone execute_process(COMMAND ${YACC_EXECUTABLE} -V OUTPUT_QUIET 29636f9cba8fSJoseph Mingrone RESULT_VARIABLE EXIT_STATUS) 29646f9cba8fSJoseph Mingrone if(NOT EXIT_STATUS EQUAL 0) 29656f9cba8fSJoseph Mingrone message(FATAL_ERROR "${YACC_EXECUTABLE} is insufficient to compile libpcap. 29666f9cba8fSJoseph Mingronelibpcap requires Bison, a newer version of Berkeley YACC with support 29676f9cba8fSJoseph Mingronefor reentrant parsers, or another YACC compatible with them.") 29686f9cba8fSJoseph Mingrone endif() 29696f9cba8fSJoseph Mingrone # 29706f9cba8fSJoseph Mingrone # Berkeley YACC doesn't support "%define api.pure", so use 29716f9cba8fSJoseph Mingrone # "%pure-parser". 29726f9cba8fSJoseph Mingrone # 29736f9cba8fSJoseph Mingrone set(REENTRANT_PARSER "%pure-parser") 29746f9cba8fSJoseph Mingroneelse() 29756f9cba8fSJoseph Mingrone # 29766f9cba8fSJoseph Mingrone # Bison prior to 2.4(.1) doesn't support "%define api.pure", so use 29776f9cba8fSJoseph Mingrone # "%pure-parser". 29786f9cba8fSJoseph Mingrone # 29796f9cba8fSJoseph Mingrone execute_process(COMMAND ${YACC_EXECUTABLE} -V OUTPUT_VARIABLE bison_full_version) 29806f9cba8fSJoseph Mingrone string(REGEX MATCH "[1-9][0-9]*[.][0-9]+" bison_major_minor ${bison_full_version}) 29816f9cba8fSJoseph Mingrone if (bison_major_minor VERSION_LESS "2.4") 29826f9cba8fSJoseph Mingrone set(REENTRANT_PARSER "%pure-parser") 29836f9cba8fSJoseph Mingrone else() 29846f9cba8fSJoseph Mingrone set(REENTRANT_PARSER "%define api.pure") 29856f9cba8fSJoseph Mingrone endif() 29866f9cba8fSJoseph Mingroneendif() 29876f9cba8fSJoseph Mingrone 2988b00ab754SHans Petter Selaskymessage(STATUS "Parser generator: ${YACC_EXECUTABLE}") 2989b00ab754SHans Petter Selasky 2990b00ab754SHans Petter Selasky# 2991b00ab754SHans Petter Selasky# Create custom command for the scanner. 2992b00ab754SHans Petter Selasky# 2993b00ab754SHans Petter Selaskyadd_custom_command( 2994b00ab754SHans Petter Selasky OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/grammar.c ${CMAKE_CURRENT_BINARY_DIR}/grammar.h 29956f9cba8fSJoseph Mingrone SOURCE ${pcap_BINARY_DIR}/grammar.y 29966f9cba8fSJoseph Mingrone COMMAND ${YACC_EXECUTABLE} -p pcap_ -o ${CMAKE_CURRENT_BINARY_DIR}/grammar.c -d ${pcap_BINARY_DIR}/grammar.y 29976f9cba8fSJoseph Mingrone DEPENDS ${pcap_BINARY_DIR}/grammar.y 2998b00ab754SHans Petter Selasky) 2999b00ab754SHans Petter Selasky 3000b00ab754SHans Petter Selasky# 3001b00ab754SHans Petter Selasky# Since grammar.c does not exists yet when cmake is run, mark 3002b00ab754SHans Petter Selasky# it as generated. 3003b00ab754SHans Petter Selasky# 3004b00ab754SHans Petter Selaskyset_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/grammar.c PROPERTIES 3005b00ab754SHans Petter Selasky GENERATED TRUE 3006b00ab754SHans Petter Selasky OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/scanner.h 3007b00ab754SHans Petter Selasky) 3008b00ab754SHans Petter Selasky 3009b00ab754SHans Petter Selasky# 3010b00ab754SHans Petter Selasky# Add grammar.c to the list of sources. 3011b00ab754SHans Petter Selasky# 3012b00ab754SHans Petter Selasky#set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} ${CMAKE_CURRENT_BINARY_DIR}/grammar.c) 3013b00ab754SHans Petter Selasky 3014b00ab754SHans Petter Selasky# 3015b00ab754SHans Petter Selasky# Assume, by default, no support for shared libraries and V7/BSD 301657e22627SCy Schubert# convention for man pages (devices in section 4, file formats in 301757e22627SCy Schubert# section 5, miscellaneous info in section 7, administrative commands 301857e22627SCy Schubert# and daemons in section 8). Individual cases can override this. 3019b00ab754SHans Petter Selasky# Individual cases can override this. 3020b00ab754SHans Petter Selasky# 302157e22627SCy Schubertset(MAN_DEVICES 4) 3022b00ab754SHans Petter Selaskyset(MAN_FILE_FORMATS 5) 3023b00ab754SHans Petter Selaskyset(MAN_MISC_INFO 7) 3024b00ab754SHans Petter Selaskyset(MAN_ADMIN_COMMANDS 8) 3025b00ab754SHans Petter Selaskyif(CMAKE_SYSTEM_NAME STREQUAL "AIX") 3026b00ab754SHans Petter Selasky # Workaround to enable certain features 3027b00ab754SHans Petter Selasky set(_SUN TRUE) 3028b00ab754SHans Petter Selasky if(PCAP_TYPE STREQUAL "bpf") 3029b00ab754SHans Petter Selasky # 3030b00ab754SHans Petter Selasky # If we're using BPF, we need libodm and libcfg, as 3031b00ab754SHans Petter Selasky # we use them to load the BPF module. 3032b00ab754SHans Petter Selasky # 3033b00ab754SHans Petter Selasky set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} odm cfg) 30346f9cba8fSJoseph Mingrone set(LIBS "${LIBS} -lodm -lcfg") 30356f9cba8fSJoseph Mingrone set(LIBS_STATIC "${LIBS_STATIC} -lodm -lcfg") 30366f9cba8fSJoseph Mingrone set(LIBS_PRIVATE "${LIBS_PRIVATE} -lodm -lcfg") 3037b00ab754SHans Petter Selasky endif() 3038b00ab754SHans Petter Selaskyelseif(CMAKE_SYSTEM_NAME STREQUAL "HP-UX") 3039b00ab754SHans Petter Selasky if(CMAKE_SYSTEM_VERSION MATCHES "[A-Z.]*9\.[0-9]*") 3040b00ab754SHans Petter Selasky # 3041b00ab754SHans Petter Selasky # HP-UX 9.x. 3042b00ab754SHans Petter Selasky # 3043b00ab754SHans Petter Selasky set(HAVE_HPUX9 TRUE) 3044b00ab754SHans Petter Selasky elseif(CMAKE_SYSTEM_VERSION MATCHES "[A-Z.]*10\.0") 3045b00ab754SHans Petter Selasky # 3046b00ab754SHans Petter Selasky # HP-UX 10.0. 3047b00ab754SHans Petter Selasky # 3048b00ab754SHans Petter Selasky elseif(CMAKE_SYSTEM_VERSION MATCHES "[A-Z.]*10\.1") 3049b00ab754SHans Petter Selasky # 3050b00ab754SHans Petter Selasky # HP-UX 10.1. 3051b00ab754SHans Petter Selasky # 3052b00ab754SHans Petter Selasky else() 3053b00ab754SHans Petter Selasky # 3054b00ab754SHans Petter Selasky # HP-UX 10.20 and later. 3055b00ab754SHans Petter Selasky # 3056b00ab754SHans Petter Selasky set(HAVE_HPUX10_20_OR_LATER TRUE) 3057b00ab754SHans Petter Selasky endif() 3058b00ab754SHans Petter Selasky 3059b00ab754SHans Petter Selasky # 3060b00ab754SHans Petter Selasky # Use System V conventions for man pages. 3061b00ab754SHans Petter Selasky # 3062b00ab754SHans Petter Selasky set(MAN_ADMIN_COMMANDS 1m) 3063b00ab754SHans Petter Selasky set(MAN_FILE_FORMATS 4) 3064b00ab754SHans Petter Selasky set(MAN_MISC_INFO 5) 3065b00ab754SHans Petter Selaskyelseif(CMAKE_SYSTEM_NAME STREQUAL "IRIX" OR CMAKE_SYSTEM_NAME STREQUAL "IRIX64") 3066b00ab754SHans Petter Selasky # 3067b00ab754SHans Petter Selasky # Use IRIX conventions for man pages; they're the same as the 3068b00ab754SHans Petter Selasky # System V conventions, except that they use section 8 for 3069b00ab754SHans Petter Selasky # administrative commands and daemons. 3070b00ab754SHans Petter Selasky # 3071b00ab754SHans Petter Selasky set(MAN_FILE_FORMATS 4) 3072b00ab754SHans Petter Selasky set(MAN_MISC_INFO 5) 3073b00ab754SHans Petter Selaskyelseif(CMAKE_SYSTEM_NAME STREQUAL "OSF1") 3074b00ab754SHans Petter Selasky # 30756f9cba8fSJoseph Mingrone # DEC OSF/1, a/k/a Digital UNIX, a/k/a Tru64 UNIX. 3076b00ab754SHans Petter Selasky # Use Tru64 UNIX conventions for man pages; they're the same as the 3077b00ab754SHans Petter Selasky # System V conventions except that they use section 8 for 3078b00ab754SHans Petter Selasky # administrative commands and daemons. 3079b00ab754SHans Petter Selasky # 3080b00ab754SHans Petter Selasky set(MAN_FILE_FORMATS 4) 3081b00ab754SHans Petter Selasky set(MAN_MISC_INFO 5) 308257e22627SCy Schubert set(MAN_DEVICES 7) 3083b00ab754SHans Petter Selaskyelseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*") 3084b00ab754SHans Petter Selasky # 3085b00ab754SHans Petter Selasky # SunOS 5.x. 3086b00ab754SHans Petter Selasky # 3087b00ab754SHans Petter Selasky set(HAVE_SOLARIS TRUE) 3088b00ab754SHans Petter Selasky # 3089b00ab754SHans Petter Selasky # Make sure errno is thread-safe, in case we're called in 3090b00ab754SHans Petter Selasky # a multithreaded program. We don't guarantee that two 3091b00ab754SHans Petter Selasky # threads can use the *same* pcap_t safely, but the 3092b00ab754SHans Petter Selasky # current version does guarantee that you can use different 3093b00ab754SHans Petter Selasky # pcap_t's in different threads, and even that pcap_compile() 3094b00ab754SHans Petter Selasky # is thread-safe (it wasn't thread-safe in some older versions). 3095b00ab754SHans Petter Selasky # 3096b00ab754SHans Petter Selasky add_definitions(-D_TS_ERRNO) 3097b00ab754SHans Petter Selasky 3098b00ab754SHans Petter Selasky if(CMAKE_SYSTEM_VERSION STREQUAL "5.12") 3099b00ab754SHans Petter Selasky else() 3100b00ab754SHans Petter Selasky # 3101b00ab754SHans Petter Selasky # Use System V conventions for man pages. 3102b00ab754SHans Petter Selasky # 3103b00ab754SHans Petter Selasky set(MAN_ADMIN_COMMANDS 1m) 3104b00ab754SHans Petter Selasky set(MAN_FILE_FORMATS 4) 3105b00ab754SHans Petter Selasky set(MAN_MISC_INFO 5) 310657e22627SCy Schubert set(MAN_DEVICES 7D) 3107b00ab754SHans Petter Selasky endif() 31086f9cba8fSJoseph Mingroneelseif(CMAKE_SYSTEM_NAME STREQUAL "Haiku") 31096f9cba8fSJoseph Mingrone # 31106f9cba8fSJoseph Mingrone # Haiku needs _BSD_SOURCE for the _IO* macros because it doesn't use them. 31116f9cba8fSJoseph Mingrone # 31126f9cba8fSJoseph Mingrone add_definitions(-D_BSD_SOURCE) 3113b00ab754SHans Petter Selaskyendif() 3114b00ab754SHans Petter Selasky 3115b00ab754SHans Petter Selaskysource_group("Source Files" FILES ${PROJECT_SOURCE_LIST_C}) 3116b00ab754SHans Petter Selaskysource_group("Header Files" FILES ${PROJECT_SOURCE_LIST_H}) 3117b00ab754SHans Petter Selasky 3118b00ab754SHans Petter Selaskyif(WIN32) 3119b00ab754SHans Petter Selasky # 3120b00ab754SHans Petter Selasky # Add pcap-dll.rc to the list of sources. 3121b00ab754SHans Petter Selasky # 3122b00ab754SHans Petter Selasky set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} ${pcap_SOURCE_DIR}/pcap-dll.rc) 3123b00ab754SHans Petter Selaskyendif(WIN32) 3124b00ab754SHans Petter Selasky 3125b00ab754SHans Petter Selasky# 3126b00ab754SHans Petter Selasky# Add subdirectories after we've set various variables, so they pick up 3127b00ab754SHans Petter Selasky# pick up those variables. 3128b00ab754SHans Petter Selasky# 3129b00ab754SHans Petter Selaskyif(ENABLE_REMOTE) 3130b00ab754SHans Petter Selasky add_subdirectory(rpcapd) 3131b00ab754SHans Petter Selaskyendif(ENABLE_REMOTE) 3132b00ab754SHans Petter Selaskyadd_subdirectory(testprogs) 3133b00ab754SHans Petter Selasky 3134b00ab754SHans Petter Selasky###################################### 3135b00ab754SHans Petter Selasky# Register targets 3136b00ab754SHans Petter Selasky###################################### 3137b00ab754SHans Petter Selasky 3138b00ab754SHans Petter Selasky# 3139b00ab754SHans Petter Selasky# Special target to serialize the building of the generated source. 3140b00ab754SHans Petter Selasky# 3141b00ab754SHans Petter Selasky# See 3142b00ab754SHans Petter Selasky# 31436f9cba8fSJoseph Mingrone# https://public.kitware.com/pipermail/cmake/2013-August/055510.html 3144b00ab754SHans Petter Selasky# 3145b00ab754SHans Petter Selaskyadd_custom_target(SerializeTarget 3146b00ab754SHans Petter Selasky DEPENDS 3147b00ab754SHans Petter Selasky ${CMAKE_CURRENT_BINARY_DIR}/grammar.c 3148b00ab754SHans Petter Selasky ${CMAKE_CURRENT_BINARY_DIR}/scanner.c 3149b00ab754SHans Petter Selasky) 3150b00ab754SHans Petter Selasky 3151b00ab754SHans Petter Selaskyset_source_files_properties(${PROJECT_EXTERNAL_OBJECT_LIST} PROPERTIES 3152b00ab754SHans Petter Selasky EXTERNAL_OBJECT TRUE) 3153b00ab754SHans Petter Selasky 3154b00ab754SHans Petter Selaskyif(BUILD_SHARED_LIBS) 3155b00ab754SHans Petter Selasky add_library(${LIBRARY_NAME} SHARED 3156b00ab754SHans Petter Selasky ${PROJECT_SOURCE_LIST_C} 3157b00ab754SHans Petter Selasky ${CMAKE_CURRENT_BINARY_DIR}/grammar.c 3158b00ab754SHans Petter Selasky ${CMAKE_CURRENT_BINARY_DIR}/scanner.c 3159b00ab754SHans Petter Selasky ${PROJECT_EXTERNAL_OBJECT_LIST} 3160b00ab754SHans Petter Selasky ) 3161*afdbf109SJoseph Mingrone target_include_directories(${LIBRARY_NAME} PUBLIC 3162*afdbf109SJoseph Mingrone $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> 3163*afdbf109SJoseph Mingrone $<INSTALL_INTERFACE:include> 3164*afdbf109SJoseph Mingrone ) 3165b00ab754SHans Petter Selasky add_dependencies(${LIBRARY_NAME} SerializeTarget) 3166b00ab754SHans Petter Selasky set_target_properties(${LIBRARY_NAME} PROPERTIES 3167b00ab754SHans Petter Selasky COMPILE_DEFINITIONS BUILDING_PCAP) 316857e22627SCy Schubert # 316957e22627SCy Schubert # No matter what the library is called - it might be called "wpcap" 317057e22627SCy Schubert # in a Windows build - the symbol to define to indicate that we're 317157e22627SCy Schubert # building the library, rather than a program using the library, 317257e22627SCy Schubert # and thus that we're exporting functions defined in our public 317357e22627SCy Schubert # header files, rather than importing those functions, is 317457e22627SCy Schubert # pcap_EXPORTS. 317557e22627SCy Schubert # 317657e22627SCy Schubert set_target_properties(${LIBRARY_NAME} PROPERTIES 317757e22627SCy Schubert DEFINE_SYMBOL pcap_EXPORTS) 31786f9cba8fSJoseph Mingrone if(NOT "${LINKER_FLAGS}" STREQUAL "") 31796f9cba8fSJoseph Mingrone set_target_properties(${LIBRARY_NAME} PROPERTIES 31806f9cba8fSJoseph Mingrone LINK_FLAGS "${LINKER_FLAGS}") 31816f9cba8fSJoseph Mingrone endif() 3182b00ab754SHans Petter Selaskyendif(BUILD_SHARED_LIBS) 3183b00ab754SHans Petter Selasky 3184b00ab754SHans Petter Selaskyadd_library(${LIBRARY_NAME}_static STATIC 3185b00ab754SHans Petter Selasky ${PROJECT_SOURCE_LIST_C} 3186b00ab754SHans Petter Selasky ${CMAKE_CURRENT_BINARY_DIR}/grammar.c 3187b00ab754SHans Petter Selasky ${CMAKE_CURRENT_BINARY_DIR}/scanner.c 3188b00ab754SHans Petter Selasky ${PROJECT_EXTERNAL_OBJECT_LIST} 3189b00ab754SHans Petter Selasky) 3190*afdbf109SJoseph Mingronetarget_include_directories(${LIBRARY_NAME}_static PUBLIC 3191*afdbf109SJoseph Mingrone $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> 3192*afdbf109SJoseph Mingrone $<INSTALL_INTERFACE:include> 3193*afdbf109SJoseph Mingrone) 3194b00ab754SHans Petter Selaskyadd_dependencies(${LIBRARY_NAME}_static SerializeTarget) 3195b00ab754SHans Petter Selaskyset_target_properties(${LIBRARY_NAME}_static PROPERTIES 3196b00ab754SHans Petter Selasky COMPILE_DEFINITIONS BUILDING_PCAP) 3197b00ab754SHans Petter Selasky 3198b00ab754SHans Petter Selaskyif(WIN32) 3199b00ab754SHans Petter Selasky if(BUILD_SHARED_LIBS) 3200b00ab754SHans Petter Selasky set_target_properties(${LIBRARY_NAME} PROPERTIES 3201b00ab754SHans Petter Selasky VERSION ${PACKAGE_VERSION_NOSUFFIX} # only MAJOR and MINOR are needed 3202b00ab754SHans Petter Selasky ) 3203b00ab754SHans Petter Selasky endif(BUILD_SHARED_LIBS) 3204b00ab754SHans Petter Selasky if(MSVC) 3205b00ab754SHans Petter Selasky # XXX For DLLs, the TARGET_PDB_FILE generator expression can be used to locate 3206b00ab754SHans Petter Selasky # its PDB file's output directory for installation. 3207b00ab754SHans Petter Selasky # cmake doesn't offer a generator expression for PDB files generated by the 3208b00ab754SHans Petter Selasky # compiler (static libraries). 3209b00ab754SHans Petter Selasky # So instead of considering any possible output there is (there are many), 3210b00ab754SHans Petter Selasky # this will search for the PDB file in the compiler's initial output directory, 3211b00ab754SHans Petter Selasky # which is always ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles\wpcap_static.dir 3212b00ab754SHans Petter Selasky # regardless of architecture, build generator etc. 3213b00ab754SHans Petter Selasky # Quite hackish indeed. 3214b00ab754SHans Petter Selasky set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:${LIBRARY_NAME}_static>) 3215b00ab754SHans Petter Selasky set_target_properties(${LIBRARY_NAME}_static PROPERTIES 3216b00ab754SHans Petter Selasky COMPILE_PDB_NAME ${LIBRARY_NAME}_static 3217b00ab754SHans Petter Selasky OUTPUT_NAME "${LIBRARY_NAME}_static" 3218b00ab754SHans Petter Selasky ) 3219b00ab754SHans Petter Selasky elseif(MINGW) 3220b00ab754SHans Petter Selasky # 3221b00ab754SHans Petter Selasky # For compatibility, build the shared library without the "lib" prefix on 3222b00ab754SHans Petter Selasky # MinGW as well. 3223b00ab754SHans Petter Selasky # 3224b00ab754SHans Petter Selasky set_target_properties(${LIBRARY_NAME} PROPERTIES 3225b00ab754SHans Petter Selasky PREFIX "" 3226b00ab754SHans Petter Selasky OUTPUT_NAME "${LIBRARY_NAME}" 3227b00ab754SHans Petter Selasky ) 3228b00ab754SHans Petter Selasky set_target_properties(${LIBRARY_NAME}_static PROPERTIES 3229b00ab754SHans Petter Selasky OUTPUT_NAME "${LIBRARY_NAME}" 3230b00ab754SHans Petter Selasky ) 3231b00ab754SHans Petter Selasky endif() 3232b00ab754SHans Petter Selaskyelse(WIN32) # UN*X 3233b00ab754SHans Petter Selasky if(BUILD_SHARED_LIBS) 3234b00ab754SHans Petter Selasky if(APPLE) 3235b00ab754SHans Petter Selasky set_target_properties(${LIBRARY_NAME} PROPERTIES 3236b00ab754SHans Petter Selasky VERSION ${PACKAGE_VERSION} 3237b00ab754SHans Petter Selasky SOVERSION A 3238b00ab754SHans Petter Selasky ) 3239b00ab754SHans Petter Selasky else(APPLE) 3240b00ab754SHans Petter Selasky set_target_properties(${LIBRARY_NAME} PROPERTIES 3241b00ab754SHans Petter Selasky VERSION ${PACKAGE_VERSION} 3242b00ab754SHans Petter Selasky SOVERSION ${PACKAGE_VERSION_MAJOR} 3243b00ab754SHans Petter Selasky ) 3244b00ab754SHans Petter Selasky endif(APPLE) 3245b00ab754SHans Petter Selasky endif(BUILD_SHARED_LIBS) 3246b00ab754SHans Petter Selasky set_target_properties(${LIBRARY_NAME}_static PROPERTIES 3247b00ab754SHans Petter Selasky OUTPUT_NAME "${LIBRARY_NAME}" 3248b00ab754SHans Petter Selasky ) 3249b00ab754SHans Petter Selaskyendif(WIN32) 3250b00ab754SHans Petter Selasky 3251b00ab754SHans Petter Selaskyif(BUILD_SHARED_LIBS) 3252b00ab754SHans Petter Selasky if(NOT C_ADDITIONAL_FLAGS STREQUAL "") 3253b00ab754SHans Petter Selasky set_target_properties(${LIBRARY_NAME} PROPERTIES COMPILE_FLAGS ${C_ADDITIONAL_FLAGS}) 3254b00ab754SHans Petter Selasky endif() 3255*afdbf109SJoseph Mingrone 3256*afdbf109SJoseph Mingrone # 3257*afdbf109SJoseph Mingrone # If this is macOS and we've picked the default architectures on 3258*afdbf109SJoseph Mingrone # which to build, build the library on them. 3259*afdbf109SJoseph Mingrone # 3260*afdbf109SJoseph Mingrone if(APPLE AND "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "") 3261*afdbf109SJoseph Mingrone set_target_properties(${LIBRARY_NAME} PROPERTIES 3262*afdbf109SJoseph Mingrone OSX_ARCHITECTURES "${OSX_LIBRARY_ARCHITECTURES}") 3263*afdbf109SJoseph Mingrone endif() 3264b00ab754SHans Petter Selasky target_link_libraries(${LIBRARY_NAME} ${PCAP_LINK_LIBRARIES}) 3265b00ab754SHans Petter Selaskyendif(BUILD_SHARED_LIBS) 3266b00ab754SHans Petter Selasky 3267b00ab754SHans Petter Selaskyif(NOT C_ADDITIONAL_FLAGS STREQUAL "") 3268b00ab754SHans Petter Selasky set_target_properties(${LIBRARY_NAME}_static PROPERTIES COMPILE_FLAGS ${C_ADDITIONAL_FLAGS}) 3269b00ab754SHans Petter Selaskyendif() 3270b00ab754SHans Petter Selasky 327157e22627SCy Schubert# 3272*afdbf109SJoseph Mingrone# If this is macOS and we've picked the default architectures on 3273*afdbf109SJoseph Mingrone# which to build, build the library on them. 327457e22627SCy Schubert# 327557e22627SCy Schubertif(APPLE AND "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "") 327657e22627SCy Schubert set_target_properties(${LIBRARY_NAME}_static PROPERTIES 327757e22627SCy Schubert OSX_ARCHITECTURES "${OSX_LIBRARY_ARCHITECTURES}") 327857e22627SCy Schubertendif() 327957e22627SCy Schubert 3280b00ab754SHans Petter Selasky###################################### 3281b00ab754SHans Petter Selasky# Write out the config.h file 3282b00ab754SHans Petter Selasky###################################### 3283b00ab754SHans Petter Selasky 3284b00ab754SHans Petter Selaskyconfigure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) 3285b00ab754SHans Petter Selasky 3286b00ab754SHans Petter Selasky###################################### 32876f9cba8fSJoseph Mingrone# Write out the grammar.y file 32886f9cba8fSJoseph Mingrone###################################### 32896f9cba8fSJoseph Mingrone 32906f9cba8fSJoseph Mingroneconfigure_file(${CMAKE_CURRENT_SOURCE_DIR}/grammar.y.in ${CMAKE_CURRENT_BINARY_DIR}/grammar.y @ONLY) 32916f9cba8fSJoseph Mingrone 32926f9cba8fSJoseph Mingrone###################################### 3293b00ab754SHans Petter Selasky# Install pcap library, include files, and man pages 3294b00ab754SHans Petter Selasky###################################### 3295b00ab754SHans Petter Selasky 3296b00ab754SHans Petter Selasky# 3297b00ab754SHans Petter Selasky# "Define GNU standard installation directories", which actually 3298b00ab754SHans Petter Selasky# are also defined, to some degree, by autotools, and at least 3299b00ab754SHans Petter Selasky# some of which are general UN*X conventions. 3300b00ab754SHans Petter Selasky# 3301b00ab754SHans Petter Selaskyinclude(GNUInstallDirs) 3302b00ab754SHans Petter Selasky 3303b00ab754SHans Petter Selaskyset(LIBRARY_NAME_STATIC ${LIBRARY_NAME}_static) 3304b00ab754SHans Petter Selasky 3305b00ab754SHans Petter Selaskyfunction(install_manpage_symlink SOURCE TARGET MANDIR) 3306b00ab754SHans Petter Selasky if(MINGW) 33076f9cba8fSJoseph Mingrone # 33086f9cba8fSJoseph Mingrone # If we haven't found an ln executable with MinGW, we don't try 33096f9cba8fSJoseph Mingrone # generating and installing the man pages, so if we get here, 33106f9cba8fSJoseph Mingrone # we've found that executable. 3311b00ab754SHans Petter Selasky set(LINK_COMMAND "\"${LINK_EXECUTABLE}\" \"-s\" \"${SOURCE}\" \"${TARGET}\"") 3312b00ab754SHans Petter Selasky else(MINGW) 3313b00ab754SHans Petter Selasky set(LINK_COMMAND "\"${CMAKE_COMMAND}\" \"-E\" \"create_symlink\" \"${SOURCE}\" \"${TARGET}\"") 3314b00ab754SHans Petter Selasky endif(MINGW) 3315b00ab754SHans Petter Selasky 3316*afdbf109SJoseph Mingrone install(CODE " 3317*afdbf109SJoseph Mingrone if(NOT ${CMAKE_INSTALL_MESSAGE} STREQUAL \"NEVER\") 3318*afdbf109SJoseph Mingrone message(STATUS \"Symlinking: \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${MANDIR}/${SOURCE} to ${TARGET}\") 3319*afdbf109SJoseph Mingrone endif() 3320b00ab754SHans Petter Selasky execute_process( 3321b00ab754SHans Petter Selasky COMMAND \"${CMAKE_COMMAND}\" \"-E\" \"remove\" \"${TARGET}\" 3322*afdbf109SJoseph Mingrone WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${MANDIR} 3323b00ab754SHans Petter Selasky ) 3324b00ab754SHans Petter Selasky execute_process( 3325b00ab754SHans Petter Selasky COMMAND ${LINK_COMMAND} 3326*afdbf109SJoseph Mingrone WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${MANDIR} 3327b00ab754SHans Petter Selasky RESULT_VARIABLE EXIT_STATUS 3328b00ab754SHans Petter Selasky ) 3329b00ab754SHans Petter Selasky if(NOT EXIT_STATUS EQUAL 0) 3330*afdbf109SJoseph Mingrone message(FATAL_ERROR \"Could not create symbolic link from \${CMAKE_INSTALL_PREFIX}/${MANDIR}/${SOURCE} to ${TARGET}\") 3331b00ab754SHans Petter Selasky endif() 3332*afdbf109SJoseph Mingrone set(CMAKE_INSTALL_MANIFEST_FILES \${CMAKE_INSTALL_MANIFEST_FILES} \${CMAKE_INSTALL_PREFIX}/${MANDIR}/${TARGET})") 3333b00ab754SHans Petter Selaskyendfunction(install_manpage_symlink) 3334b00ab754SHans Petter Selasky 3335b00ab754SHans Petter Selaskyset(MAN1_NOEXPAND pcap-config.1) 3336b00ab754SHans Petter Selaskyset(MAN3PCAP_EXPAND 3337b00ab754SHans Petter Selasky pcap.3pcap.in 3338b00ab754SHans Petter Selasky pcap_compile.3pcap.in 3339b00ab754SHans Petter Selasky pcap_datalink.3pcap.in 3340b00ab754SHans Petter Selasky pcap_dump_open.3pcap.in 3341b00ab754SHans Petter Selasky pcap_get_tstamp_precision.3pcap.in 3342b00ab754SHans Petter Selasky pcap_list_datalinks.3pcap.in 3343b00ab754SHans Petter Selasky pcap_list_tstamp_types.3pcap.in 3344b00ab754SHans Petter Selasky pcap_open_dead.3pcap.in 3345b00ab754SHans Petter Selasky pcap_open_offline.3pcap.in 334657e22627SCy Schubert pcap_set_immediate_mode.3pcap.in 3347b00ab754SHans Petter Selasky pcap_set_tstamp_precision.3pcap.in 3348b00ab754SHans Petter Selasky pcap_set_tstamp_type.3pcap.in 3349b00ab754SHans Petter Selasky) 3350b00ab754SHans Petter Selaskyset(MAN3PCAP_NOEXPAND 3351b00ab754SHans Petter Selasky pcap_activate.3pcap 3352b00ab754SHans Petter Selasky pcap_breakloop.3pcap 3353b00ab754SHans Petter Selasky pcap_can_set_rfmon.3pcap 3354b00ab754SHans Petter Selasky pcap_close.3pcap 3355b00ab754SHans Petter Selasky pcap_create.3pcap 3356b00ab754SHans Petter Selasky pcap_datalink_name_to_val.3pcap 3357b00ab754SHans Petter Selasky pcap_datalink_val_to_name.3pcap 3358b00ab754SHans Petter Selasky pcap_dump.3pcap 3359b00ab754SHans Petter Selasky pcap_dump_close.3pcap 3360b00ab754SHans Petter Selasky pcap_dump_file.3pcap 3361b00ab754SHans Petter Selasky pcap_dump_flush.3pcap 3362b00ab754SHans Petter Selasky pcap_dump_ftell.3pcap 3363b00ab754SHans Petter Selasky pcap_file.3pcap 3364b00ab754SHans Petter Selasky pcap_fileno.3pcap 3365b00ab754SHans Petter Selasky pcap_findalldevs.3pcap 3366b00ab754SHans Petter Selasky pcap_freecode.3pcap 3367b00ab754SHans Petter Selasky pcap_get_required_select_timeout.3pcap 3368b00ab754SHans Petter Selasky pcap_get_selectable_fd.3pcap 3369b00ab754SHans Petter Selasky pcap_geterr.3pcap 33706f9cba8fSJoseph Mingrone pcap_init.3pcap 3371b00ab754SHans Petter Selasky pcap_inject.3pcap 3372b00ab754SHans Petter Selasky pcap_is_swapped.3pcap 3373b00ab754SHans Petter Selasky pcap_lib_version.3pcap 3374b00ab754SHans Petter Selasky pcap_lookupdev.3pcap 3375b00ab754SHans Petter Selasky pcap_lookupnet.3pcap 3376b00ab754SHans Petter Selasky pcap_loop.3pcap 3377b00ab754SHans Petter Selasky pcap_major_version.3pcap 3378b00ab754SHans Petter Selasky pcap_next_ex.3pcap 3379b00ab754SHans Petter Selasky pcap_offline_filter.3pcap 3380b00ab754SHans Petter Selasky pcap_open_live.3pcap 3381b00ab754SHans Petter Selasky pcap_set_buffer_size.3pcap 3382b00ab754SHans Petter Selasky pcap_set_datalink.3pcap 3383b00ab754SHans Petter Selasky pcap_set_promisc.3pcap 338457e22627SCy Schubert pcap_set_protocol_linux.3pcap 3385b00ab754SHans Petter Selasky pcap_set_rfmon.3pcap 3386b00ab754SHans Petter Selasky pcap_set_snaplen.3pcap 3387b00ab754SHans Petter Selasky pcap_set_timeout.3pcap 3388b00ab754SHans Petter Selasky pcap_setdirection.3pcap 3389b00ab754SHans Petter Selasky pcap_setfilter.3pcap 3390b00ab754SHans Petter Selasky pcap_setnonblock.3pcap 3391b00ab754SHans Petter Selasky pcap_snapshot.3pcap 3392b00ab754SHans Petter Selasky pcap_stats.3pcap 3393b00ab754SHans Petter Selasky pcap_statustostr.3pcap 3394b00ab754SHans Petter Selasky pcap_strerror.3pcap 3395b00ab754SHans Petter Selasky pcap_tstamp_type_name_to_val.3pcap 3396b00ab754SHans Petter Selasky pcap_tstamp_type_val_to_name.3pcap 3397b00ab754SHans Petter Selasky) 33986f9cba8fSJoseph Mingroneset(MANFILE_EXPAND 33996f9cba8fSJoseph Mingrone pcap-savefile.manfile.in 34006f9cba8fSJoseph Mingrone) 3401b00ab754SHans Petter Selaskyset(MANMISC_EXPAND 3402b00ab754SHans Petter Selasky pcap-filter.manmisc.in 3403b00ab754SHans Petter Selasky pcap-linktype.manmisc.in 3404b00ab754SHans Petter Selasky pcap-tstamp.manmisc.in 3405b00ab754SHans Petter Selasky) 3406b00ab754SHans Petter Selasky 34076f9cba8fSJoseph Mingroneif(BUILD_SHARED_LIBS) 34086f9cba8fSJoseph Mingrone set(LIBRARIES_TO_INSTALL "${LIBRARY_NAME}" "${LIBRARY_NAME_STATIC}") 34096f9cba8fSJoseph Mingroneelse(BUILD_SHARED_LIBS) 34106f9cba8fSJoseph Mingrone set(LIBRARIES_TO_INSTALL "${LIBRARY_NAME_STATIC}") 34116f9cba8fSJoseph Mingroneendif(BUILD_SHARED_LIBS) 3412b00ab754SHans Petter Selasky 34136f9cba8fSJoseph Mingroneif(WIN32 OR CYGWIN OR MSYS) 34146f9cba8fSJoseph Mingrone # 34156f9cba8fSJoseph Mingrone # XXX - according to the CMake documentation, WIN32 is set if 34166f9cba8fSJoseph Mingrone # the target is Windows; would there ever be a case where 34176f9cba8fSJoseph Mingrone # CYGWIN or MSYS are set but WIN32 *isn't* set? 34186f9cba8fSJoseph Mingrone # 3419b00ab754SHans Petter Selasky if(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8) 3420b00ab754SHans Petter Selasky # 34216f9cba8fSJoseph Mingrone # Install 64-bit code built with MSVC in the x64 subdirectories, 3422b00ab754SHans Petter Selasky # as that's where it expects it to be. 3423b00ab754SHans Petter Selasky # 34246f9cba8fSJoseph Mingrone install(TARGETS ${LIBRARIES_TO_INSTALL} 34256f9cba8fSJoseph Mingrone RUNTIME DESTINATION bin/x64 34266f9cba8fSJoseph Mingrone LIBRARY DESTINATION lib/x64 34276f9cba8fSJoseph Mingrone ARCHIVE DESTINATION lib/x64) 3428b00ab754SHans Petter Selasky if(NOT MINGW) 3429b00ab754SHans Petter Selasky install(FILES $<TARGET_FILE_DIR:${LIBRARY_NAME_STATIC}>/${LIBRARY_NAME_STATIC}.pdb 34306f9cba8fSJoseph Mingrone DESTINATION bin/x64 OPTIONAL) 3431b00ab754SHans Petter Selasky if(BUILD_SHARED_LIBS) 3432b00ab754SHans Petter Selasky install(FILES $<TARGET_PDB_FILE:${LIBRARY_NAME}> 34336f9cba8fSJoseph Mingrone DESTINATION bin/x64 OPTIONAL) 3434b00ab754SHans Petter Selasky endif(BUILD_SHARED_LIBS) 3435b00ab754SHans Petter Selasky endif(NOT MINGW) 3436b00ab754SHans Petter Selasky else(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8) 3437b00ab754SHans Petter Selasky # 3438b00ab754SHans Petter Selasky # Install 32-bit code, and 64-bit code not built with MSVC 3439b00ab754SHans Petter Selasky # in the top-level directories, as those are where they 3440b00ab754SHans Petter Selasky # expect it to be. 3441b00ab754SHans Petter Selasky # 34426f9cba8fSJoseph Mingrone install(TARGETS ${LIBRARIES_TO_INSTALL} 3443b00ab754SHans Petter Selasky RUNTIME DESTINATION bin 3444b00ab754SHans Petter Selasky LIBRARY DESTINATION lib 3445b00ab754SHans Petter Selasky ARCHIVE DESTINATION lib) 34466f9cba8fSJoseph Mingrone if(MSVC) 3447b00ab754SHans Petter Selasky install(FILES $<TARGET_FILE_DIR:${LIBRARY_NAME_STATIC}>/${LIBRARY_NAME_STATIC}.pdb 3448b00ab754SHans Petter Selasky DESTINATION bin OPTIONAL) 3449b00ab754SHans Petter Selasky if(BUILD_SHARED_LIBS) 3450b00ab754SHans Petter Selasky install(FILES $<TARGET_PDB_FILE:${LIBRARY_NAME}> 3451b00ab754SHans Petter Selasky DESTINATION bin OPTIONAL) 3452b00ab754SHans Petter Selasky endif(BUILD_SHARED_LIBS) 34536f9cba8fSJoseph Mingrone endif(MSVC) 3454b00ab754SHans Petter Selasky endif(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8) 34556f9cba8fSJoseph Mingroneelse(WIN32 OR CYGWIN OR MSYS) 3456*afdbf109SJoseph Mingrone install(TARGETS ${LIBRARIES_TO_INSTALL} DESTINATION ${CMAKE_INSTALL_LIBDIR}) 34576f9cba8fSJoseph Mingroneendif(WIN32 OR CYGWIN OR MSYS) 3458b00ab754SHans Petter Selasky 3459*afdbf109SJoseph Mingroneinstall(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/pcap/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pcap) 3460*afdbf109SJoseph Mingroneinstall(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pcap.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 3461*afdbf109SJoseph Mingroneinstall(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pcap-bpf.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 3462*afdbf109SJoseph Mingroneinstall(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pcap-namedb.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 3463b00ab754SHans Petter Selasky 3464b00ab754SHans Petter Selasky# On UN*X, and on Windows when not using MSVC, generate libpcap.pc and 3465b00ab754SHans Petter Selasky# pcap-config and process man pages and arrange that they be installed. 3466b00ab754SHans Petter Selaskyif(NOT MSVC) 3467b00ab754SHans Petter Selasky set(prefix ${CMAKE_INSTALL_PREFIX}) 3468b00ab754SHans Petter Selasky set(exec_prefix "\${prefix}") 3469b00ab754SHans Petter Selasky set(includedir "\${prefix}/include") 34706f9cba8fSJoseph Mingrone set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") 34716f9cba8fSJoseph Mingrone 34726f9cba8fSJoseph Mingrone # 34736f9cba8fSJoseph Mingrone # If this is a platform where we need to have the .pc file and 34746f9cba8fSJoseph Mingrone # pcap-config script supply an rpath option to specify the directory 34756f9cba8fSJoseph Mingrone # in which the libpcap shared library is installed, and the install 34766f9cba8fSJoseph Mingrone # prefix /usr (meaning we're not installing a system library), 34776f9cba8fSJoseph Mingrone # provide the rpath option. 34786f9cba8fSJoseph Mingrone # 34796f9cba8fSJoseph Mingrone # (We must check CMAKE_INSTALL_PREFIX, as the library directory 34806f9cba8fSJoseph Mingrone # isn't necessarily /usr/lib in this case - for example, Linux 34816f9cba8fSJoseph Mingrone # distributions for 64-bit platforms that also provide support for 34826f9cba8fSJoseph Mingrone # binaries for a 32-bit version of the platform may put the 64-bit 34836f9cba8fSJoseph Mingrone # libraries, the 32-bit libraries, or both in directories other than 34846f9cba8fSJoseph Mingrone # /usr/lib.) 34856f9cba8fSJoseph Mingrone # 34866f9cba8fSJoseph Mingrone # In AIX, do we have to do this? 34876f9cba8fSJoseph Mingrone # 34886f9cba8fSJoseph Mingrone # In Darwin-based OSes, the full paths of the shared libraries with 34896f9cba8fSJoseph Mingrone # which the program was linked are stored in the executable, so we 34906f9cba8fSJoseph Mingrone # don't need to provide an rpath option. 34916f9cba8fSJoseph Mingrone # 34926f9cba8fSJoseph Mingrone # With the HP-UX linker, directories specified with -L are, by 34936f9cba8fSJoseph Mingrone # default, added to the run-time search path, so we don't need to 34946f9cba8fSJoseph Mingrone # supply them. 34956f9cba8fSJoseph Mingrone # 34966f9cba8fSJoseph Mingrone # For Tru64 UNIX, "-rpath" works with DEC's^WCompaq's^WHP's C 34976f9cba8fSJoseph Mingrone # compiler for Alpha, but isn't documented as working with GCC, and 34986f9cba8fSJoseph Mingrone # no GCC-compatible option is documented as working with the DEC 34996f9cba8fSJoseph Mingrone # compiler. If anybody needs this on Tru64/Alpha, they're welcome 35006f9cba8fSJoseph Mingrone # to figure out a way to make it work. 35016f9cba8fSJoseph Mingrone # 35026f9cba8fSJoseph Mingrone # This must *not* depend on the compiler, as, on platforms where 35036f9cba8fSJoseph Mingrone # there's a GCC-compatible compiler and a vendor compiler, we need 35046f9cba8fSJoseph Mingrone # to work with both. 35056f9cba8fSJoseph Mingrone # 35066f9cba8fSJoseph Mingrone if(NOT CMAKE_INSTALL_PREFIX STREQUAL "/usr") 3507b00ab754SHans Petter Selasky if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR 3508b00ab754SHans Petter Selasky CMAKE_SYSTEM_NAME STREQUAL "NetBSD" OR 3509b00ab754SHans Petter Selasky CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR 3510b00ab754SHans Petter Selasky CMAKE_SYSTEM_NAME STREQUAL "DragonFly BSD" OR 35116f9cba8fSJoseph Mingrone CMAKE_SYSTEM_NAME STREQUAL "Linux") 3512b00ab754SHans Petter Selasky # 35136f9cba8fSJoseph Mingrone # Platforms where the "native" C compiler is GCC or accepts 35146f9cba8fSJoseph Mingrone # compatible command-line arguments, and the "native" linker 35156f9cba8fSJoseph Mingrone # is the GNU linker or accepts compatible command-line 35166f9cba8fSJoseph Mingrone # arguments. 3517b00ab754SHans Petter Selasky # 35186f9cba8fSJoseph Mingrone set(RPATH "-Wl,-rpath,\${libdir}") 3519b00ab754SHans Petter Selasky elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*") 3520b00ab754SHans Petter Selasky # 3521b00ab754SHans Petter Selasky # SunOS 5.x. 3522b00ab754SHans Petter Selasky # 35236f9cba8fSJoseph Mingrone # Sun/Oracle's linker, the GNU linker, and GNU-compatible 35246f9cba8fSJoseph Mingrone # linkers all support -R. 3525b00ab754SHans Petter Selasky # 35266f9cba8fSJoseph Mingrone set(RPATH "-Wl,-R,\${libdir}") 3527b00ab754SHans Petter Selasky else() 3528b00ab754SHans Petter Selasky # 3529b00ab754SHans Petter Selasky # No option needed to set the RPATH. 3530b00ab754SHans Petter Selasky # 35316f9cba8fSJoseph Mingrone set(RPATH "") 3532b00ab754SHans Petter Selasky endif() 35336f9cba8fSJoseph Mingrone endif() 353457e22627SCy Schubert configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pcap-config.in ${CMAKE_CURRENT_BINARY_DIR}/pcap-config @ONLY) 353557e22627SCy Schubert configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpcap.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libpcap.pc @ONLY) 3536b00ab754SHans Petter Selasky install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/pcap-config DESTINATION bin) 3537b00ab754SHans Petter Selasky install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpcap.pc DESTINATION lib/pkgconfig) 3538b00ab754SHans Petter Selasky 3539b00ab754SHans Petter Selasky # 3540b00ab754SHans Petter Selasky # Man pages. 3541b00ab754SHans Petter Selasky # 3542b00ab754SHans Petter Selasky # For each section of the manual for which we have man pages 3543b00ab754SHans Petter Selasky # that require macro expansion, do the expansion. 3544b00ab754SHans Petter Selasky # 35456f9cba8fSJoseph Mingrone # If this is MinGW, maybe we have a UN*X-style ln command and 35466f9cba8fSJoseph Mingrone # maybe we don't. (No, we do *NOT* require MSYS!) If we don't 35476f9cba8fSJoseph Mingrone # have it, don't do the man pages. 35486f9cba8fSJoseph Mingrone # 35496f9cba8fSJoseph Mingrone if(MINGW) 35506f9cba8fSJoseph Mingrone find_program(LINK_EXECUTABLE ln) 35516f9cba8fSJoseph Mingrone endif(MINGW) 35526f9cba8fSJoseph Mingrone if(UNIX OR (MINGW AND LINK_EXECUTABLE)) 3553b00ab754SHans Petter Selasky set(MAN1 "") 3554b00ab754SHans Petter Selasky foreach(MANPAGE ${MAN1_NOEXPAND}) 355557e22627SCy Schubert set(MAN1 ${MAN1} ${CMAKE_CURRENT_SOURCE_DIR}/${MANPAGE}) 3556b00ab754SHans Petter Selasky endforeach(MANPAGE) 3557b00ab754SHans Petter Selasky install(FILES ${MAN1} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) 3558b00ab754SHans Petter Selasky 3559b00ab754SHans Petter Selasky set(MAN3PCAP "") 3560b00ab754SHans Petter Selasky foreach(MANPAGE ${MAN3PCAP_NOEXPAND}) 356157e22627SCy Schubert set(MAN3PCAP ${MAN3PCAP} ${CMAKE_CURRENT_SOURCE_DIR}/${MANPAGE}) 3562b00ab754SHans Petter Selasky endforeach(MANPAGE) 3563b00ab754SHans Petter Selasky foreach(TEMPLATE_MANPAGE ${MAN3PCAP_EXPAND}) 3564b00ab754SHans Petter Selasky string(REPLACE ".in" "" MANPAGE ${TEMPLATE_MANPAGE}) 356557e22627SCy Schubert configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY) 3566b00ab754SHans Petter Selasky set(MAN3PCAP ${MAN3PCAP} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE}) 3567b00ab754SHans Petter Selasky endforeach(TEMPLATE_MANPAGE) 3568b00ab754SHans Petter Selasky install(FILES ${MAN3PCAP} DESTINATION ${CMAKE_INSTALL_MANDIR}/man3) 3569b00ab754SHans Petter Selasky install_manpage_symlink(pcap_datalink_val_to_name.3pcap pcap_datalink_val_to_description.3pcap ${CMAKE_INSTALL_MANDIR}/man3) 35706f9cba8fSJoseph Mingrone install_manpage_symlink(pcap_datalink_val_to_name.3pcap pcap_datalink_val_to_description_or_dlt.3pcap ${CMAKE_INSTALL_MANDIR}/man3) 3571b00ab754SHans Petter Selasky install_manpage_symlink(pcap_dump_open.3pcap pcap_dump_fopen.3pcap ${CMAKE_INSTALL_MANDIR}/man3) 3572b00ab754SHans Petter Selasky install_manpage_symlink(pcap_findalldevs.3pcap pcap_freealldevs.3pcap ${CMAKE_INSTALL_MANDIR}/man3) 3573b00ab754SHans Petter Selasky install_manpage_symlink(pcap_geterr.3pcap pcap_perror.3pcap ${CMAKE_INSTALL_MANDIR}/man3) 3574b00ab754SHans Petter Selasky install_manpage_symlink(pcap_inject.3pcap pcap_sendpacket.3pcap ${CMAKE_INSTALL_MANDIR}/man3) 3575b00ab754SHans Petter Selasky install_manpage_symlink(pcap_list_datalinks.3pcap pcap_free_datalinks.3pcap ${CMAKE_INSTALL_MANDIR}/man3) 3576b00ab754SHans Petter Selasky install_manpage_symlink(pcap_list_tstamp_types.3pcap pcap_free_tstamp_types.3pcap ${CMAKE_INSTALL_MANDIR}/man3) 3577b00ab754SHans Petter Selasky install_manpage_symlink(pcap_loop.3pcap pcap_dispatch.3pcap ${CMAKE_INSTALL_MANDIR}/man3) 3578b00ab754SHans Petter Selasky install_manpage_symlink(pcap_major_version.3pcap pcap_minor_version.3pcap ${CMAKE_INSTALL_MANDIR}/man3) 3579b00ab754SHans Petter Selasky install_manpage_symlink(pcap_next_ex.3pcap pcap_next.3pcap ${CMAKE_INSTALL_MANDIR}/man3) 3580b00ab754SHans Petter Selasky install_manpage_symlink(pcap_open_dead.3pcap pcap_open_dead_with_tstamp_precision.3pcap ${CMAKE_INSTALL_MANDIR}/man3) 3581b00ab754SHans Petter Selasky install_manpage_symlink(pcap_open_offline.3pcap pcap_open_offline_with_tstamp_precision.3pcap ${CMAKE_INSTALL_MANDIR}/man3) 3582b00ab754SHans Petter Selasky install_manpage_symlink(pcap_open_offline.3pcap pcap_fopen_offline.3pcap ${CMAKE_INSTALL_MANDIR}/man3) 3583b00ab754SHans Petter Selasky install_manpage_symlink(pcap_open_offline.3pcap pcap_fopen_offline_with_tstamp_precision.3pcap ${CMAKE_INSTALL_MANDIR}/man3) 3584b00ab754SHans Petter Selasky install_manpage_symlink(pcap_tstamp_type_val_to_name.3pcap pcap_tstamp_type_val_to_description.3pcap ${CMAKE_INSTALL_MANDIR}/man3) 3585b00ab754SHans Petter Selasky install_manpage_symlink(pcap_setnonblock.3pcap pcap_getnonblock.3pcap ${CMAKE_INSTALL_MANDIR}/man3) 3586b00ab754SHans Petter Selasky 3587b00ab754SHans Petter Selasky set(MANFILE "") 3588b00ab754SHans Petter Selasky foreach(TEMPLATE_MANPAGE ${MANFILE_EXPAND}) 3589b00ab754SHans Petter Selasky string(REPLACE ".manfile.in" ".${MAN_FILE_FORMATS}" MANPAGE ${TEMPLATE_MANPAGE}) 359057e22627SCy Schubert configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY) 3591b00ab754SHans Petter Selasky set(MANFILE ${MANFILE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE}) 3592b00ab754SHans Petter Selasky endforeach(TEMPLATE_MANPAGE) 3593b00ab754SHans Petter Selasky install(FILES ${MANFILE} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${MAN_FILE_FORMATS}) 3594b00ab754SHans Petter Selasky 3595b00ab754SHans Petter Selasky set(MANMISC "") 3596b00ab754SHans Petter Selasky foreach(TEMPLATE_MANPAGE ${MANMISC_EXPAND}) 3597b00ab754SHans Petter Selasky string(REPLACE ".manmisc.in" ".${MAN_MISC_INFO}" MANPAGE ${TEMPLATE_MANPAGE}) 359857e22627SCy Schubert configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY) 3599b00ab754SHans Petter Selasky set(MANMISC ${MANMISC} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE}) 3600b00ab754SHans Petter Selasky endforeach(TEMPLATE_MANPAGE) 3601b00ab754SHans Petter Selasky install(FILES ${MANMISC} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${MAN_MISC_INFO}) 36026f9cba8fSJoseph Mingrone endif(UNIX OR (MINGW AND LINK_EXECUTABLE)) 3603b00ab754SHans Petter Selaskyendif(NOT MSVC) 3604b00ab754SHans Petter Selasky 3605b00ab754SHans Petter Selasky# uninstall target 3606b00ab754SHans Petter Selaskyconfigure_file( 3607b00ab754SHans Petter Selasky "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" 3608b00ab754SHans Petter Selasky "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" 3609b00ab754SHans Petter Selasky IMMEDIATE @ONLY) 3610b00ab754SHans Petter Selasky 3611b00ab754SHans Petter Selaskyadd_custom_target(uninstall 3612b00ab754SHans Petter Selasky COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) 3613