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