-
Notifications
You must be signed in to change notification settings - Fork 47
/
CMakeLists.txt
249 lines (217 loc) · 9.5 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
PROJECT(Memcached)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
IF (${CMAKE_MAJOR_VERSION} GREATER 2)
CMAKE_POLICY(SET CMP0042 NEW)
ENDIF (${CMAKE_MAJOR_VERSION} GREATER 2)
INCLUDE(CheckCSourceCompiles)
INCLUDE(CheckIncludeFiles)
INCLUDE(CheckIncludeFileCXX)
INCLUDE(CTest)
INCLUDE(GenerateExportHeader)
# The test program expects to find the output files in
# the root directory (that's how we built them earlier)
# let's continue to find them there until it's all done
# Unfortunately this means I need to add WORKING_DIRECTORY
# to ADD_TEST in order for it to correctly find the binary..
# (Please note that these settings only affect the BUILD
# directory structure, and not the installed directory
# structure
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
# Check if the system have a usable version of PKCS5_PBKDF2_HMAC_SHA1
CMAKE_PUSH_CHECK_STATE(RESET)
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${OPENSSL_LIBRARIES})
SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${OPENSSL_INCLUDE_DIR})
CHECK_C_SOURCE_COMPILES("
#include <openssl/evp.h>
int main() {
PKCS5_PBKDF2_HMAC_SHA1(NULL, 0, NULL, 0, 0, 0, NULL);
}" HAVE_PKCS5_PBKDF2_HMAC_SHA1)
CHECK_C_SOURCE_COMPILES("
#include <openssl/evp.h>
int main() {
PKCS5_PBKDF2_HMAC(NULL, 0, NULL, 0, 0, NULL, 0, NULL);
}" HAVE_PKCS5_PBKDF2_HMAC)
CHECK_C_SOURCE_COMPILES("
#include <openssl/ssl.h>
int main() {
long mask = SSL_OP_NO_TLSv1_1;
}" HAVE_SSL_OP_NO_TLSv1_1)
CMAKE_POP_CHECK_STATE()
CMAKE_PUSH_CHECK_STATE(RESET)
CHECK_CXX_SOURCE_COMPILES("
int main() {
const char* func = __func__;
return 1;
}" HAVE_FUNC)
CHECK_CXX_SOURCE_COMPILES("
int main() {
const char* func = __FUNCTION__;
return 1;
}" HAVE_FUNCTION)
CMAKE_POP_CHECK_STATE()
IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
EXECUTE_PROCESS(COMMAND git log -1 --pretty=format:%H
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE MEMCACHED_VERSION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
ENDIF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
IF ("${MEMCACHED_VERSION}" STREQUAL "")
string(TIMESTAMP _timestamp UTC)
set(MEMCACHED_VERSION "unknown:${_timestamp}")
ENDIF ("${MEMCACHED_VERSION}" STREQUAL "")
CHECK_SYMBOL_EXISTS(memalign malloc.h HAVE_MEMALIGN)
IF (ENABLE_DTRACE)
ADD_DEFINITIONS(-DENABLE_DTRACE=1)
ENDIF (ENABLE_DTRACE)
ADD_CUSTOM_COMMAND(OUTPUT ${Memcached_BINARY_DIR}/memcached_dtrace.h
COMMAND
${DTRACE} -h
-s ${Memcached_SOURCE_DIR}/memcached_dtrace.d
-o ${Memcached_BINARY_DIR}/memcached_dtrace.h
&& sed -itmp "s/, *char \\*/, const char \\*/g" ${Memcached_BINARY_DIR}/memcached_dtrace.h
DEPENDS
memcached_dtrace.d
COMMENT "Generating DTrace probe header file"
VERBATIM)
ADD_CUSTOM_TARGET(generate_memcached_dtrace_h
DEPENDS ${Memcached_BINARY_DIR}/memcached_dtrace.h)
INCLUDE_DIRECTORIES(BEFORE
${LIBEVENT_INCLUDE_DIR}
${SNAPPY_INCLUDE_DIR}
${OPENSSL_INCLUDE_DIR}
${CMAKE_INSTALL_PREFIX}/include
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${Platform_SOURCE_DIR}/include
${subjson_SOURCE_DIR})
INCLUDE_DIRECTORIES(AFTER
${gtest_SOURCE_DIR}/include
${phosphor_SOURCE_DIR}/include)
INCLUDE_DIRECTORIES(AFTER ${PROJECT_BINARY_DIR}/include)
IF (MEMORY_ALLOCATOR)
INCLUDE_DIRECTORIES(AFTER ${MALLOC_INCLUDE_DIR})
ELSE (MEMORY_ALLOCATOR)
SET(MALLOC_LIBRARIES "")
ENDIF (MEMORY_ALLOCATOR)
IF (BREAKPAD_FOUND)
ADD_DEFINITIONS(-DHAVE_BREAKPAD)
INCLUDE_DIRECTORIES(AFTER ${BREAKPAD_INCLUDE_DIR})
IF (UNIX)
# On Linux Breakpad unit test relies on examining the minidump -> core
# file with GDB.
FIND_PROGRAM(GDB_EXECUTABLE gdb)
IF (GDB_EXECUTABLE)
# Three tests - crashing via segfault, std::exception and unknown exception
ADD_TEST(memcached-breakpad-test-segfault ${PYTHON_EXECUTABLE}
${Memcached_SOURCE_DIR}/tests/breakpad_test.py
${Memcached_BINARY_DIR}/memcached segfault ${MINIDUMP2CORE}
${GDB_EXECUTABLE})
ADD_TEST(memcached-breakpad-test-std-exception ${PYTHON_EXECUTABLE}
${Memcached_SOURCE_DIR}/tests/breakpad_test.py
${Memcached_BINARY_DIR}/memcached std_exception ${MINIDUMP2CORE}
${GDB_EXECUTABLE})
ADD_TEST(memcached-breakpad-test-unknown-exception ${PYTHON_EXECUTABLE}
${Memcached_SOURCE_DIR}/tests/breakpad_test.py
${Memcached_BINARY_DIR}/memcached unknown_exception ${MINIDUMP2CORE}
${GDB_EXECUTABLE})
ELSE (GDB_EXECUTABLE)
MESSAGE(STATUS "GDB not available, skipping breakpad test")
ENDIF (GDB_EXECUTABLE)
# ELSEIF (WIN32)
# Disable the test on Windows until we understand why we're seeing all
# of the temporary test failures caused by python not detecting that
# the processes died.
# On Windows the test doesn't use minidump-2-core or GDB.
# ADD_TEST(breakpad-test
# ${PYTHON_EXECUTABLE}
# ${Memcached_SOURCE_DIR}/tests/breakpad_test.py
# ${Memcached_BINARY_DIR}/memcached)
ENDIF (UNIX)
ENDIF (BREAKPAD_FOUND)
IF (MEMORY_ALLOCATOR STREQUAL jemalloc OR MEMORY_ALLOCATOR STREQUAL badmalloc)
LIST(APPEND MEMORY_TRACKING_SRCS
${Memcached_SOURCE_DIR}/daemon/alloc_hooks_${MEMORY_ALLOCATOR}.cc)
ELSE ()
LIST(APPEND MEMORY_TRACKING_SRCS
${Memcached_SOURCE_DIR}/daemon/alloc_hooks_dummy.cc)
ENDIF ()
LIST(APPEND MEMORY_TRACKING_SRCS ${Memcached_SOURCE_DIR}/daemon/alloc_hooks.h)
IF (APPLE)
LIST(APPEND MEMORY_TRACKING_SRCS
${Memcached_SOURCE_DIR}/daemon/darwin_zone.cc
${Memcached_SOURCE_DIR}/daemon/darwin_zone.h)
ENDIF (APPLE)
ADD_LIBRARY(memory_tracking OBJECT ${MEMORY_TRACKING_SRCS})
IF (WIN32)
INCLUDE_DIRECTORIES(AFTER ${Platform_SOURCE_DIR}/include/win32)
ENDIF (WIN32)
# We're using all of the sources to build up the server from one of
# the unit tests so let's just stash them in a variable
LIST(APPEND CBSASL_SOURCES
${Memcached_SOURCE_DIR}/include/cbsasl/cbsasl.h
${Memcached_SOURCE_DIR}/include/cbsasl/saslauthd_config.h
${Memcached_SOURCE_DIR}/include/cbsasl/visibility.h
${Memcached_SOURCE_DIR}/cbsasl/cbsasl_internal.h
${Memcached_SOURCE_DIR}/cbsasl/client.cc
${Memcached_SOURCE_DIR}/cbsasl/common.cc
${Memcached_SOURCE_DIR}/cbsasl/log.cc
${Memcached_SOURCE_DIR}/cbsasl/mechanismfactory.cc
${Memcached_SOURCE_DIR}/cbsasl/mechanismfactory.h
${Memcached_SOURCE_DIR}/cbsasl/plain/check_password.cc
${Memcached_SOURCE_DIR}/cbsasl/plain/check_password.h
${Memcached_SOURCE_DIR}/cbsasl/plain/plain.cc
${Memcached_SOURCE_DIR}/cbsasl/plain/plain.h
${Memcached_SOURCE_DIR}/cbsasl/password_database.cc
${Memcached_SOURCE_DIR}/cbsasl/password_database.h
${Memcached_SOURCE_DIR}/cbsasl/pwconv.cc
${Memcached_SOURCE_DIR}/cbsasl/pwconv.h
${Memcached_SOURCE_DIR}/cbsasl/pwfile.cc
${Memcached_SOURCE_DIR}/cbsasl/pwfile.h
${Memcached_SOURCE_DIR}/cbsasl/saslauthd_config.cc
${Memcached_SOURCE_DIR}/cbsasl/scram-sha/scram-sha.cc
${Memcached_SOURCE_DIR}/cbsasl/scram-sha/scram-sha.h
${Memcached_SOURCE_DIR}/cbsasl/scram-sha/stringutils.cc
${Memcached_SOURCE_DIR}/cbsasl/scram-sha/stringutils.h
${Memcached_SOURCE_DIR}/cbsasl/server.cc
${Memcached_SOURCE_DIR}/cbsasl/strcmp.cc
${Memcached_SOURCE_DIR}/cbsasl/strerror.cc
${Memcached_SOURCE_DIR}/cbsasl/user.cc
${Memcached_SOURCE_DIR}/cbsasl/user.h
${Memcached_SOURCE_DIR}/cbsasl/util.h)
if (NOT WIN32)
list(APPEND CBSASL_SOURCES
${Memcached_SOURCE_DIR}/cbsasl/plain/saslauthd.cc
${Memcached_SOURCE_DIR}/cbsasl/plain/saslauthd.h)
endif (NOT WIN32)
ADD_SUBDIRECTORY(etc)
ADD_SUBDIRECTORY(cbcrypto)
ADD_SUBDIRECTORY(cbsasl)
ADD_SUBDIRECTORY(time)
ADD_SUBDIRECTORY(rbac)
ADD_SUBDIRECTORY(support-files)
ADD_SUBDIRECTORY(protocol)
ADD_SUBDIRECTORY(programs)
ADD_SUBDIRECTORY(utilities)
ADD_SUBDIRECTORY(engines)
ADD_SUBDIRECTORY(extensions)
ADD_SUBDIRECTORY(testsuite)
ADD_SUBDIRECTORY(auditd)
ADD_SUBDIRECTORY(xattr)
ADD_SUBDIRECTORY(daemon)
CONFIGURE_FILE(tests/cert/testapp.pem tests/cert/testapp.pem COPYONLY)
CONFIGURE_FILE(tests/cert/testapp.cert tests/cert/testapp.cert COPYONLY)
CONFIGURE_FILE(tests/cert/client.pem tests/cert/client.pem COPYONLY)
CONFIGURE_FILE(tests/cert/client.key tests/cert/client.key COPYONLY)
CONFIGURE_FILE(tests/cert/parse-test.key tests/cert/parse-test.key COPYONLY)
CONFIGURE_FILE(tests/cert/parse-test.pem tests/cert/parse-test.pem COPYONLY)
# Second copy to test changing at runtime
CONFIGURE_FILE(tests/cert/testapp.pem tests/cert/testapp2.pem COPYONLY)
CONFIGURE_FILE(tests/cert/testapp.cert tests/cert/testapp2.cert COPYONLY)
ADD_SUBDIRECTORY(tests)
ENABLE_CODE_COVERAGE_REPORT()
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
${CMAKE_CURRENT_BINARY_DIR}/config.h)