bin/contrib/memaslap: attempt to fix atomics detection
[m6w6/libmemcached] / CMake / _Include.cmake
1
2 # globals
3 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
4 include(CTest)
5 endif()
6 include(GNUInstallDirs)
7 include(CMakePackageConfigHelpers)
8
9 if(CMAKE_HOST_SYSTEM_NAME MATCHES "BSD")
10 find_program(PKGCONF pkgconf)
11 if(PKGCONF)
12 set(PKG_CONFIG_EXECUTABLE ${PKGCONF})
13 endif()
14 endif()
15 find_package(PkgConfig)
16 set(THREADS_PREFER_PTHREAD_FLAG ON)
17 find_package(Threads REQUIRED)
18
19 # locals
20 include(InstallPublicHeaders)
21 include(SafeString)
22 include(CheckDebug)
23 include(CheckDecl)
24 include(CheckDependency)
25 include(CheckHeader)
26 include(CheckCompiles)
27 include(CheckType)
28 include(CheckAtomics)
29 include(TestBigEndian)
30 include(CheckByteswap)
31
32 # configuration
33
34 ## debug
35 check_debug()
36
37 ## memaslap
38 if(ENABLE_MEMASLAP)
39 check_atomics()
40 check_dependency(LIBEVENT event event.h)
41 check_decl(getline stdio.h)
42 if(HAVE_LIBEVENT AND HAVE_C_STDATOMIC)
43 set(HAVE_MEMASLAP 1)
44 endif()
45 endif()
46
47 ## dtrace
48 include(EnableDtrace)
49 if(ENABLE_DTRACE)
50 find_package(DTrace)
51 if(DTRACE_EXECUTABLE)
52 set(HAVE_DTRACE 1)
53 else()
54 message(WARNING "The dtrace command is required to enable dtrace/systemtap support.")
55 endif()
56 endif()
57
58 ## uuid
59 if(BUILD_TESTING)
60 if(NOT MEMCACHED_BINARY)
61 find_package(Memcached)
62 set(MEMCACHED_BINARY ${MEMCACHED_EXECUTABLE})
63 endif()
64 endif()
65
66 ## sasl
67 if(ENABLE_SASL)
68 check_dependency(LIBSASL sasl2 sasl/sasl.h)
69 if(HAVE_LIBSASL)
70 set(LIBMEMCACHED_WITH_SASL_SUPPORT 1)
71 endif()
72 endif()
73
74 ## hashes
75 if(ENABLE_HASH_FNV64)
76 set(HAVE_FNV64_HASH 1)
77 endif()
78 if(ENABLE_HASH_MURMUR)
79 set(HAVE_MURMUR_HASH 1)
80 endif()
81 if(ENABLE_HASH_HSIEH)
82 set(HAVE_HSIEH_HASH 1)
83 endif()
84
85 # system checks
86
87 test_big_endian(WORDS_BIGENDIAN)
88 check_byteswap()
89
90 check_header(alloca.h)
91 check_header(arpa/inet.h)
92 check_header(dlfcn.h)
93 check_header(errno.h)
94 check_header(fcntl.h)
95 check_header(io.h)
96 check_header(limits.h)
97 check_header(netdb.h)
98 check_header(poll.h)
99 check_header(stddef.h)
100 check_header(stdlib.h)
101 check_header(strings.h)
102 check_header(sys/socket.h)
103 check_header(sys/time.h)
104 check_header(sys/types.h)
105 check_header(sys/un.h)
106 check_header(sys/wait.h)
107 check_header(time.h)
108 check_header(umem.h)
109 check_header(unistd.h)
110 check_header(winsock2.h)
111 check_header(ws2tcpip.h)
112
113 check_decl(fcntl fcntl.h)
114 check_decl(htonll arpa/inet.h)
115 check_decl(MSG_DONTWAIT sys/socket.h)
116 check_decl(MSG_MORE sys/socket.h)
117 check_decl(MSG_NOSIGNAL sys/socket.h)
118 check_decl(SO_RCVTIMEO sys/socket.h)
119 check_decl(SO_SNDTIMEO sys/socket.h)
120 check_decl(setenv stdlib.h)
121 check_decl(strerror string.h)
122 check_decl(strerror_r string.h)
123
124 check_compiles(HAVE_STRERROR_R_CHAR_P "char x, y = *strerror_r(0,&x,1);" string.h)
125
126 check_decl(abi::__cxa_demangle cxxabi.h)
127
128 find_package(Backtrace)
129 if(Backtrace_FOUND)
130 set(HAVE_BACKTRACE 1)
131 set(BACKTRACE BACKTRACE)
132 add_library(BACKTRACE INTERFACE IMPORTED)
133 set_target_properties(BACKTRACE PROPERTIES
134 INTERFACE_LINK_LIBRARIES "${Backtrace_LIBRARIES}"
135 INTERFACE_INCLUDE_DIRECTORIES "${Backtrace_INCLUDE_DIR}")
136 endif()
137
138 check_type(in_port_t netinet/in.h)
139
140 check_header(cstdint)
141 check_header(cinttypes)
142 check_header(inttypes.h)