xref: /5.5.2/moxi/CMakeLists.txt (revision 5bbc7ed0)
1PROJECT(Moxi)
2CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
3
4IF (${CMAKE_MAJOR_VERSION} GREATER 2)
5    CMAKE_POLICY(SET CMP0042 NEW)
6ENDIF (${CMAKE_MAJOR_VERSION} GREATER 2)
7
8ADD_SUBDIRECTORY(libmemcached)
9
10INCLUDE(CheckFunctionExists)
11INCLUDE(CheckIncludeFiles)
12
13INCLUDE_DIRECTORIES(BEFORE ${LIBEVENT_INCLUDE_DIR}
14                           ${CMAKE_INSTALL_PREFIX}/include
15                           ${CMAKE_CURRENT_SOURCE_DIR}/include
16                           ${CMAKE_SOURCE_DIR}/platform/include
17                           ${PROJECT_SOURCE_DIR}/libmemcached
18                           ${CMAKE_CURRENT_BINARY_DIR}
19                           ${CMAKE_CURRENT_SOURCE_DIR})
20
21INCLUDE_DIRECTORIES(AFTER ${CURL_INCLUDE_DIR})
22
23
24ADD_LIBRARY(conflate SHARED
25            conflate/adhoc_commands.c
26            conflate/conflate.c
27            conflate/conflate_internal.h
28            conflate/kvpair.c
29            conflate/logging.c
30            conflate/persist.c
31            conflate/rest.c
32            conflate/rest.h
33            conflate/util.c
34            conflate/xmpp.c)
35
36IF(WIN32)
37    INCLUDE_DIRECTORIES(AFTER ${CMAKE_SOURCE_DIR}/platform/include/win32)
38    ADD_DEFINITIONS(-Dsnprintf=_snprintf)
39ELSE(WIN32)
40    SET(ZLIB z)
41ENDIF(WIN32)
42
43IF(APPLE)
44   FIND_LIBRARY(SECURITY NAMES Security)
45   FIND_LIBRARY(CORE_FOUNDATION NAMES CoreFoundation)
46   SET(SSL_LIBRARIES ${SECURITY} ${CORE_FOUNDATION})
47ELSE(APPLE)
48   SET(SSL_LIBRARIES ${OPENSSL_LIBRARIES})
49ENDIF(APPLE)
50
51TARGET_LINK_LIBRARIES(conflate ${CURL_LIBRARIES} platform ${ZLIB}
52                               ${SSL_LIBRARIES})
53SET_TARGET_PROPERTIES(conflate PROPERTIES SOVERSION 1.0.0)
54SET_TARGET_PROPERTIES(conflate PROPERTIES COMPILE_FLAGS
55                               -DBUILDING_LIBCONFLATE=1)
56
57IF (INSTALL_HEADER_FILES)
58    INSTALL(FILES include/libconflate/conflate.h
59            DESTINATION include/libconflate)
60ENDIF (INSTALL_HEADER_FILES)
61
62INSTALL(TARGETS conflate
63        RUNTIME DESTINATION bin
64        LIBRARY DESTINATION lib
65        ARCHIVE DESTINATION lib)
66
67ADD_EXECUTABLE(tests_check_kvpair
68               include/libconflate/conflate.h
69               tests/conflate/check_kvpair.c
70               tests/conflate/test_common.c
71               tests/conflate/test_common.h)
72TARGET_LINK_LIBRARIES(tests_check_kvpair conflate)
73ADD_TEST(libconflate-test-suite tests_check_kvpair)
74
75ADD_LIBRARY(vbucket SHARED
76            include/libvbucket/vbucket.h
77            include/libvbucket/visibility.h
78            vbucket/crc32.c
79            vbucket/hash.h
80            vbucket/hash.h
81            vbucket/ketama.c
82            vbucket/rfc1321/global.h
83            vbucket/rfc1321/md5.h
84            vbucket/vbucket.c)
85
86SET_TARGET_PROPERTIES(vbucket PROPERTIES SOVERSION 1.1.1)
87SET_TARGET_PROPERTIES(vbucket PROPERTIES
88                      COMPILE_FLAGS -DBUILDING_LIBVBUCKET=1)
89
90IF (WIN32)
91    TARGET_LINK_LIBRARIES(vbucket cJSON)
92ELSE (WIN32)
93    TARGET_LINK_LIBRARIES(vbucket cJSON m)
94ENDIF (WIN32)
95
96IF (INSTALL_HEADER_FILES)
97   INSTALL(FILES
98           include/libvbucket/vbucket.h
99           include/libvbucket/visibility.h
100           DESTINATION include/libvbucket)
101ENDIF(INSTALL_HEADER_FILES)
102
103INSTALL(TARGETS vbucket
104        RUNTIME DESTINATION bin
105        LIBRARY DESTINATION lib
106        ARCHIVE DESTINATION lib)
107
108ADD_EXECUTABLE(vbuckettool
109               include/libvbucket/vbucket.h
110               include/libvbucket/visibility.h
111               vbucket/vbuckettool.c)
112TARGET_LINK_LIBRARIES(vbuckettool vbucket)
113
114ADD_EXECUTABLE(vbucketkeygen
115               include/libvbucket/vbucket.h
116               include/libvbucket/visibility.h
117               vbucket/vbucketkeygen.c)
118TARGET_LINK_LIBRARIES(vbucketkeygen vbucket)
119
120#
121# The tests. These are automatically executed as part of the build!
122#
123
124ADD_EXECUTABLE(vbucket_testapp
125               include/libvbucket/vbucket.h
126               include/libvbucket/visibility.h
127               tests/vbucket/macros.h
128               tests/vbucket/testapp.c)
129TARGET_LINK_LIBRARIES(vbucket_testapp vbucket)
130
131ADD_EXECUTABLE(vbucket_regression
132               include/libvbucket/vbucket.h
133               include/libvbucket/visibility.h
134               tests/vbucket/macros.h
135               tests/vbucket/regression.c)
136TARGET_LINK_LIBRARIES(vbucket_regression vbucket)
137
138ADD_EXECUTABLE(vbucket_testketama
139               vbucket/ketama.c
140               vbucket/rfc1321/global.h
141               vbucket/rfc1321/md5.h
142               tests/vbucket/testketama.c)
143TARGET_LINK_LIBRARIES(vbucket_testketama vbucket)
144
145ADD_TEST(vbucket-basic-tests vbucket_testapp ${CMAKE_CURRENT_SOURCE_DIR})
146ADD_TEST(vbucket-regression-tests vbucket_regression ${CMAKE_CURRENT_SOURCE_DIR})
147ADD_TEST(vbucket-ketama-tests vbucket_testketama)
148
149
150
151
152
153IF ("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
154   SET(UMEM_LIBRARY -lumem)
155   SET(PRVILEGES_SOURCES src/solaris_priv.c)
156ENDIF ("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
157
158IF (WIN32)
159   INCLUDE_DIRECTORIES(AFTER ${CMAKE_CURRENT_SOURCE_DIR}/../platform/include/win32)
160ENDIF (WIN32)
161
162CHECK_INCLUDE_FILES("umem.h" HAVE_UMEM_H)
163CHECK_INCLUDE_FILES("sysexits.h" HAVE_SYSEXITS_H)
164CHECK_FUNCTION_EXISTS(getpwnam HAVE_GETPWNAM)
165CHECK_FUNCTION_EXISTS(getrlimit HAVE_GETRLIMIT)
166CHECK_FUNCTION_EXISTS(mlockall HAVE_MLOCKALL)
167CHECK_FUNCTION_EXISTS(getpagesizes HAVE_GETPAGESIZES)
168
169SET(CONFLATE_DB_PATH ${CMAKE_INSTALL_PREFIX}/var/lib/moxi)
170
171IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
172   EXECUTE_PROCESS(COMMAND git describe
173                   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
174                   OUTPUT_VARIABLE MOXI_VERSION
175                   ERROR_QUIET
176                   OUTPUT_STRIP_TRAILING_WHITESPACE)
177ELSE (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
178   SET(MOXI_VERSION "unknown")
179ENDIF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
180
181CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/src/config.cmake.h
182                ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
183
184ADD_EXECUTABLE(moxi_sizes tests/moxi/sizes.c)
185ADD_EXECUTABLE(moxi_htgram_test tests/moxi/htgram_test.c src/htgram.c)
186
187ADD_EXECUTABLE(moxi
188               src/memcached.c src/genhash.c src/hash.c src/slabs.c
189               src/items.c src/assoc.c src/thread.c src/stats.c
190               src/util.c src/work.c src/cproxy.c src/cproxy_config.c
191               src/cproxy_protocol_a.c src/cproxy_protocol_a2a.c
192               src/cproxy_protocol_a2b.c src/cproxy_protocol_b.c
193               src/cproxy_protocol_b2b.c src/cproxy_multiget.c
194               src/cproxy_stats.c src/cproxy_front.c src/matcher.c
195               src/murmur_hash.c src/mcs.c src/stdin_check.c src/log.c
196               src/htgram.c src/agent_config.c src/agent_ping.c
197               src/agent_stats.c src/daemon.c src/cache.c src/strsep.c
198               ${PRVILEGES_SOURCES})
199
200TARGET_LINK_LIBRARIES(moxi conflate vbucket platform mcd ${LIBEVENT_LIBRARIES} ${COUCHBASE_NETWORK_LIBS} ${UMEM_LIBRARY})
201
202INSTALL(TARGETS moxi vbucketkeygen vbuckettool
203        RUNTIME DESTINATION bin)
204
205ADD_TEST(moxi-sizes moxi_sizes)
206ADD_TEST(moxi-htgram-test moxi_htgram_test)
207
208IF (${CMAKE_MAJOR_VERSION} LESS 3)
209   SET_TARGET_PROPERTIES(vbucket PROPERTIES INSTALL_NAME_DIR
210                         ${CMAKE_INSTALL_PREFIX}/lib)
211ENDIF (${CMAKE_MAJOR_VERSION} LESS 3)
212