Removed HAVE_CONFIG_H
[amule.git] / cmake / glib21.cmake
blob1fd2aef0e0a1814dcaaae729946a292a748b4dc8
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)
19                                 Lucky GNU user
20                         #endif
21                 #endif"
22         )
24         execute_process (COMMAND echo ${TEST_APP}
25                 COMMAND ${CMAKE_C_COMPILER} -E -xc -
26                 OUTPUT_VARIABLE GLIB_TEST_OUTPUT
27         )
29         string (REGEX MATCH "Lucky GNU user" MATCH "${GLIB_TEST_OUTPUT}")
31         if (${MATCH})
32                 set (__GLIBC__ TRUE)
33                 message (STATUS "glibc -- found")
34         endif()
36         check_function_exists (posix_fallocate HAVE_POSIX_FALLOCATE)
37 endif()
39 if (BUILD_DAEMON)
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)
44 endif()
46 if (BUILD_DAEMON OR BUILD_WEBSERVER)
47         check_include_file (sys/types.h HAVE_SYS_TYPES_H)
48 endif()
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)
53 endif()
55 if (NEED_LIB_MULEAPPCORE)
56         check_include_file (errno.h HAVE_ERRNO_H)
57         check_include_file (signal.h HAVE_SIGNAL_H)
59         if (ENABLE_MMAP)
60                 check_include_file (sys/mman.h HAVE_SYS_MMAN_H)
62                 if (HAVE_SYS_MMAN_H)
63                         check_function_exists (munmap HAVE_MUNMAP)
65                         if (HAVE_MUNMAP)
66                                 check_function_exists (sysconf HAVE_SYSCONF)
68                                 if (HAVE_SYSCONF)
69                                         set (TEST_APP "#include <unistd.h>
70                                                 main ()
71                                                 {
72                                                         return sysconf (_SC_PAGESIZE)\;
73                                                 }"
74                                         )
76                                         EXECUTE_PROCESS (COMMAND echo ${TEST_APP}
77                                                 COMMAND ${CMAKE_C_COMPILER} -xc -
78                                                 ERROR_VARIABLE SC_PAGESIZE_ERROR
79                                         )
81                                         if (SC_PAGESIZE_ERROR)
82                                                 MESSAGE (STATUS "_SC_PAGESIZE not defined, mmap support is disabled")
83                                         else()
84                                                 message (STATUS "_SC_PAGESIZE found")
85                                                 set (HAVE__SC_PAGESIZE TRUE)
86                                         endif()
87                                 else()
88                                         message (STATUS "sysconf function not fouind, mmap support is disabled")
89                                 endif()
90                         else()
91                                 message (STATUS "munmap function not found, mmap support is disabled")
92                         endif()
93                 else()
94                         message (STATUS "sys/mman.h wasn't found, mmap support is disabled")
95                 endif()
96         endif()
97 endif()
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>"
107                 )
109                 EXECUTE_PROCESS (COMMAND echo ${TEST_APP}
110                         COMMAND ${CMAKE_C_COMPILER} -c -xc -
111                         ERROR_VARIABLE INTTYPES_SYSTYPES_TEST_ERRORS
112                 )
114                 if (INTTYPES_SYSTYPES_TEST_ERRORS)
115                         set (HAVE_INTTYPES_H FALSE)
116                 else()
117                         set (TEST_APP "#include <sys/types.h>
118                                 #include <inttypes.h>
119                                 uintmax_t i = (uintmax_t) -1\;"
120                         )
122                         EXECUTE_PROCESS (COMMAND echo ${TEST_APP}
123                                 COMMAND ${CMAKE_C_COMPILER} -c -xc -
124                                 ERROR_VARIABLE INTTYPES_SYSTYPES_UINTMAX_TEST_ERRORS
125                         )
127                         if (NOT INTTYPES_SYSTYPES_UINTMAX_TEST_ERRORS)
128                                 set (HAVE_INTTYPES_H_WITH_UINTMAX TRUE)
129                         endif()
130                 endif()
131         endif()
133         if (HAVE_INTTYPES_H)
134                 set (TEST_APP "#include <inttypes.h>
135                         #ifdef PRId32
136                         char *p = PRId32\;
137                         #endif"
138                 )
140                 EXECUTE_PROCESS (COMMAND echo ${TEST_APP}
141                         COMMAND ${CMAKE_C_COMPILER} -c -xc -
142                         ERROR_VARIABLE INTTYPES_BROKEN_PRI_TEST_ERRORS
143                 )
145                 if (INTTYPES_BROKEN_PRI_TEST_ERRORS)
146                         set (PRI_MACROS_BROKEN TRUE)
147                 endif()
148         endif()
150         check_function_exists (strerror_r HAVE_STRERROR_R)
152         if (HAVE_STRERROR_R)
153                 set (TEST_APP "int main ()
154                         {
155                                 char buf[100]\;
156                                 char x = *strerror_r (0, buf, sizeof buf)\;
157                         }"
158                 )
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
164                 )
166                 if (STR_ERROR_CHAR_P_TEST)
167                         set (STRERROR_R_CHAR_P TRUE)
168                         message (STATUS "strerror_r returns char*")
169                 endif()
170         endif()
171 endif()