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)
12 #check system for includes
13 include(CheckIncludeFile)
14 include(CheckIncludeFiles)
15 check_include_file("arpa/inet.h" HAVE_ARPA_INET_H)
16 check_include_file("fcntl.h" HAVE_FCNTL_H)
17 check_include_file("getopt.h" HAVE_GETOPT_H)
18 check_include_file("grp.h" HAVE_GRP_H)
20 # This may require <sys/types.h> to be included
22 check_include_files("sys/types.h;ifaddrs.h" HAVE_IFADDRS_H)
23 check_include_file("netinet/in.h" HAVE_NETINET_IN_H)
24 check_include_file("netdb.h" HAVE_NETDB_H)
25 check_include_file("pwd.h" HAVE_PWD_H)
26 check_include_file("sys/ioctl.h" HAVE_SYS_IOCTL_H)
27 check_include_file("sys/select.h" HAVE_SYS_SELECT_H)
28 check_include_file("sys/socket.h" HAVE_SYS_SOCKET_H)
29 check_include_file("sys/sockio.h" HAVE_SYS_SOCKIO_H)
30 check_include_file("sys/time.h" HAVE_SYS_TIME_H)
31 check_include_file("sys/utsname.h" HAVE_SYS_UTSNAME_H)
32 check_include_file("sys/wait.h" HAVE_SYS_WAIT_H)
33 check_include_file("unistd.h" HAVE_UNISTD_H)
36 # On Linux, check for some additional headers, which we need as a
37 # workaround for a bonding driver bug and for libpcap's current lack
38 # of its own workaround for that bug.
40 if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
42 # Those header files require <sys/socket.h>.
44 check_c_source_compiles(
45 "#include <sys/socket.h>
46 #include <linux/sockios.h>
53 check_c_source_compiles(
54 "#include <sys/socket.h>
55 #include <linux/if_bonding.h>
60 HAVE_LINUX_IF_BONDING_H
65 include(CheckFunctionExists)
66 include(CheckSymbolExists)
69 # Platform-specific functions used in platform-specific code.
70 # We check for them only on the platform on which we use them.
72 if(CMAKE_SYSTEM_NAME STREQUAL "HP-UX")
76 cmake_push_check_state()
77 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS})
78 check_function_exists("dlget" HAVE_DLGET)
79 cmake_pop_check_state()
80 elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*")
84 check_function_exists("getexecname" HAVE_GETEXECNAME)
88 # Use check_symbol_exists just in case math.h does something magic
89 # and there's not actually a function named floorl()
91 cmake_push_check_state()
92 set(CMAKE_REQUIRED_INCLUDES ${M_INCLUDE_DIRS})
93 set(CMAKE_REQUIRED_LIBRARIES ${M_LIBRARIES})
94 check_symbol_exists("floorl" "math.h" HAVE_FLOORL)
95 cmake_pop_check_state()
97 check_function_exists("getopt_long" HAVE_GETOPT_LONG)
100 # The OS has getopt_long(), so it might have optreset.
104 check_symbol_exists("optreset" "getopt.h" HAVE_OPTRESET)
106 check_symbol_exists("optreset" HAVE_OPTRESET)
110 # The OS doesn't have getopt_long(), so we're using the GNU libc
111 # version that we have in wsutil. It doesn't have optreset, so we
112 # don't need to check for it.
114 # However, it uses alloca(), so we may need to include alloca.h;
117 check_include_file("alloca.h" HAVE_ALLOCA_H)
119 check_function_exists("getifaddrs" HAVE_GETIFADDRS)
120 check_function_exists("issetugid" HAVE_ISSETUGID)
121 check_function_exists("mkstemps" HAVE_MKSTEMPS)
122 check_function_exists("setresgid" HAVE_SETRESGID)
123 check_function_exists("setresuid" HAVE_SETRESUID)
124 check_function_exists("strptime" HAVE_STRPTIME)
126 cmake_push_check_state()
127 set(CMAKE_REQUIRED_LIBRARIES ${APPLE_CORE_FOUNDATION_LIBRARY})
128 check_function_exists("CFPropertyListCreateWithStream" HAVE_CFPROPERTYLISTCREATEWITHSTREAM)
129 cmake_pop_check_state()
133 include(CheckStructHasMember)
134 check_struct_has_member("struct sockaddr" sa_len sys/socket.h HAVE_STRUCT_SOCKADDR_SA_LEN)
135 check_struct_has_member("struct stat" st_flags sys/stat.h HAVE_STRUCT_STAT_ST_FLAGS)
136 check_struct_has_member("struct stat" st_birthtime sys/stat.h HAVE_STRUCT_STAT_ST_BIRTHTIME)
137 check_struct_has_member("struct stat" __st_birthtime sys/stat.h HAVE_STRUCT_STAT___ST_BIRTHTIME)
138 check_struct_has_member("struct tm" tm_zone time.h HAVE_STRUCT_TM_TM_ZONE)
140 #Symbols but NOT enums or types
141 check_symbol_exists(tzname "time.h" HAVE_TZNAME)
143 # Check for stuff that isn't testable via the tests above
146 # *If* we found libnl, check if we can use nl80211 stuff with it.
149 check_c_source_compiles(
150 "#include <linux/nl80211.h>
152 int x = NL80211_FREQUENCY_ATTR_MAX_TX_POWER;
153 x |= NL80211_ATTR_SUPPORTED_IFTYPES;
154 x |= NL80211_ATTR_SUPPORTED_COMMANDS;
155 x |= NL80211_ATTR_WIPHY_FREQ;
156 x |= NL80211_CHAN_NO_HT;
161 check_c_source_compiles(
162 "#include <linux/nl80211.h>
164 enum nl80211_commands x = NL80211_CMD_SET_CHANNEL;
166 HAVE_NL80211_CMD_SET_CHANNEL
168 check_c_source_compiles(
169 "#include <linux/nl80211.h>
171 enum nl80211_protocol_features x = NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP;
173 HAVE_NL80211_SPLIT_WIPHY_DUMP
175 check_c_source_compiles(
176 "#include <linux/nl80211.h>
178 enum nl80211_attrs x = NL80211_ATTR_VHT_CAPABILITY;
180 HAVE_NL80211_VHT_CAPABILITY
185 # Editor modelines - http://www.wireshark.org/tools/modelines.html
190 # indent-tabs-mode: t
193 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
194 # :indentSize=8:tabSize=8:noTabs=false: