Debian Codegraph @

builds/cmake/Configure.cmake

raw
1 ################################################################################
2 #
3 # configure
4 #
5 ################################################################################
6
7 ########################################
8 # FUNCTION check_includes
9 ########################################
10 function(check_includes files)
11 foreach(F ${${files}})
12 set(name ${F})
13 string(REPLACE "." "_" name ${name})
14 string(REPLACE "/" "_" name ${name})
15 string(TOUPPER ${name} name)
16 check_include_files(${F} HAVE_${name})
17 #message("/* Define to 1 if you have the <${F}> header file. */")
18 #message("#cmakedefine HAVE_${name} 1")
19 #message("")
20 endforeach()
21 endfunction(check_includes)
22
23 ########################################
24 # FUNCTION check_functions
25 ########################################
26 function(check_functions functions)
27 foreach(F ${${functions}})
28 set(name ${F})
29 string(TOUPPER ${name} name)
30 check_function_exists(${F} HAVE_${name})
31 #message("/* Define to 1 if you have the `${F}' function. */")
32 #message("#cmakedefine HAVE_${name} 1")
33 #message("")
34 endforeach()
35 endfunction(check_functions)
36
37 ########################################
38 # FUNCTION check_type_alignment
39 ########################################
40 function(check_type_alignment type var)
41 if (NOT DEFINED ${var})
42 check_c_source_runs("main(){struct s{char a;${type} b;};exit((int)&((struct s*)0)->b);}" ${var})
43 #message(STATUS "Performing Test ${var} - It's still OK.")
44 message(STATUS "Performing Test ${var} - Success")
45 set(${var} ${${var}_EXITCODE} CACHE STRING "${type} alignment" FORCE)
46 endif()
47 endfunction(check_type_alignment)
48
49 ########################################
50 # FUNCTION check_symbol
51 ########################################
52 function(check_symbol symbol var)
53 if (NOT ${var}_SYMBOL)
54 foreach(f ${ARGN})
55 if (NOT ${var})
56 unset(${var} CACHE)
57 message(STATUS "Looking for ${symbol} - ${f}")
58 check_symbol_exists(${symbol} ${f} ${var})
59 endif()
60 endforeach()
61 endif()
62 set(${var}_SYMBOL 1 CACHE INTERNAL "Do not check this symbol again")
63 endfunction(check_symbol)
64
65 ########################################
66
67 include(CheckCSourceCompiles)
68 include(CheckCSourceRuns)
69 include(CheckCXXSourceCompiles)
70 include(CheckCXXSourceRuns)
71 include(CheckFunctionExists)
72 include(CheckIncludeFiles)
73 include(CheckLibraryExists)
74 include(CheckPrototypeDefinition)
75 include(CheckStructHasMember)
76 include(CheckSymbolExists)
77 include(CheckTypeSize)
78 include(TestBigEndian)
79
80 if (ANDROID)
81 set(LINUX 1)
82 endif()
83
84 if (IOS)
85 set(CMAKE_SYSTEM_PROCESSOR "armv7")
86 add_definitions(-D__arm__)
87 endif()
88
89 if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
90 set(CLANG 1)
91 endif()
92
93 set(ENABLE_BINRELOC 1)
94
95 string(TOUPPER ${CMAKE_SYSTEM_NAME} CMAKE_SYSTEM_NAME_UPPER)
96 set(${CMAKE_SYSTEM_NAME_UPPER} 1)
97
98 string(TOUPPER ${CMAKE_SYSTEM_PROCESSOR} CMAKE_SYSTEM_PROCESSOR_UPPER)
99 string(FIND ${CMAKE_SYSTEM_PROCESSOR} "arm" ARM)
100 if (NOT ${ARM} EQUAL -1)
101 set(ARM 1)
102 else()
103 set(ARM)
104 endif()
105 if (${CMAKE_SYSTEM_PROCESSOR_UPPER} STREQUAL "X86_64" OR
106 ${CMAKE_SYSTEM_PROCESSOR_UPPER} STREQUAL "AMD64")
107 set(AMD64 1)
108 set(I386 1)
109 endif()
110 set(${CMAKE_SYSTEM_PROCESSOR_UPPER} 1)
111
112 set(SHRLIB_EXT ${CMAKE_SHARED_LIBRARY_SUFFIX})
113 string(REPLACE "." "" SHRLIB_EXT ${SHRLIB_EXT})
114
115 set(CASE_SENSITIVITY "true")
116 set(SUPPORT_RAW_DEVICES 1)
117
118 set(include_files_list
119 aio.h
120 assert.h
121 atomic.h
122 atomic_ops.h
123 crypt.h
124 ctype.h
125 dirent.h
126 dlfcn.h
127 editline.h
128 errno.h
129 fcntl.h
130 float.h
131 grp.h
132 iconv.h
133 io.h
134 inttypes.h
135 langinfo.h
136 libio.h
137 linux/falloc.h
138 limits.h
139 locale.h
140 math.h
141 memory.h
142 mntent.h
143 mnttab.h
144 ndir.h
145 netconfig.h
146 netinet/in.h
147 poll.h
148 pthread.h
149 pwd.h
150 rpc/rpc.h
151 rpc/xdr.h
152 semaphore.h
153 setjmp.h
154 signal.h
155 socket.h
156 stdarg.h
157 stdint.h
158 stdlib.h
159 string.h
160 strings.h
161 sys/dir.h
162 sys/file.h
163 sys/ioctl.h
164 sys/ipc.h
165 sys/mntent.h
166 sys/mnttab.h
167 sys/mount.h
168 sys/ndir.h
169 sys/param.h
170 sys/resource.h
171 sys/sem.h
172 sys/select.h
173 sys/siginfo.h
174 sys/signal.h
175 sys/socket.h
176 sys/sockio.h
177 sys/stat.h
178 sys/syscall.h
179 sys/time.h
180 sys/timeb.h
181 sys/types.h
182 sys/uio.h
183 sys/wait.h
184 termio.h
185 termios.h
186 unistd.h
187 varargs.h
188 vfork.h
189 winsock2.h
190 zlib.h
191 )
192 check_includes(include_files_list)
193
194 #if test "$EDITLINE_FLG" = "Y"; then
195 # AC_HEADER_DIRENT
196 # AC_DEFINE(HAVE_EDITLINE_H, 1, [Define this if editline is in use])
197 #fi
198
199 set(functions_list
200 accept4
201 AO_compare_and_swap_full
202 clock_gettime
203 ctime_r
204 dirname
205 fallocate
206 fchmod
207 fsync
208 flock
209 fork
210 getpagesize
211 getcwd getwd
212 gettimeofday
213 gmtime_r
214 initgroups
215 localtime_r
216 mkstemp
217 mmap
218 nanosleep
219 poll
220 posix_fadvise
221 pread pwrite
222 pthread_cancel
223 pthread_keycreate pthread_key_create
224 pthread_mutexattr_setprotocol
225 pthread_mutexattr_setrobust_np
226 pthread_mutex_consistent_np
227 pthread_rwlockattr_setkind_np
228 qsort_r
229 setitimer
230 semtimedop
231 setpgid
232 setpgrp
233 setmntent getmntent
234 setrlimit getrlimit
235 sigaction
236 sigset
237 snprintf vsnprintf
238 strcasecmp stricmp
239 strncasecmp strnicmp
240 strdup
241 strerror_r
242 swab _swab
243 tcgetattr
244 time times
245 vfork
246 )
247 check_functions(functions_list)
248
249 if (APPLE)
250 set(HAVE_QSORT_R 0 CACHE STRING "Disabled on OS X" FORCE)
251 endif()
252
253 check_cxx_source_compiles("#include <unistd.h>\nmain(){fdatasync(0);}" HAVE_FDATASYNC)
254
255 check_library_exists(dl dladdr "${CMAKE_LIBRARY_PREFIX}" HAVE_DLADDR)
256 check_library_exists(m fegetenv "${CMAKE_LIBRARY_PREFIX}" HAVE_FEGETENV)
257 check_library_exists(m llrint "${CMAKE_LIBRARY_PREFIX}" HAVE_LLRINT)
258 check_library_exists(pthread sem_init "${CMAKE_LIBRARY_PREFIX}" HAVE_SEM_INIT)
259 check_library_exists(pthread sem_timedwait "${CMAKE_LIBRARY_PREFIX}" HAVE_SEM_TIMEDWAIT)
260
261 check_type_size(caddr_t HAVE_CADDR_T)
262 check_c_source_compiles("#include <sys/sem.h>\nmain(){union semun s;return 0;}" HAVE_SEMUN)
263 set(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h sys/types.h)
264 check_type_size(socklen_t HAVE_SOCKLEN_T)
265 set(CMAKE_EXTRA_INCLUDE_FILES)
266
267 check_type_size(long SIZEOF_LONG)
268 check_type_size(size_t SIZEOF_SIZE_T)
269 check_type_size("void *" SIZEOF_VOID_P)
270
271 check_type_size(gid_t HAVE_GID_T)
272 check_type_size(off_t HAVE_OFF_T)
273 check_type_size(pid_t HAVE_PID_T)
274 check_type_size(size_t HAVE_SIZE_T)
275 check_type_size(uid_t HAVE_UID_T)
276
277 if (${HAVE_OFF_T} AND ${HAVE_OFF_T} EQUAL 8)
278 set(_FILE_OFFSET_BITS 64)
279 endif()
280
281 test_big_endian(WORDS_BIGENDIAN)
282 check_symbol_exists(INFINITY math.h HAVE_INFINITY)
283 check_symbol_exists(va_copy stdarg.h HAVE_VA_COPY)
284 check_symbol(SOCK_CLOEXEC HAVE_DECL_SOCK_CLOEXEC socket.h sys/socket.h)
285
286 set(CMAKE_EXTRA_INCLUDE_FILES Windows.h)
287 check_type_size("char[MAX_PATH]" MAXPATHLEN)
288 set(CMAKE_EXTRA_INCLUDE_FILES)
289
290 set(TIMEZONE_TYPE "struct timezone")
291 if (APPLE OR MINGW)
292 set(TIMEZONE_TYPE "void")
293 endif()
294 check_prototype_definition(
295 gettimeofday
296 "int gettimeofday(struct timeval *tv, ${TIMEZONE_TYPE} *tz)"
297 0
298 "sys/time.h"
299 GETTIMEOFDAY_RETURNS_TIMEZONE
300 )
301
302 check_prototype_definition(
303 getmntent
304 "int getmntent(FILE *file, struct mnttab *mptr)"
305 0
306 mntent.h
307 GETMNTENT_TAKES_TWO_ARGUMENTS
308 )
309
310 check_struct_has_member("struct dirent" d_type dirent.h HAVE_STRUCT_DIRENT_D_TYPE)
311
312 check_c_source_compiles("#include <unistd.h>\nmain(){getpgrp();}" GETPGRP_VOID)
313 check_c_source_compiles("#include <unistd.h>\nmain(){setpgrp();}" SETPGRP_VOID)
314
315 check_c_source_compiles("__thread int a = 42;main(){a = a + 1;}" HAVE___THREAD)
316 check_c_source_compiles("#include <sys/time.h>\n#include <time.h>\nmain(){}" TIME_WITH_SYS_TIME)
317
318 set(CMAKE_REQUIRED_LIBRARIES pthread)
319 check_c_source_compiles("#include <semaphore.h>\nmain(){sem_t s;sem_init(&s,0,0);}" WORKING_SEM_INIT)
320 set(CMAKE_REQUIRED_LIBRARIES)
321
322 if (EXISTS "/proc/self/exe")
323 set(HAVE__PROC_SELF_EXE 1)
324 endif()
325
326 ########################################
327
328 if (NOT CMAKE_CROSSCOMPILING)
329 check_type_alignment(long FB_ALIGNMENT)
330 check_type_alignment(double FB_DOUBLE_ALIGN)
331 else() # CMAKE_CROSSCOMPILING
332 set(FB_ALIGNMENT 8)
333 set(FB_DOUBLE_ALIGN 8)
334 if (ANDROID)
335 set(HAVE__PROC_SELF_EXE 1)
336 endif()
337 endif()
338
339 ########################################
340
341 if (WIN32)
342 set(ENABLE_BINRELOC 0)
343 set(SUPPORT_RAW_DEVICES 0)
344 set(WIN_NT 1)
345 set(CASE_SENSITIVITY "false")
346 endif(WIN32)
347
348 if (APPLE)
349 set(ENABLE_BINRELOC 0)
350 set(CASE_SENSITIVITY "false")
351 endif()
352
353 ################################################################################