1 # Recreation of our old glib check. Don't know what to do with it
2 # so leaving as is now. It's detected by nothin more.
4 include (CheckFunctionExists)
5 include (CheckIncludeFile)
6 include (CheckIncludeFileCXX)
8 if (BUILD_MONOLITHIC OR BUILD_DAEMON)
9 check_function_exists (fallocate HAVE_FALLOCATE)
10 check_function_exists (getrlimit HAVE_GETRLIMIT)
11 check_function_exists (setrlimit HAVE_SETRLIMIT)
12 check_include_file (fcntl.h HAVE_FCNTL_H)
13 check_include_file (sys/resource.h HAVE_SYS_RESOURCE_H)
14 check_include_file (sys/statvfs.h HAVE_SYS_STATVFS_H)
16 set (TEST_APP "#include <features.h>
17 #ifdef __GNU_LIBRARY__
18 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
24 execute_process (COMMAND echo ${TEST_APP}
25 COMMAND ${CMAKE_C_COMPILER} -E -xc -
26 OUTPUT_VARIABLE GLIB_TEST_OUTPUT
29 string (REGEX MATCH "Lucky GNU user" MATCH "${GLIB_TEST_OUTPUT}")
33 message (STATUS "glibc -- found")
36 check_function_exists (posix_fallocate HAVE_POSIX_FALLOCATE)
40 check_include_file (sys/select.h HAVE_SYS_SELECT_H)
41 check_include_file (sys/time.h HAVE_SYS_TIME_H)
42 check_include_file (sys/wait.h HAVE_SYS_WAIT_H)
43 check_include_file (unistd.h HAVE_UNISTD_H)
46 if (BUILD_DAEMON OR BUILD_WEBSERVER)
47 check_include_file (sys/types.h HAVE_SYS_TYPES_H)
50 if (BUILD_DAEMON OR BUILD_WEBSERVER OR NEED_LIB_MULECOMMON)
51 include (CheckTypeSize) #Sets also HAVE_SYS_TYPES_H, HAVE_STDINT_H, and HAVE_STDDEF_H
52 check_type_size (int INTSIZE)
55 if (NEED_LIB_MULEAPPCORE)
56 check_include_file (errno.h HAVE_ERRNO_H)
57 check_include_file (signal.h HAVE_SIGNAL_H)
60 check_include_file (sys/mman.h HAVE_SYS_MMAN_H)
63 check_function_exists (munmap HAVE_MUNMAP)
66 check_function_exists (sysconf HAVE_SYSCONF)
69 set (TEST_APP "#include <unistd.h>
72 return sysconf (_SC_PAGESIZE)\;
76 EXECUTE_PROCESS (COMMAND echo ${TEST_APP}
77 COMMAND ${CMAKE_C_COMPILER} -xc -
78 ERROR_VARIABLE SC_PAGESIZE_ERROR
81 if (SC_PAGESIZE_ERROR)
82 MESSAGE (STATUS "_SC_PAGESIZE not defined, mmap support is disabled")
84 message (STATUS "_SC_PAGESIZE found")
85 set (HAVE__SC_PAGESIZE TRUE)
88 message (STATUS "sysconf function not fouind, mmap support is disabled")
91 message (STATUS "munmap function not found, mmap support is disabled")
94 message (STATUS "sys/mman.h wasn't found, mmap support is disabled")
99 if (NEED_LIB_MULECOMMON)
100 check_include_file_cxx (cxxabi.h HAVE_CXXABI)
101 check_include_file (execinfo.h HAVE_EXECINFO)
102 check_include_file (inttypes.h HAVE_INTTYPES_H)
104 if (HAVE_INTTYPES_H AND HAVE_SYS_TYPES_H)
105 set (TEST_APP "#include <sys/types.h>
106 #include <inttypes.h>"
109 EXECUTE_PROCESS (COMMAND echo ${TEST_APP}
110 COMMAND ${CMAKE_C_COMPILER} -c -xc -
111 ERROR_VARIABLE INTTYPES_SYSTYPES_TEST_ERRORS
114 if (INTTYPES_SYSTYPES_TEST_ERRORS)
115 set (HAVE_INTTYPES_H FALSE)
117 set (TEST_APP "#include <sys/types.h>
118 #include <inttypes.h>
119 uintmax_t i = (uintmax_t) -1\;"
122 EXECUTE_PROCESS (COMMAND echo ${TEST_APP}
123 COMMAND ${CMAKE_C_COMPILER} -c -xc -
124 ERROR_VARIABLE INTTYPES_SYSTYPES_UINTMAX_TEST_ERRORS
127 if (NOT INTTYPES_SYSTYPES_UINTMAX_TEST_ERRORS)
128 set (HAVE_INTTYPES_H_WITH_UINTMAX TRUE)
134 set (TEST_APP "#include <inttypes.h>
140 EXECUTE_PROCESS (COMMAND echo ${TEST_APP}
141 COMMAND ${CMAKE_C_COMPILER} -c -xc -
142 ERROR_VARIABLE INTTYPES_BROKEN_PRI_TEST_ERRORS
145 if (INTTYPES_BROKEN_PRI_TEST_ERRORS)
146 set (PRI_MACROS_BROKEN TRUE)
150 check_function_exists (strerror_r HAVE_STRERROR_R)
153 set (TEST_APP "int main ()
156 char x = *strerror_r (0, buf, sizeof buf)\;
160 EXECUTE_PROCESS (COMMAND echo ${TEST_APP}
161 COMMAND ${CMAKE_C_COMPILER} -E -xc -
162 OUTPUT_VARIABLE STR_ERROR_CHAR_P_OUTPUT
163 ERROR_VARIABLE STR_ERROR_CHAR_P_TEST
166 if (STR_ERROR_CHAR_P_TEST)
167 set (STRERROR_R_CHAR_P TRUE)
168 message (STATUS "strerror_r returns char*")