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 check_include_file("arpa/inet.h" HAVE_ARPA_INET_H)
15 check_include_file("fcntl.h" HAVE_FCNTL_H)
16 check_include_file("getopt.h" HAVE_GETOPT_H)
17 check_include_file("grp.h" HAVE_GRP_H)
18 check_include_file("ifaddrs.h" HAVE_IFADDRS_H)
19 check_include_file("netinet/in.h" HAVE_NETINET_IN_H)
20 check_include_file("netdb.h" HAVE_NETDB_H)
21 check_include_file("pwd.h" HAVE_PWD_H)
22 check_include_file("sys/ioctl.h" HAVE_SYS_IOCTL_H)
23 check_include_file("sys/select.h" HAVE_SYS_SELECT_H)
24 check_include_file("sys/socket.h" HAVE_SYS_SOCKET_H)
25 check_include_file("sys/sockio.h" HAVE_SYS_SOCKIO_H)
26 check_include_file("sys/time.h" HAVE_SYS_TIME_H)
27 check_include_file("sys/utsname.h" HAVE_SYS_UTSNAME_H)
28 check_include_file("sys/wait.h" HAVE_SYS_WAIT_H)
29 check_include_file("unistd.h" HAVE_UNISTD_H)
32 # On Linux, check for some additional headers, which we need as a
33 # workaround for a bonding driver bug and for libpcap's current lack
34 # of its own workaround for that bug.
36 if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
38 # Those header files require <sys/socket.h>.
40 check_c_source_compiles(
41 "#include <sys/socket.h>
42 #include <linux/sockios.h>
49 check_c_source_compiles(
50 "#include <sys/socket.h>
51 #include <linux/if_bonding.h>
56 HAVE_LINUX_IF_BONDING_H
61 include(CheckFunctionExists)
62 include(CheckSymbolExists)
65 # Platform-specific functions used in platform-specific code.
66 # We check for them only on the platform on which we use them.
68 if(CMAKE_SYSTEM_NAME STREQUAL "HP-UX")
72 cmake_push_check_state()
73 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS})
74 check_function_exists("dlget" HAVE_DLGET)
75 cmake_pop_check_state()
76 elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*")
80 check_function_exists("getexecname" HAVE_GETEXECNAME)
84 # Use check_symbol_exists just in case math.h does something magic
85 # and there's not actually a function named floorl()
87 cmake_push_check_state()
88 set(CMAKE_REQUIRED_INCLUDES ${M_INCLUDE_DIRS})
89 set(CMAKE_REQUIRED_LIBRARIES ${M_LIBRARIES})
90 check_symbol_exists("floorl" "math.h" HAVE_FLOORL)
91 cmake_pop_check_state()
93 check_function_exists("getopt_long" HAVE_GETOPT_LONG)
96 # The OS has getopt_long(), so it might have optreset.
100 check_symbol_exists("optreset" "getopt.h" HAVE_OPTRESET)
102 check_symbol_exists("optreset" HAVE_OPTRESET)
106 # The OS doesn't have getopt_long(), so we're using the GNU libc
107 # version that we have in wsutil. It doesn't have optreset, so we
108 # don't need to check for it.
110 # However, it uses alloca(), so we may need to include alloca.h;
113 check_include_file("alloca.h" HAVE_ALLOCA_H)
115 check_function_exists("getifaddrs" HAVE_GETIFADDRS)
116 check_function_exists("issetugid" HAVE_ISSETUGID)
117 check_function_exists("mkstemps" HAVE_MKSTEMPS)
118 check_function_exists("setresgid" HAVE_SETRESGID)
119 check_function_exists("setresuid" HAVE_SETRESUID)
120 check_function_exists("strptime" HAVE_STRPTIME)
122 cmake_push_check_state()
123 set(CMAKE_REQUIRED_LIBRARIES ${APPLE_CORE_FOUNDATION_LIBRARY})
124 check_function_exists("CFPropertyListCreateWithStream" HAVE_CFPROPERTYLISTCREATEWITHSTREAM)
125 cmake_pop_check_state()
129 include(CheckStructHasMember)
130 check_struct_has_member("struct sockaddr" sa_len sys/socket.h HAVE_STRUCT_SOCKADDR_SA_LEN)
131 check_struct_has_member("struct stat" st_flags sys/stat.h HAVE_STRUCT_STAT_ST_FLAGS)
132 check_struct_has_member("struct stat" st_birthtime sys/stat.h HAVE_STRUCT_STAT_ST_BIRTHTIME)
133 check_struct_has_member("struct stat" __st_birthtime sys/stat.h HAVE_STRUCT_STAT___ST_BIRTHTIME)
134 check_struct_has_member("struct tm" tm_zone time.h HAVE_STRUCT_TM_TM_ZONE)
136 #Symbols but NOT enums or types
137 check_symbol_exists(tzname "time.h" HAVE_TZNAME)
139 # Check for stuff that isn't testable via the tests above
142 # *If* we found libnl, check if we can use nl80211 stuff with it.
145 check_c_source_compiles(
146 "#include <linux/nl80211.h>
148 int x = NL80211_FREQUENCY_ATTR_MAX_TX_POWER;
149 x |= NL80211_ATTR_SUPPORTED_IFTYPES;
150 x |= NL80211_ATTR_SUPPORTED_COMMANDS;
151 x |= NL80211_ATTR_WIPHY_FREQ;
152 x |= NL80211_CHAN_NO_HT;
157 check_c_source_compiles(
158 "#include <linux/nl80211.h>
160 enum nl80211_commands x = NL80211_CMD_SET_CHANNEL;
162 HAVE_NL80211_CMD_SET_CHANNEL
164 check_c_source_compiles(
165 "#include <linux/nl80211.h>
167 enum nl80211_protocol_features x = NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP;
169 HAVE_NL80211_SPLIT_WIPHY_DUMP
171 check_c_source_compiles(
172 "#include <linux/nl80211.h>
174 enum nl80211_attrs x = NL80211_ATTR_VHT_CAPABILITY;
176 HAVE_NL80211_VHT_CAPABILITY
181 # Editor modelines - http://www.wireshark.org/tools/modelines.html
186 # indent-tabs-mode: t
189 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
190 # :indentSize=8:tabSize=8:noTabs=false: