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