1 include (CheckFunctionExists)
2 include (CheckIncludeFile)
3 include (CheckIncludeFileCXX)
5 if (BUILD_MONOLITHIC OR BUILD_DAEMON)
6 check_function_exists (fallocate HAVE_FALLOCATE)
7 check_function_exists (getrlimit HAVE_GETRLIMIT)
8 check_function_exists (setrlimit HAVE_SETRLIMIT)
9 check_include_file (fcntl.h HAVE_FCNTL_H)
10 check_include_file (sys/resource.h HAVE_SYS_RESOURCE_H)
11 check_include_file (sys/statvfs.h HAVE_SYS_STATVFS_H)
13 set (TEST_APP "#include <features.h>
14 #ifdef __GNU_LIBRARY__
15 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
21 execute_process (COMMAND echo ${TEST_APP}
22 COMMAND ${CMAKE_C_COMPILER} -E -xc -
23 OUTPUT_VARIABLE GLIB_TEST_OUTPUT
26 string (REGEX MATCH "Lucky GNU user" MATCH "${GLIB_TEST_OUTPUT}")
30 message (STATUS "glibc -- found")
33 check_function_exists (posix_fallocate HAVE_POSIX_FALLOCATE)
37 check_include_file (sys/select.h HAVE_SYS_SELECT_H)
38 check_include_file (sys/time.h HAVE_SYS_TIME_H)
39 check_include_file (sys/wait.h HAVE_SYS_WAIT_H)
40 check_include_file (unistd.h HAVE_UNISTD_H)
43 if (BUILD_DAEMON OR BUILD_WEBSERVER)
44 check_include_file (sys/types.h HAVE_SYS_TYPES_H)
47 if (BUILD_DAEMON OR BUILD_WEBSERVER OR NEED_LIB_MULECOMMON)
48 include (CheckTypeSize) #Sets also HAVE_SYS_TYPES_H, HAVE_STDINT_H, and HAVE_STDDEF_H
49 check_type_size (int INTSIZE)
52 if (NEED_LIB_MULEAPPCORE)
53 check_include_file (errno.h HAVE_ERRNO_H)
54 check_include_file (float.h HAVE_FLOAT_H)
55 check_include_file (signal.h HAVE_SIGNAL_H)
56 check_include_file (stdarg.h HAVE_STDARG_H)
57 check_include_file (stdlib.h HAVE_STDLIB_H)
58 check_include_file (string.h HAVE_STRING_H)
61 set (CMAKE_REQUIRED_INCLUDES stdlib.h)
62 check_function_exists (free HAVE_FREE)
63 unset (CMAKE_REQUIRED_INCLUDES)
66 if (HAVE_FREE AND HAVE_FLOAT_H AND HAVE_STDARG_H AND HAVE_STRING_H)
67 set (STDC_HEADERS TRUE)
71 check_include_file (sys/mman.h HAVE_SYS_MMAN_H)
74 check_function_exists (munmap HAVE_MUNMAP)
77 check_function_exists (sysconf HAVE_SYSCONF)
79 if (HAVE_SYSCONF AND STDC_HEADERS)
80 try_run (PS_RUN_RESULT PS_COMPILE_RESULT
82 ${amule_SOURCE_DIR}/cmake/mmap-test.cpp
83 RUN_OUTPUT_VARIABLE PS_OUTPUT
86 if (PS_RUN_RESULT EQUAL 0)
87 message (STATUS "_SC_PAGESIZE found")
88 set (HAVE__SC_PAGESIZE TRUE)
90 message (STATUS "_SC_PAGESIZE not defined, mmap support is disabled")
93 message (STATUS "sysconf function not found, mmap support is disabled")
96 message (STATUS "munmap function not found, mmap support is disabled")
99 message (STATUS "sys/mman.h wasn't found, mmap support is disabled")
104 if (NEED_LIB_MULECOMMON)
105 check_include_file_cxx (cxxabi.h HAVE_CXXABI)
106 check_include_file (execinfo.h HAVE_EXECINFO)
107 check_include_file (inttypes.h HAVE_INTTYPES_H)
109 if (HAVE_INTTYPES_H AND HAVE_SYS_TYPES_H)
110 set (TEST_APP "#include <sys/types.h>
111 #include <inttypes.h>"
114 EXECUTE_PROCESS (COMMAND echo ${TEST_APP}
115 COMMAND ${CMAKE_C_COMPILER} -c -xc -
116 ERROR_VARIABLE INTTYPES_SYSTYPES_TEST_ERRORS
119 if (INTTYPES_SYSTYPES_TEST_ERRORS)
120 set (HAVE_INTTYPES_H FALSE)
122 set (TEST_APP "#include <sys/types.h>
123 #include <inttypes.h>
124 uintmax_t i = (uintmax_t) -1\;"
127 EXECUTE_PROCESS (COMMAND echo ${TEST_APP}
128 COMMAND ${CMAKE_C_COMPILER} -c -xc -
129 ERROR_VARIABLE INTTYPES_SYSTYPES_UINTMAX_TEST_ERRORS
132 if (NOT INTTYPES_SYSTYPES_UINTMAX_TEST_ERRORS)
133 set (HAVE_INTTYPES_H_WITH_UINTMAX TRUE)
139 set (TEST_APP "#include <inttypes.h>
145 EXECUTE_PROCESS (COMMAND echo ${TEST_APP}
146 COMMAND ${CMAKE_C_COMPILER} -c -xc -
147 ERROR_VARIABLE INTTYPES_BROKEN_PRI_TEST_ERRORS
150 if (INTTYPES_BROKEN_PRI_TEST_ERRORS)
151 set (PRI_MACROS_BROKEN TRUE)
155 check_function_exists (strerror_r HAVE_STRERROR_R)
158 set (TEST_APP "int main ()
161 char x = *strerror_r (0, buf, sizeof buf)\;
165 EXECUTE_PROCESS (COMMAND echo ${TEST_APP}
166 COMMAND ${CMAKE_C_COMPILER} -E -xc -
167 OUTPUT_VARIABLE STR_ERROR_CHAR_P_OUTPUT
168 ERROR_VARIABLE STR_ERROR_CHAR_P_TEST
171 if (STR_ERROR_CHAR_P_TEST)
172 set (STRERROR_R_CHAR_P TRUE)
173 message (STATUS "strerror_r returns char*")