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