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