90ebc261b471b98ad893a62bc44d3219ef7132b0
[m6w6/libmemcached] / CMake / _Include.cmake
1 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")
2
3 include(_Configure)
4 configure_init(${CMAKE_BINARY_DIR}/mem_config.h)
5
6 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
7 include(CTest)
8 endif()
9
10 include(CMakePushCheckState)
11 include(CMakePackageConfigHelpers)
12
13 macro(make_have_identifier NAME ID)
14 string(MAKE_C_IDENTIFIER ${NAME} _make_have_identifier)
15 string(TOUPPER ${_make_have_identifier} _make_have_identifier)
16 set(${ID} HAVE_${_make_have_identifier})
17 endmacro()
18
19 include(CheckCCompilerFlag)
20 macro(check_flag FLAG HAVE)
21 configure_define(${HAVE})
22 check_c_compiler_flag("${FLAG}" ${HAVE})
23 endmacro()
24 include(CheckCXXCompilerFlag)
25 macro(check_cxx_flag FLAG HAVE)
26 configure_define(${HAVE})
27 check_cxx_compiler_flag("${FLAG}" ${HAVE})
28 endmacro()
29 include(CheckSymbolExists)
30 macro(check_symbol NAME HEADER)
31 make_have_identifier(${NAME} HAVE)
32 configure_define(${HAVE})
33 cmake_push_check_state()
34 if(${ARGC} GREATER 1)
35 string(APPEND CMAKE_REQUIRED_FLAGS " ${ARGV2}")
36 endif()
37 check_symbol_exists(${NAME} ${HEADER} ${HAVE})
38 cmake_pop_check_state()
39 endmacro()
40 include(CheckCXXSymbolExists)
41 macro(check_cxx_symbol NAME HEADER)
42 make_have_identifier(${NAME} HAVE)
43 configure_define(${HAVE})
44 cmake_push_check_state()
45 if(${ARGC} GREATER 1)
46 string(APPEND CMAKE_REQUIRED_FLAGS " ${ARGN}")
47 endif()
48 check_cxx_symbol_exists(${NAME} ${HEADER} ${HAVE})
49 cmake_pop_check_state()
50 endmacro()
51 include(CheckIncludeFile)
52 macro(check_include HEADER)
53 make_have_identifier(${HEADER} HAVE)
54 configure_define(${HAVE})
55 cmake_push_check_state()
56 if(${ARGC} GREATER 1)
57 string(APPEND CMAKE_REQUIRED_FLAGS " ${ARGN}")
58 endif()
59 check_include_file(${HEADER} ${HAVE})
60 cmake_pop_check_state()
61 endmacro()
62 include(CheckIncludeFileCXX)
63 macro(check_cxx_include HEADER)
64 make_have_identifier(${HEADER} HAVE)
65 configure_define(${HAVE})
66 cmake_push_check_state()
67 if(${ARGC} GREATER 1)
68 string(APPEND CMAKE_REQUIRED_FLAGS " ${ARGN}")
69 endif()
70 check_include_file_cxx(${HEADER} ${HAVE})
71 cmake_pop_check_state()
72 endmacro()
73 include(CheckTypeSize)
74 macro(check_type TYPE)
75 make_have_identifier(${TYPE} HAVE)
76 configure_define(${HAVE})
77 cmake_push_check_state()
78 if(${ARGC} GREATER 1)
79 list(APPEND CMAKE_EXTRA_INCLUDE_FILES ${ARGN})
80 endif()
81 check_type_size(${TYPE} ${HAVE})
82 cmake_pop_check_state()
83 endmacro()
84 include(CheckCSourceCompiles)
85 macro(check_c_source SOURCE HAVE)
86 configure_define(${HAVE})
87 check_c_source_compiles("${SOURCE}" ${HAVE})
88 endmacro()
89 include(CheckCXXSourceCompiles)
90 macro(check_cxx_source SOURCE HAVE)
91 configure_define(${HAVE})
92 check_cxx_source_compiles("${SOURCE}" ${HAVE})
93 endmacro()
94
95 include(CheckBacktrace)
96 include(CheckByteswap)
97 include(CheckDependency)
98 include(CheckDtrace)
99 include(CheckPkgconf)
100 include(CheckDebug)
101 include(CheckThreads)
102 include(CheckVisibility)
103 include(InstallPublicHeaders)
104
105 ## sasl
106 configure_define_01(LIBMEMCACHED_WITH_SASL_SUPPORT)
107 if(ENABLE_SASL)
108 check_dependency(LIBSASL sasl2)
109 if(HAVE_LIBSASL)
110 set(LIBMEMCACHED_WITH_SASL_SUPPORT 1)
111 endif()
112 endif()
113
114 ## hashes
115 configure_set(HAVE_FNV64_HASH ${ENABLE_HASH_FNV64})
116 configure_set(HAVE_MURMUR_HASH ${ENABLE_HASH_MURMUR})
117 configure_set(HAVE_HSIEH_HASH ${ENABLE_HASH_HSIEH})
118
119 check_include(alloca.h)
120 check_include(arpa/inet.h)
121 check_include(dlfcn.h)
122 check_include(getopt.h)
123 check_include(libgen.h)
124 check_include(netdb.h)
125 check_include(netinet/in.h)
126 check_include(netinet/tcp.h)
127 check_include(poll.h)
128 check_include(strings.h)
129 check_include(sys/poll.h)
130 check_include(sys/socket.h)
131 check_include(sys/time.h)
132 check_include(sys/un.h)
133 check_include(unistd.h)
134
135 check_type(in_port_t netinet/in.h)
136 check_type(pid_t sys/types.h)
137 check_type(ssize_t sys/types.h)
138 check_type("struct msghdr" sys/socket.h)
139
140 check_cxx_symbol(abi::__cxa_demangle cxxabi.h)
141 check_symbol(ERESTART errno.h)
142 check_symbol(fcntl fcntl.h)
143 check_symbol(gettimeofday sys/time.h)
144 check_symbol(htonll arpa/inet.h)
145 check_symbol(index strings.h)
146 check_symbol(MSG_DONTWAIT sys/socket.h)
147 check_symbol(MSG_MORE sys/socket.h)
148 check_symbol(MSG_NOSIGNAL sys/socket.h)
149 check_symbol(SO_RCVTIMEO sys/socket.h)
150 check_symbol(SO_SNDTIMEO sys/socket.h)
151 check_symbol(rand stdlib.h)
152 check_symbol(random stdlib.h)
153 check_symbol(realpath stdlib.h)
154 check_symbol(sendmsg sys/socket.h)
155 check_symbol(setenv stdlib.h)
156 check_symbol(strerror_r string.h)
157 check_c_source("
158 #include <string.h>
159 int main() {
160 char x;
161 return *strerror_r(0, &x, 1);
162 }"
163 HAVE_STRERROR_R_CHAR_P
164 )
165
166 if(WIN32)
167 check_include(io.h)
168 check_include(winsock2.h)
169 check_include(ws2tcpip.h)
170
171 check_symbol(htonll winsock2.h)
172 endif()