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