1 # ConfigureChecks.cmake
3 # Wireshark - Network traffic analyzer
4 # By Gerald Combs <gerald@wireshark.org>
5 # Copyright 1998 Gerald Combs
7 # SPDX-License-Identifier: GPL-2.0-or-later
10 include(CMakePushCheckState)
13 # Prepopulate some values. Compilation checks on Windows can be slow.
14 set(HAVE_FCNTL_H TRUE)
15 set(HAVE_SYS_STAT_H TRUE)
20 #check system for includes
21 include(CheckIncludeFile)
22 check_include_file("arpa/inet.h" HAVE_ARPA_INET_H)
23 check_include_file("fcntl.h" HAVE_FCNTL_H)
24 check_include_file("getopt.h" HAVE_GETOPT_H)
25 check_include_file("grp.h" HAVE_GRP_H)
26 check_include_file("ifaddrs.h" HAVE_IFADDRS_H)
27 check_include_file("netinet/in.h" HAVE_NETINET_IN_H)
28 check_include_file("netdb.h" HAVE_NETDB_H)
29 check_include_file("pwd.h" HAVE_PWD_H)
30 check_include_file("sys/ioctl.h" HAVE_SYS_IOCTL_H)
31 check_include_file("sys/select.h" HAVE_SYS_SELECT_H)
32 check_include_file("sys/socket.h" HAVE_SYS_SOCKET_H)
33 check_include_file("sys/sockio.h" HAVE_SYS_SOCKIO_H)
34 check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
35 check_include_file("sys/time.h" HAVE_SYS_TIME_H)
36 check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
37 check_include_file("sys/utsname.h" HAVE_SYS_UTSNAME_H)
38 check_include_file("sys/wait.h" HAVE_SYS_WAIT_H)
39 check_include_file("unistd.h" HAVE_UNISTD_H)
42 # On Linux, check for some additional headers, which we need as a
43 # workaround for a bonding driver bug and for libpcap's current lack
44 # of its own workaround for that bug.
46 if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
48 # Those header files require <sys/socket.h>.
50 check_c_source_compiles(
51 "#include <sys/socket.h>
52 #include <linux/sockios.h>
59 check_c_source_compiles(
60 "#include <sys/socket.h>
61 #include <linux/if_bonding.h>
66 HAVE_LINUX_IF_BONDING_H
71 include(CheckFunctionExists)
72 include(CheckSymbolExists)
74 cmake_push_check_state()
75 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS})
76 check_function_exists("dladdr" HAVE_DLADDR)
77 cmake_pop_check_state()
80 # Use check_symbol_exists just in case math.h does something magic
81 # and there's not actually a function named floorl()
83 cmake_push_check_state()
84 set(CMAKE_REQUIRED_INCLUDES ${M_INCLUDE_DIRS})
85 set(CMAKE_REQUIRED_LIBRARIES ${M_LIBRARIES})
86 check_symbol_exists("floorl" "math.h" HAVE_FLOORL)
87 check_symbol_exists("lrint" "math.h" HAVE_LRINT) # GTK+ only
88 cmake_pop_check_state()
90 check_function_exists("getopt_long" HAVE_GETOPT_LONG)
93 check_symbol_exists("optreset" "getopt.h" HAVE_OPTRESET)
95 check_symbol_exists("optreset" HAVE_OPTRESET)
98 check_function_exists("getifaddrs" HAVE_GETIFADDRS)
99 check_function_exists("issetugid" HAVE_ISSETUGID)
100 check_function_exists("mkstemps" HAVE_MKSTEMPS)
101 check_function_exists("popcount" HAVE_POPCOUNT)
102 check_function_exists("setresgid" HAVE_SETRESGID)
103 check_function_exists("setresuid" HAVE_SETRESUID)
104 check_function_exists("strptime" HAVE_STRPTIME)
106 cmake_push_check_state()
107 set(CMAKE_REQUIRED_LIBRARIES ${APPLE_CORE_FOUNDATION_LIBRARY})
108 check_function_exists("CFPropertyListCreateWithStream" HAVE_CFPROPERTYLISTCREATEWITHSTREAM)
109 cmake_pop_check_state()
113 include(CheckStructHasMember)
114 check_struct_has_member("struct sockaddr" sa_len sys/socket.h HAVE_STRUCT_SOCKADDR_SA_LEN)
115 check_struct_has_member("struct stat" st_flags sys/stat.h HAVE_STRUCT_STAT_ST_FLAGS)
116 check_struct_has_member("struct stat" st_birthtime sys/stat.h HAVE_STRUCT_STAT_ST_BIRTHTIME)
117 check_struct_has_member("struct stat" __st_birthtime sys/stat.h HAVE_STRUCT_STAT___ST_BIRTHTIME)
118 check_struct_has_member("struct tm" tm_zone time.h HAVE_STRUCT_TM_TM_ZONE)
120 #Symbols but NOT enums or types
121 check_symbol_exists(tzname "time.h" HAVE_TZNAME)
123 # Check for stuff that isn't testable via the tests above
126 # *If* we found libnl, check if we can use nl80211 stuff with it.
129 check_c_source_compiles(
130 "#include <linux/nl80211.h>
132 int x = NL80211_FREQUENCY_ATTR_MAX_TX_POWER;
133 x |= NL80211_ATTR_SUPPORTED_IFTYPES;
134 x |= NL80211_ATTR_SUPPORTED_COMMANDS;
135 x |= NL80211_ATTR_WIPHY_FREQ;
136 x |= NL80211_CHAN_NO_HT;
141 check_c_source_compiles(
142 "#include <linux/nl80211.h>
144 enum nl80211_commands x = NL80211_CMD_SET_CHANNEL;
146 HAVE_NL80211_CMD_SET_CHANNEL
148 check_c_source_compiles(
149 "#include <linux/nl80211.h>
151 enum nl80211_protocol_features x = NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP;
153 HAVE_NL80211_SPLIT_WIPHY_DUMP
155 check_c_source_compiles(
156 "#include <linux/nl80211.h>
158 enum nl80211_attrs x = NL80211_ATTR_VHT_CAPABILITY;
160 HAVE_NL80211_VHT_CAPABILITY
165 # Editor modelines - http://www.wireshark.org/tools/modelines.html
170 # indent-tabs-mode: t
173 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
174 # :indentSize=8:tabSize=8:noTabs=false: