main_toolbar: fix redundant redeclaration of ‘cfile’ [-Wredundant-decls]
[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("inttypes.h"          HAVE_INTTYPES_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("stdint.h"            HAVE_STDINT_H)
43 check_include_file("sys/ioctl.h"         HAVE_SYS_IOCTL_H)
44 check_include_file("sys/param.h"         HAVE_SYS_PARAM_H)
45 check_include_file("sys/socket.h"        HAVE_SYS_SOCKET_H)
46 check_include_file("sys/sockio.h"        HAVE_SYS_SOCKIO_H)
47 check_include_file("sys/stat.h"          HAVE_SYS_STAT_H)
48 check_include_file("sys/time.h"          HAVE_SYS_TIME_H)
49 check_include_file("sys/types.h"         HAVE_SYS_TYPES_H)
50 check_include_file("sys/utsname.h"       HAVE_SYS_UTSNAME_H)
51 check_include_file("sys/wait.h"          HAVE_SYS_WAIT_H)
52 check_include_file("unistd.h"            HAVE_UNISTD_H)
53 check_include_file("windows.h"           HAVE_WINDOWS_H)
54 check_include_file("winsock2.h"          HAVE_WINSOCK2_H)
55
56 #
57 # On Linux, check for some additional headers, which we need as a
58 # workaround for a bonding driver bug and for libpcap's current lack
59 # of its own workaround for that bug.
60 #
61 if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
62         #
63         # Those header files require <sys/socket.h>.
64         #
65         check_c_source_compiles(
66                 "#include <sys/socket.h>
67                 #include <linux/sockios.h>
68                 int main(void)
69                 {
70                         return 0;
71                 }"
72                 HAVE_LINUX_SOCKIOS_H
73         )
74         check_c_source_compiles(
75                 "#include <sys/socket.h>
76                 #include <linux/if_bonding.h>
77                 int main(void)
78                 {
79                         return 0;
80                 }"
81                 HAVE_LINUX_IF_BONDING_H
82         )
83 endif()
84
85 #Functions
86 include(CheckFunctionExists)
87 include(CheckSymbolExists)
88 check_function_exists("chown"            HAVE_CHOWN)
89
90 cmake_push_check_state()
91 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS})
92 check_function_exists("dladdr"           HAVE_DLADDR)
93 cmake_pop_check_state()
94
95 #
96 # Use check_symbol_exists just in case math.h does something magic
97 # and there's not actually a function named floorl()
98 #
99 if(UNIX)
100         set(_mathlib m)
101 endif()
102 cmake_push_check_state()
103 set(CMAKE_REQUIRED_LIBRARIES ${_mathlib})
104 check_symbol_exists("floorl" "math.h"    HAVE_FLOORL)
105 cmake_pop_check_state()
106
107 check_function_exists("getaddrinfo"      HAVE_GETADDRINFO)
108 check_function_exists("gethostbyname"    HAVE_GETHOSTBYNAME)
109 check_function_exists("gethostbyname2"   HAVE_GETHOSTBYNAME2)
110 check_function_exists("getopt_long"      HAVE_GETOPT_LONG)
111 if(HAVE_GETOPT_LONG)
112         if(HAVE_GETOPT_H)
113                 check_symbol_exists("optreset" "getopt.h" HAVE_OPTRESET)
114         else()
115                 check_symbol_exists("optreset"           HAVE_OPTRESET)
116         endif()
117 endif()
118 check_function_exists("getprotobynumber" HAVE_GETPROTOBYNUMBER)
119 check_function_exists("inet_aton"        HAVE_INET_ATON)
120 check_function_exists("inet_ntop"        HAVE_INET_NTOP_PROTO)
121 check_function_exists("issetugid"        HAVE_ISSETUGID)
122 check_function_exists("mkdtemp"          HAVE_MKDTEMP)
123 check_function_exists("mkstemp"          HAVE_MKSTEMP)
124 check_function_exists("popcount"         HAVE_POPCOUNT)
125 check_function_exists("setresgid"        HAVE_SETRESGID)
126 check_function_exists("setresuid"        HAVE_SETRESUID)
127 check_function_exists("strptime"         HAVE_STRPTIME)
128 check_function_exists("sysconf"          HAVE_SYSCONF)
129 if (APPLE)
130         cmake_push_check_state()
131         set(CMAKE_REQUIRED_LIBRARIES ${APPLE_CORE_FOUNDATION_LIBRARY})
132         check_function_exists("CFPropertyListCreateWithStream" HAVE_CFPROPERTYLISTCREATEWITHSTREAM)
133         cmake_pop_check_state()
134 endif()
135
136 #Struct members
137 include(CheckStructHasMember)
138 check_struct_has_member("struct sockaddr" sa_len   sys/socket.h HAVE_SA_LEN)
139 check_struct_has_member("struct stat"     st_flags sys/stat.h   HAVE_ST_FLAGS)
140 check_struct_has_member("struct tm"       tm_zone  time.h       HAVE_TM_ZONE)
141
142 #Symbols but NOT enums or types
143 check_symbol_exists(tzname "time.h" HAVE_TZNAME)
144
145 # Check for stuff that isn't testable via the tests above
146
147 #
148 # *If* we found libnl, check if we can use nl80211 stuff with it.
149 #
150 if (NL_FOUND)
151         check_c_source_compiles(
152                 "#include <linux/nl80211.h>
153                 int main() {
154                         int x = NL80211_FREQUENCY_ATTR_MAX_TX_POWER;
155                         x |= NL80211_ATTR_SUPPORTED_IFTYPES;
156                         x |= NL80211_ATTR_SUPPORTED_COMMANDS;
157                         x |= NL80211_ATTR_WIPHY_FREQ;
158                         x |= NL80211_CHAN_NO_HT;
159                         (void)x;
160                 }"
161                 HAVE_NL80211
162         )
163         check_c_source_compiles(
164                 "#include <linux/nl80211.h>
165                 int main() {
166                         enum nl80211_commands x = NL80211_CMD_SET_CHANNEL;
167                 }"
168                 HAVE_NL80211_CMD_SET_CHANNEL
169         )
170         check_c_source_compiles(
171                 "#include <linux/nl80211.h>
172                 int main() {
173                         enum nl80211_protocol_features x = NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP;
174                 }"
175                 HAVE_NL80211_SPLIT_WIPHY_DUMP
176         )
177 endif()
178
179 #
180 # Check whether GLib's printf supports thousands grouping. (This might
181 # be different from the system's printf since GLib can optionally use
182 # its own printf implementation.)
183 #
184 if (CMAKE_CROSSCOMPILING OR WIN32)
185         #
186         # Play it safe when cross-compiling.
187         #
188         # XXX - compiling and trying to run the test below appears
189         # to loop infinitely on Windows, and the locale is wrong in
190         # any case, so we don't do this on Window for now.
191         #
192         set(HAVE_GLIB_PRINTF_GROUPING FALSE)
193 else()
194         cmake_push_check_state()
195         set(CMAKE_REQUIRED_INCLUDES ${GLIB2_INCLUDE_DIRS})
196         set(CMAKE_REQUIRED_LIBRARIES ${GLIB2_LIBRARIES})
197         check_c_source_runs(
198                 "#include <glib.h>
199                 #include <locale.h>
200                 #include <stdio.h>
201                 #include <string.h>
202
203                 int
204                 main ()
205                 {
206                   gchar *str;
207                   setlocale(LC_ALL, \"en_US.UTF-8\");
208                   str = g_strdup_printf(\"%'u\", 123456);
209                   return (strcmp (str, \"123,456\") != 0);
210                 }" HAVE_GLIB_PRINTF_GROUPING)
211         cmake_pop_check_state()
212 endif()
213
214 #
215 # Editor modelines  -  http://www.wireshark.org/tools/modelines.html
216 #
217 # Local variables:
218 # c-basic-offset: 8
219 # tab-width: 8
220 # indent-tabs-mode: t
221 # End:
222 #
223 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
224 # :indentSize=8:tabSize=8:noTabs=false:
225 #