blob: e48b60d10d270ddde19546a4d667b843bfe07a62 [file] [log] [blame]
Emeric Vigier2f625822012-08-06 11:09:52 -04001include(CheckIncludeFile)
2include(CheckSymbolExists)
3include(CheckStructMember)
4include(CheckTypeSize)
5
6check_include_file(dirent.h HAVE_DIRENT_H) # dbus-sysdeps-util.c
7check_include_file(io.h HAVE_IO_H) # internal
8check_include_file(grp.h HAVE_GRP_H) # dbus-sysdeps-util-win.c
9check_include_file(sys/poll.h HAVE_POLL) # dbus-sysdeps.c, dbus-sysdeps-win.c
10check_include_file(sys/time.h HAVE_SYS_TIME_H)# dbus-sysdeps-win.c
11check_include_file(sys/wait.h HAVE_SYS_WAIT_H)# dbus-sysdeps-win.c
12check_include_file(time.h HAVE_TIME_H) # dbus-sysdeps-win.c
13check_include_file(ws2tcpip.h HAVE_WS2TCPIP_H)# dbus-sysdeps-win.c
14check_include_file(wspiapi.h HAVE_WSPIAPI_H) # dbus-sysdeps-win.c
15check_include_file(unistd.h HAVE_UNISTD_H) # dbus-sysdeps-util-win.c
16check_include_file(stdio.h HAVE_STDIO_H) # dbus-sysdeps.h
17check_include_file(sys/syslimits.h HAVE_SYS_SYSLIMITS_H) # dbus-sysdeps-unix.c
18check_include_file(errno.h HAVE_ERRNO_H) # dbus-sysdeps.c
19check_include_file(signal.h HAVE_SIGNAL_H)
20check_include_file(locale.h HAVE_LOCALE_H)
21check_include_file(inttypes.h HAVE_INTTYPES_H) # dbus-pipe.h
22check_include_file(stdint.h HAVE_STDINT_H) # dbus-pipe.h
23
24check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE) # dbus-sysdeps.c, dbus-sysdeps-win.c
25check_symbol_exists(getgrouplist "grp.h" HAVE_GETGROUPLIST) # dbus-sysdeps.c
26check_symbol_exists(getpeerucred "ucred.h" HAVE_GETPEERUCRED) # dbus-sysdeps.c, dbus-sysdeps-win.c
27check_symbol_exists(nanosleep "time.h" HAVE_NANOSLEEP) # dbus-sysdeps.c
28check_symbol_exists(getpwnam_r "errno.h pwd.h" HAVE_POSIX_GETPWNAM_R) # dbus-sysdeps-util-unix.c
29check_symbol_exists(setenv "stdlib.h" HAVE_SETENV) # dbus-sysdeps.c
30check_symbol_exists(unsetenv "stdlib.h" HAVE_UNSETENV) # dbus-sysdeps.c
31check_symbol_exists(clearenv "stdlib.h" HAVE_CLEARENV) # dbus-sysdeps.c
32check_symbol_exists(writev "sys/uio.h" HAVE_WRITEV) # dbus-sysdeps.c, dbus-sysdeps-win.c
33check_symbol_exists(setrlimit "sys/resource.h" HAVE_SETRLIMIT) # dbus-sysdeps.c, dbus-sysdeps-win.c, test/test-segfault.c
34check_symbol_exists(socketpair "sys/socket.h" HAVE_SOCKETPAIR) # dbus-sysdeps.c
35check_symbol_exists(socklen_t "sys/socket.h" HAVE_SOCKLEN_T) # dbus-sysdeps-unix.c
36check_symbol_exists(setlocale "locale.h" HAVE_SETLOCALE) # dbus-test-main.c
37check_symbol_exists(localeconv "locale.h" HAVE_LOCALECONV) # dbus-sysdeps.c
38check_symbol_exists(strtoll "stdlib.h" HAVE_STRTOLL) # dbus-send.c
39check_symbol_exists(strtoull "stdlib.h" HAVE_STRTOULL) # dbus-send.c
40
41check_struct_member(cmsgcred cmcred_pid "sys/types.h sys/socket.h" HAVE_CMSGCRED) # dbus-sysdeps.c
42
43# missing:
44# HAVE_ABSTRACT_SOCKETS
45# DBUS_HAVE_GCC33_GCOV
46
47check_type_size("short" SIZEOF_SHORT)
48check_type_size("int" SIZEOF_INT)
49check_type_size("long" SIZEOF_LONG)
50check_type_size("long long" SIZEOF_LONG_LONG)
51check_type_size("__int64" SIZEOF___INT64)
52
53# DBUS_INT64_TYPE
54if(SIZEOF_INT EQUAL 8)
55 set (DBUS_HAVE_INT64 1)
56 set (DBUS_INT64_TYPE "int")
57else(SIZEOF_INT EQUAL 8)
58 if(SIZEOF_LONG EQUAL 8)
59 set (DBUS_HAVE_INT64 1)
60 set (DBUS_INT64_TYPE "long")
61 else(SIZEOF_LONG EQUAL 8)
62 if(SIZEOF_LONG_LONG EQUAL 8)
63 set (DBUS_HAVE_INT64 1)
64 set (DBUS_INT64_TYPE "long long")
65 else(SIZEOF_LONG_LONG EQUAL 8)
66 if(SIZEOF___INT64 EQUAL 8)
67 set (DBUS_HAVE_INT64 1)
68 set (DBUS_INT64_TYPE "__int64")
69 endif(SIZEOF___INT64 EQUAL 8)
70 endif(SIZEOF_LONG_LONG EQUAL 8)
71 endif(SIZEOF_LONG EQUAL 8)
72endif(SIZEOF_INT EQUAL 8)
73
74# DBUS_INT32_TYPE
75if(SIZEOF_INT EQUAL 4)
76 set (DBUS_INT32_TYPE "int")
77else(SIZEOF_INT EQUAL 4)
78 if(SIZEOF_LONG EQUAL 4)
79 set (DBUS_INT32_TYPE "long")
80 else(SIZEOF_LONG EQUAL 4)
81 if(SIZEOF_LONG_LONG EQUAL 4)
82 set (DBUS_INT32_TYPE "long long")
83 endif(SIZEOF_LONG_LONG EQUAL 4)
84 endif(SIZEOF_LONG EQUAL 4)
85endif(SIZEOF_INT EQUAL 4)
86
87# DBUS_INT16_TYPE
88if(SIZEOF_INT EQUAL 2)
89 set (DBUS_INT16_TYPE "int")
90else(SIZEOF_INT EQUAL 2)
91 if(SIZEOF_SHORT EQUAL 2)
92 set (DBUS_INT16_TYPE "short")
93 endif(SIZEOF_SHORT EQUAL 2)
94endif(SIZEOF_INT EQUAL 2)
95
96find_program(DOXYGEN doxygen)
97find_program(XMLTO xmlto)
98
99if(MSVC)
100 SET(DBUS_VA_COPY_FUNC "_DBUS_VA_COPY_ASSIGN";)
101else(MSVC)
102write_file("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/cmake_try_compile.c" "#include <stdarg.h>
103 #include <stdlib.h>
104 static void f (int i, ...) {
105 va_list args1, args2;
106 va_start (args1, i);
107 va_copy (args2, args1);
108 if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
109 exit (1);
110 va_end (args1); va_end (args2);
111 }
112 int main() {
113 f (0, 42);
114 return 0;
115 }
116")
117try_compile(DBUS_HAVE_VA_COPY
118 ${CMAKE_BINARY_DIR}
119 ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/cmake_try_compile.c)
120
121if(DBUS_HAVE_VA_COPY)
122 SET(DBUS_VA_COPY_FUNC va_copy CACHE STRING "va_copy function")
123else(DBUS_HAVE_VA_COPY)
124 write_file("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/cmake_try_compile.c" "#include <stdarg.h>
125 #include <stdlib.h>
126 static void f (int i, ...) {
127 va_list args1, args2;
128 va_start (args1, i);
129 __va_copy (args2, args1);
130 if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
131 exit (1);
132 va_end (args1); va_end (args2);
133 }
134 int main() {
135 f (0, 42);
136 return 0;
137 }
138 ")
139 try_compile(DBUS_HAVE___VA_COPY
140 ${CMAKE_BINARY_DIR}
141 ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/cmake_try_compile.c)
142 if(DBUS_HAVE___VA_COPY)
143 SET(DBUS_VA_COPY_FUNC __va_copy CACHE STRING "va_copy function")
144 else(DBUS_HAVE___VA_COPY)
145 SET(DBUS_VA_COPY_AS_ARRAY "1" CACHE STRING "'va_lists' cannot be copies as values")
146 endif(DBUS_HAVE___VA_COPY)
147endif(DBUS_HAVE_VA_COPY)
148endif(MSVC) # _not_ MSVC
149#### Abstract sockets
150
151if (DBUS_ENABLE_ABSTRACT_SOCKETS)
152
153 try_compile(HAVE_ABSTRACT_SOCKETS
154 ${CMAKE_BINARY_DIR}
155 ${CMAKE_SOURCE_DIR}/modules/CheckForAbstractSockets.c)
156
157endif(DBUS_ENABLE_ABSTRACT_SOCKETS)
158
159if(HAVE_ABSTRACT_SOCKETS)
160 set(DBUS_PATH_OR_ABSTRACT_VALUE abstract)
161else(HAVE_ABSTRACT_SOCKETS)
162 set(DBUS_PATH_OR_ABSTRACT_VALUE path)
163endif(HAVE_ABSTRACT_SOCKETS)
164