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