Qt: Clear up the label
[metze/wireshark/wip.git] / ConfigureChecks.cmake
1 # ConfigureChecks.cmake
2 #
3 # Wireshark - Network traffic analyzer
4 # By Gerald Combs <gerald@wireshark.org>
5 # Copyright 1998 Gerald Combs
6 #
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License
9 # as published by the Free Software Foundation; either version 2
10 # of the License, or (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #
21
22 include(CMakePushCheckState)
23
24 #check system for includes
25 include(CheckIncludeFile)
26 check_include_file("arpa/inet.h"         HAVE_ARPA_INET_H)
27 check_include_file("arpa/nameser.h"      HAVE_ARPA_NAMESER_H)
28 check_include_file("dlfcn.h"             HAVE_DLFCN_H)
29 check_include_file("fcntl.h"             HAVE_FCNTL_H)
30 check_include_file("getopt.h"            HAVE_GETOPT_H)
31 check_include_file("grp.h"               HAVE_GRP_H)
32 check_include_file("ifaddrs.h"           HAVE_IFADDRS_H)
33 check_include_file("netinet/in.h"        HAVE_NETINET_IN_H)
34 check_include_file("netdb.h"             HAVE_NETDB_H)
35 # We need to set the path to Wpdpack in order to find Ntddndis.h
36 #cmake_push_check_state()
37 #set(CMAKE_REQUIRED_INCLUDES ${PCAP_INCLUDE_DIRS})
38 #check_include_file("Ntddndis.h"          HAVE_NTDDNDIS_H)
39 #cmake_pop_check_state()
40 check_include_file("portaudio.h"         HAVE_PORTAUDIO_H)
41 check_include_file("pwd.h"               HAVE_PWD_H)
42 check_include_file("sys/ioctl.h"         HAVE_SYS_IOCTL_H)
43 check_include_file("sys/param.h"         HAVE_SYS_PARAM_H)
44 check_include_file("sys/socket.h"        HAVE_SYS_SOCKET_H)
45 check_include_file("sys/sockio.h"        HAVE_SYS_SOCKIO_H)
46 check_include_file("sys/stat.h"          HAVE_SYS_STAT_H)
47 check_include_file("sys/time.h"          HAVE_SYS_TIME_H)
48 check_include_file("sys/types.h"         HAVE_SYS_TYPES_H)
49 check_include_file("sys/utsname.h"       HAVE_SYS_UTSNAME_H)
50 check_include_file("sys/wait.h"          HAVE_SYS_WAIT_H)
51 check_include_file("unistd.h"            HAVE_UNISTD_H)
52
53 #
54 # On Linux, check for some additional headers, which we need as a
55 # workaround for a bonding driver bug and for libpcap's current lack
56 # of its own workaround for that bug.
57 #
58 if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
59         #
60         # Those header files require <sys/socket.h>.
61         #
62         check_c_source_compiles(
63                 "#include <sys/socket.h>
64                 #include <linux/sockios.h>
65                 int main(void)
66                 {
67                         return 0;
68                 }"
69                 HAVE_LINUX_SOCKIOS_H
70         )
71         check_c_source_compiles(
72                 "#include <sys/socket.h>
73                 #include <linux/if_bonding.h>
74                 int main(void)
75                 {
76                         return 0;
77                 }"
78                 HAVE_LINUX_IF_BONDING_H
79         )
80 endif()
81
82 #Functions
83 include(CheckFunctionExists)
84 include(CheckSymbolExists)
85 check_function_exists("chown"            HAVE_CHOWN)
86
87 cmake_push_check_state()
88 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS})
89 check_function_exists("dladdr"           HAVE_DLADDR)
90 cmake_pop_check_state()
91
92 #
93 # Use check_symbol_exists just in case math.h does something magic
94 # and there's not actually a function named floorl()
95 #
96 cmake_push_check_state()
97 set(CMAKE_REQUIRED_INCLUDES ${M_INCLUDE_DIRS})
98 set(CMAKE_REQUIRED_LIBRARIES ${M_LIBRARIES})
99 check_symbol_exists("floorl" "math.h"    HAVE_FLOORL)
100 check_symbol_exists("lrint"  "math.h"    HAVE_LRINT)
101 cmake_pop_check_state()
102
103 check_function_exists("getopt_long"      HAVE_GETOPT_LONG)
104 if(HAVE_GETOPT_LONG)
105         if(HAVE_GETOPT_H)
106                 check_symbol_exists("optreset" "getopt.h" HAVE_OPTRESET)
107         else()
108                 check_symbol_exists("optreset"           HAVE_OPTRESET)
109         endif()
110 endif()
111 check_function_exists("getifaddrs"       HAVE_GETIFADDRS)
112 check_function_exists("issetugid"        HAVE_ISSETUGID)
113 check_function_exists("mkdtemp"          HAVE_MKDTEMP)
114 check_function_exists("mkstemps"         HAVE_MKSTEMPS)
115 check_function_exists("popcount"         HAVE_POPCOUNT)
116 check_function_exists("setresgid"        HAVE_SETRESGID)
117 check_function_exists("setresuid"        HAVE_SETRESUID)
118 check_function_exists("strptime"         HAVE_STRPTIME)
119 if (APPLE)
120         cmake_push_check_state()
121         set(CMAKE_REQUIRED_LIBRARIES ${APPLE_CORE_FOUNDATION_LIBRARY})
122         check_function_exists("CFPropertyListCreateWithStream" HAVE_CFPROPERTYLISTCREATEWITHSTREAM)
123         cmake_pop_check_state()
124 endif()
125
126 #Struct members
127 include(CheckStructHasMember)
128 check_struct_has_member("struct sockaddr" sa_len         sys/socket.h HAVE_STRUCT_SOCKADDR_SA_LEN)
129 check_struct_has_member("struct stat"     st_flags       sys/stat.h   HAVE_STRUCT_STAT_ST_FLAGS)
130 check_struct_has_member("struct stat"     st_birthtime   sys/stat.h   HAVE_STRUCT_STAT_ST_BIRTHTIME)
131 check_struct_has_member("struct stat"     __st_birthtime sys/stat.h   HAVE_STRUCT_STAT___ST_BIRTHTIME)
132 check_struct_has_member("struct tm"       tm_zone        time.h       HAVE_STRUCT_TM_TM_ZONE)
133
134 #Symbols but NOT enums or types
135 check_symbol_exists(tzname "time.h" HAVE_TZNAME)
136
137 # Check for stuff that isn't testable via the tests above
138
139 #
140 # *If* we found libnl, check if we can use nl80211 stuff with it.
141 #
142 if (NL_FOUND)
143         check_c_source_compiles(
144                 "#include <linux/nl80211.h>
145                 int main() {
146                         int x = NL80211_FREQUENCY_ATTR_MAX_TX_POWER;
147                         x |= NL80211_ATTR_SUPPORTED_IFTYPES;
148                         x |= NL80211_ATTR_SUPPORTED_COMMANDS;
149                         x |= NL80211_ATTR_WIPHY_FREQ;
150                         x |= NL80211_CHAN_NO_HT;
151                         (void)x;
152                 }"
153                 HAVE_NL80211
154         )
155         check_c_source_compiles(
156                 "#include <linux/nl80211.h>
157                 int main() {
158                         enum nl80211_commands x = NL80211_CMD_SET_CHANNEL;
159                 }"
160                 HAVE_NL80211_CMD_SET_CHANNEL
161         )
162         check_c_source_compiles(
163                 "#include <linux/nl80211.h>
164                 int main() {
165                         enum nl80211_protocol_features x = NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP;
166                 }"
167                 HAVE_NL80211_SPLIT_WIPHY_DUMP
168         )
169         check_c_source_compiles(
170                 "#include <linux/nl80211.h>
171                 int main() {
172                         enum nl80211_attrs x = NL80211_ATTR_VHT_CAPABILITY;
173                 }"
174                 HAVE_NL80211_VHT_CAPABILITY
175         )
176 endif()
177
178 #
179 # Editor modelines  -  http://www.wireshark.org/tools/modelines.html
180 #
181 # Local variables:
182 # c-basic-offset: 8
183 # tab-width: 8
184 # indent-tabs-mode: t
185 # End:
186 #
187 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
188 # :indentSize=8:tabSize=8:noTabs=false:
189 #