Test was the wrong way around
[metze/wireshark/wip.git] / ConfigureChecks.cmake
1 # ConfigureChecks.cmake
2 #
3 # $Id$
4 #
5 # Wireshark - Network traffic analyzer
6 # By Gerald Combs <gerald@wireshark.org>
7 # Copyright 1998 Gerald Combs
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License
11 # as published by the Free Software Foundation; either version 2
12 # of the License, or (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #
23
24 include(CMakePushCheckState)
25
26 #check system for includes
27 include(CheckIncludeFile)
28 check_include_file("arpa/inet.h"         HAVE_ARPA_INET_H)
29 check_include_file("arpa/nameser.h"      HAVE_ARPA_NAMESER_H)
30 check_include_file("direct.h"            HAVE_DIRECT_H)
31 check_include_file("dirent.h"            HAVE_DIRENT_H)
32 check_include_file("dlfcn.h"             HAVE_DLFCN_H)
33 check_include_file("fcntl.h"             HAVE_FCNTL_H)
34 check_include_file("getopt.h"            HAVE_GETOPT_H)
35 check_include_file("grp.h"               HAVE_GRP_H)
36 check_include_file("inet/aton.h"         HAVE_INET_ATON_H)
37 check_include_file("inttypes.h"          HAVE_INTTYPES_H)
38 check_include_file("memory.h"            HAVE_MEMORY_H)
39 check_include_file("netinet/in.h"        HAVE_NETINET_IN_H)
40 check_include_file("netdb.h"             HAVE_NETDB_H)
41 # We need to set the path to Wpdpack in order to find Ntddndis.h
42 #cmake_push_check_state()
43 #set(CMAKE_REQUIRED_INCLUDES %{PCAP_INCLUDE_DIRS})
44 #check_include_file("Ntddndis.h"          HAVE_NTDDNDIS_H)
45 #cmake_pop_check_state()
46 check_include_file("portaudio.h"         HAVE_PORTAUDIO_H)
47 check_include_file("pwd.h"               HAVE_PWD_H)
48 check_include_file("stdarg.h"            HAVE_STDARG_H)
49 check_include_file("stddef.h"            HAVE_STDDEF_H)
50 check_include_file("stdint.h"            HAVE_STDINT_H)
51 check_include_file("stdlib.h"            HAVE_STDLIB_H)
52 check_include_file("strings.h"           HAVE_STRINGS_H)
53 check_include_file("string.h"            HAVE_STRING_H)
54 check_include_file("sys/ioctl.h"         HAVE_SYS_IOCTL_H)
55 check_include_file("sys/param.h"         HAVE_SYS_PARAM_H)
56 check_include_file("sys/socket.h"        HAVE_SYS_SOCKET_H)
57 check_include_file("sys/sockio.h"        HAVE_SYS_SOCKIO_H)
58 check_include_file("sys/stat.h"          HAVE_SYS_STAT_H)
59 check_include_file("sys/time.h"          HAVE_SYS_TIME_H)
60 check_include_file("sys/types.h"         HAVE_SYS_TYPES_H)
61 check_include_file("sys/utsname.h"       HAVE_SYS_UTSNAME_H)
62 check_include_file("sys/wait.h"          HAVE_SYS_WAIT_H)
63 check_include_file("unistd.h"            HAVE_UNISTD_H)
64 check_include_file("windows.h"           HAVE_WINDOWS_H)
65 check_include_file("winsock2.h"          HAVE_WINSOCK2_H)
66
67 #Functions
68 include(CheckFunctionExists)
69 check_function_exists("chown"            HAVE_CHOWN)
70
71 cmake_push_check_state()
72 #
73 # XXX - this is *not* finding dladdr() on OS X (at least not on
74 # Mountain Lion), even though it's available; autoconf does find
75 # it.  The dl* functions can be tricky, in that they might be
76 # exported by the run-time linker rather than by any library,
77 # so the only way to check for it that might work is "can I link
78 # a program that calls this function?", not, for example, "do
79 # any of these libraries define this function?"
80 #
81 set(CMAKE_REQUIRED_LIBRARIES %{CMAKE_DL_LIBS})
82 check_function_exists("dladdr"           HAVE_DLADDR)
83 cmake_pop_check_state()
84
85 check_function_exists("gethostbyname2"   HAVE_GETHOSTBYNAME2)
86 check_function_exists("getopt"           HAVE_GETOPT)
87 check_function_exists("getprotobynumber" HAVE_GETPROTOBYNUMBER)
88 check_function_exists("inet_ntop"        HAVE_INET_NTOP_PROTO)
89 check_function_exists("issetugid"        HAVE_ISSETUGID)
90 check_function_exists("mmap"             HAVE_MMAP)
91 check_function_exists("mprotect"         HAVE_MPROTECT)
92 check_function_exists("mkdtemp"          HAVE_MKDTEMP)
93 check_function_exists("mkstemp"          HAVE_MKSTEMP)
94 check_function_exists("setresgid"        HAVE_SETRESGID)
95 check_function_exists("setresuid"        HAVE_SETRESUID)
96 check_function_exists("sysconf"          HAVE_SYSCONF)
97
98 #Struct members
99 include(CheckStructHasMember)
100 check_struct_has_member("struct sockaddr" sa_len   sys/socket.h HAVE_SA_LEN)
101 check_struct_has_member("struct stat"     st_flags sys/stat.h   HAVE_ST_FLAGS)
102 check_struct_has_member("struct tm"       tm_zone  time.h       HAVE_TM_ZONE)
103
104 #Symbols but NOT enums or types
105 include(CheckSymbolExists)
106 check_symbol_exists(tzname "time.h" HAVE_TZNAME)
107
108 # Check for stuff that isn't testable via the tests above
109 #include(CheckCSourceCompiles)
110 check_c_source_compiles(
111         "#include <linux/nl80211.h>
112         int main() {
113                 enum nl80211_commands x = NL80211_CMD_SET_CHANNEL;
114         }"
115         HAVE_NL80211_CMD_SET_CHANNEL
116 )
117 check_c_source_compiles(
118         "#include <linux/nl80211.h>
119         int main() {
120                 int x = NL80211_FREQUENCY_ATTR_MAX_TX_POWER;
121                 x = NL80211_ATTR_SUPPORTED_IFTYPES;
122                 x = NL80211_ATTR_SUPPORTED_COMMANDS;
123                 x = NL80211_ATTR_WIPHY_FREQ;
124                 x = NL80211_CHAN_NO_HT;
125         }"
126         HAVE_NL80211
127 )
128