forked from steveyen/moxi
-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
217 lines (173 loc) · 7.11 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
PROJECT(Moxi)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
IF (${CMAKE_MAJOR_VERSION} GREATER 2)
CMAKE_POLICY(SET CMP0042 NEW)
ENDIF (${CMAKE_MAJOR_VERSION} GREATER 2)
ADD_SUBDIRECTORY(libmemcached)
INCLUDE(CheckFunctionExists)
INCLUDE(CheckIncludeFiles)
ADD_DEFINITIONS(-DMOXI_ITEM_MALLOC=1)
INCLUDE_DIRECTORIES(BEFORE ${LIBEVENT_INCLUDE_DIR}
${CMAKE_INSTALL_PREFIX}/include
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/platform/include
${PROJECT_SOURCE_DIR}/libmemcached
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE_DIRECTORIES(AFTER ${CURL_INCLUDE_DIR})
ADD_LIBRARY(conflate SHARED
conflate/adhoc_commands.c
conflate/conflate.c
conflate/conflate_internal.h
conflate/kvpair.c
conflate/logging.c
conflate/persist.c
conflate/rest.c
conflate/rest.h
conflate/util.c
conflate/xmpp.c)
IF(WIN32)
INCLUDE_DIRECTORIES(AFTER ${CMAKE_SOURCE_DIR}/platform/include/win32)
IF (${CMAKE_C_COMPILER_VERSION} VERSION_LESS 19)
ADD_DEFINITIONS(-Dsnprintf=_snprintf)
ENDIF (${CMAKE_C_COMPILER_VERSION} VERSION_LESS 19)
ELSE(WIN32)
SET(ZLIB z)
ENDIF(WIN32)
IF(APPLE)
FIND_LIBRARY(SECURITY NAMES Security)
FIND_LIBRARY(CORE_FOUNDATION NAMES CoreFoundation)
SET(SSL_LIBRARIES ${SECURITY} ${CORE_FOUNDATION})
ELSE(APPLE)
SET(SSL_LIBRARIES ${OPENSSL_LIBRARIES})
ENDIF(APPLE)
TARGET_LINK_LIBRARIES(conflate ${CURL_LIBRARIES} platform ${ZLIB}
${SSL_LIBRARIES})
SET_TARGET_PROPERTIES(conflate PROPERTIES SOVERSION 1.0.0)
SET_TARGET_PROPERTIES(conflate PROPERTIES COMPILE_FLAGS
-DBUILDING_LIBCONFLATE=1)
IF (INSTALL_HEADER_FILES)
INSTALL(FILES include/libconflate/conflate.h
DESTINATION include/libconflate)
ENDIF (INSTALL_HEADER_FILES)
INSTALL(TARGETS conflate
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
ADD_EXECUTABLE(tests_check_kvpair
include/libconflate/conflate.h
tests/conflate/check_kvpair.c
tests/conflate/test_common.c
tests/conflate/test_common.h)
TARGET_LINK_LIBRARIES(tests_check_kvpair conflate)
ADD_TEST(libconflate-test-suite tests_check_kvpair)
ADD_LIBRARY(vbucket SHARED
include/libvbucket/vbucket.h
include/libvbucket/visibility.h
vbucket/crc32.c
vbucket/hash.h
vbucket/hash.h
vbucket/ketama.c
vbucket/rfc1321/global.h
vbucket/rfc1321/md5.h
vbucket/vbucket.c)
SET_TARGET_PROPERTIES(vbucket PROPERTIES SOVERSION 1.1.1)
SET_TARGET_PROPERTIES(vbucket PROPERTIES
COMPILE_FLAGS -DBUILDING_LIBVBUCKET=1)
IF (WIN32)
TARGET_LINK_LIBRARIES(vbucket cJSON platform)
ELSE (WIN32)
TARGET_LINK_LIBRARIES(vbucket cJSON m platform)
ENDIF (WIN32)
IF (INSTALL_HEADER_FILES)
INSTALL(FILES
include/libvbucket/vbucket.h
include/libvbucket/visibility.h
DESTINATION include/libvbucket)
ENDIF(INSTALL_HEADER_FILES)
INSTALL(TARGETS vbucket
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
ADD_EXECUTABLE(vbuckettool
include/libvbucket/vbucket.h
include/libvbucket/visibility.h
vbucket/vbuckettool.c)
TARGET_LINK_LIBRARIES(vbuckettool vbucket)
ADD_EXECUTABLE(vbucketkeygen
include/libvbucket/vbucket.h
include/libvbucket/visibility.h
vbucket/vbucketkeygen.c)
TARGET_LINK_LIBRARIES(vbucketkeygen vbucket)
#
# The tests. These are automatically executed as part of the build!
#
ADD_EXECUTABLE(vbucket_testapp
include/libvbucket/vbucket.h
include/libvbucket/visibility.h
tests/vbucket/macros.h
tests/vbucket/testapp.c)
TARGET_LINK_LIBRARIES(vbucket_testapp vbucket)
ADD_EXECUTABLE(vbucket_regression
include/libvbucket/vbucket.h
include/libvbucket/visibility.h
tests/vbucket/macros.h
tests/vbucket/regression.c)
TARGET_LINK_LIBRARIES(vbucket_regression vbucket)
ADD_EXECUTABLE(vbucket_testketama
vbucket/ketama.c
vbucket/rfc1321/global.h
vbucket/rfc1321/md5.h
tests/vbucket/testketama.c)
TARGET_LINK_LIBRARIES(vbucket_testketama vbucket)
ADD_TEST(vbucket-basic-tests vbucket_testapp ${CMAKE_CURRENT_SOURCE_DIR})
ADD_TEST(vbucket-regression-tests vbucket_regression ${CMAKE_CURRENT_SOURCE_DIR})
ADD_TEST(vbucket-ketama-tests vbucket_testketama)
IF ("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
SET(UMEM_LIBRARY -lumem)
SET(PRVILEGES_SOURCES src/solaris_priv.c)
ENDIF ("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
IF (WIN32)
INCLUDE_DIRECTORIES(AFTER ${CMAKE_CURRENT_SOURCE_DIR}/../platform/include/win32)
ENDIF (WIN32)
CHECK_INCLUDE_FILES("umem.h" HAVE_UMEM_H)
CHECK_INCLUDE_FILES("sysexits.h" HAVE_SYSEXITS_H)
CHECK_FUNCTION_EXISTS(getpwnam HAVE_GETPWNAM)
CHECK_FUNCTION_EXISTS(getrlimit HAVE_GETRLIMIT)
CHECK_FUNCTION_EXISTS(mlockall HAVE_MLOCKALL)
CHECK_FUNCTION_EXISTS(getpagesizes HAVE_GETPAGESIZES)
SET(CONFLATE_DB_PATH ${CMAKE_INSTALL_PREFIX}/var/lib/moxi)
CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/src/config.cmake.h
${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
ADD_EXECUTABLE(moxi_sizes tests/moxi/sizes.c)
ADD_EXECUTABLE(moxi_htgram_test tests/moxi/htgram_test.c src/htgram.c)
TARGET_LINK_LIBRARIES(moxi_htgram_test platform)
ADD_EXECUTABLE(moxi
src/memcached.c src/genhash.c src/hash.c src/slabs.c
src/items.c src/assoc.c src/thread.c src/stats.c
src/util.c src/work.c src/cproxy.c src/cproxy_config.c
src/cproxy_protocol_a.c src/cproxy_protocol_a2a.c
src/cproxy_protocol_a2b.c src/cproxy_protocol_b.c
src/cproxy_protocol_b2b.c src/cproxy_multiget.c
src/cproxy_stats.c src/cproxy_front.c src/matcher.c
src/murmur_hash.c src/mcs.c src/stdin_check.c src/log.c
src/htgram.c src/agent_config.c src/agent_ping.c
src/agent_stats.c src/daemon.c src/cache.c src/strsep.c
${PRVILEGES_SOURCES})
TARGET_LINK_LIBRARIES(moxi conflate vbucket platform mcd ${LIBEVENT_LIBRARIES} ${COUCHBASE_NETWORK_LIBS} ${UMEM_LIBRARY})
INSTALL(TARGETS moxi
RUNTIME DESTINATION bin)
INSTALL(TARGETS vbucketkeygen vbuckettool
RUNTIME DESTINATION bin/tools)
IF (APPLE)
# Tools are installed in bin/tools/; need to map from there to lib/
SET_TARGET_PROPERTIES(vbucketkeygen vbuckettool
PROPERTIES
INSTALL_RPATH "@executable_path/../../lib")
ENDIF ()
ADD_TEST(moxi-sizes moxi_sizes)
ADD_TEST(moxi-htgram-test moxi_htgram_test)
IF (${CMAKE_MAJOR_VERSION} LESS 3)
SET_TARGET_PROPERTIES(vbucket PROPERTIES INSTALL_NAME_DIR
${CMAKE_INSTALL_PREFIX}/lib)
ENDIF (${CMAKE_MAJOR_VERSION} LESS 3)