]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | cmake_minimum_required(VERSION 2.8.11) |
2 | ||
3 | project(ceph) | |
91327a77 | 4 | set(VERSION 12.2.10) |
7c673cae FG |
5 | |
6 | if(POLICY CMP0046) | |
7 | # Tweak policies (this one disables "missing" dependency warning) | |
8 | cmake_policy(SET CMP0046 OLD) | |
9 | endif() | |
10 | # we use LINK_PRIVATE keyword instead of PRIVATE, but do not specify the LINK_PUBLIC | |
11 | # for target_link_libraries() command when PUBLIC should be used instead, it's just | |
12 | # for backward compatibility with cmake 2.8.11. | |
13 | if (POLICY CMP0022) | |
14 | cmake_policy(SET CMP0022 OLD) | |
15 | endif (POLICY CMP0022) | |
16 | if (POLICY CMP0023) | |
17 | cmake_policy(SET CMP0023 OLD) | |
18 | endif (POLICY CMP0023) | |
19 | if(POLICY CMP0056) | |
20 | cmake_policy(SET CMP0056 NEW) | |
21 | endif() | |
22 | if(POLICY CMP0065) | |
23 | cmake_policy(SET CMP0065 NEW) | |
24 | endif() | |
31f18b77 FG |
25 | if(POLICY CMP0051) |
26 | # cmake 3.1 and higher include generator expressions in SOURCES property. | |
27 | # in BuildBoost.cmake, get_target_property(<var> <target> SOURCES) is used | |
28 | # to retrieve the source files of a target. in that case, we are only | |
29 | # interested in the *source* files. and i don't want to bother stripping off | |
30 | # the TARGET_OBJECTS elements from the returned SOURCES. so let's stick with | |
31 | # the old behavior now. | |
32 | cmake_policy(SET CMP0051 OLD) | |
33 | endif() | |
7c673cae FG |
34 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/") |
35 | ||
36 | if(CMAKE_SYSTEM_NAME MATCHES "Linux") | |
37 | set(LINUX ON) | |
38 | FIND_PACKAGE(Threads) | |
39 | elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") | |
40 | set(FREEBSD ON) | |
41 | FIND_PACKAGE(Threads) | |
42 | elseif(APPLE) | |
43 | set(OperatingSystem "Mac OS X") | |
44 | else() | |
45 | message(STATUS "No systemtype selected for building") | |
46 | endif(CMAKE_SYSTEM_NAME MATCHES "Linux") | |
47 | ||
48 | option(WITH_CCACHE "Build with ccache.") | |
49 | if(WITH_CCACHE) | |
50 | find_program(CCACHE_FOUND ccache) | |
51 | if(CCACHE_FOUND) | |
52 | message(STATUS "Building with ccache: ${CCACHE_FOUND}, CCACHE_DIR=$ENV{CCACHE_DIR}") | |
53 | set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) | |
54 | # ccache does not accelerate link (ld), but let it handle it. by passing it | |
55 | # along with cc to python's distutils, we are able to workaround | |
56 | # https://bugs.python.org/issue8027. | |
57 | set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) | |
58 | else(CCACHE_FOUND) | |
59 | message(FATAL_ERROR "Can't find ccache. Is it installed?") | |
60 | endif(CCACHE_FOUND) | |
61 | endif(WITH_CCACHE) | |
62 | ||
63 | option(WITH_MANPAGE "Build man pages." ON) | |
64 | if(WITH_MANPAGE) | |
65 | find_program(SPHINX_BUILD | |
66 | sphinx-build) | |
67 | if(NOT SPHINX_BUILD) | |
68 | message(FATAL_ERROR "Can't find sphinx-build.") | |
69 | endif(NOT SPHINX_BUILD) | |
70 | endif(WITH_MANPAGE) | |
71 | ||
72 | include_directories( | |
73 | ${PROJECT_BINARY_DIR}/src/include | |
74 | ${PROJECT_SOURCE_DIR}/src) | |
75 | ||
76 | if(OFED_PREFIX) | |
77 | include_directories(${OFED_PREFIX}/include) | |
78 | link_directories(${OFED_PREFIX}/lib) | |
79 | endif() | |
80 | ||
81 | if(FREEBSD) | |
82 | include_directories(/usr/local/include) | |
83 | link_directories(/usr/local/lib) | |
84 | list(APPEND CMAKE_REQUIRED_INCLUDES /usr/local/include) | |
85 | endif(FREEBSD) | |
86 | ||
87 | #Check Includes | |
88 | include(CheckIncludeFiles) | |
89 | include(CheckIncludeFileCXX) | |
90 | include(CheckFunctionExists) | |
91 | ||
92 | #put all the libs and binaries in one place | |
93 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | |
94 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | |
95 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | |
96 | ||
97 | ||
98 | CHECK_FUNCTION_EXISTS(fallocate CEPH_HAVE_FALLOCATE) | |
99 | CHECK_FUNCTION_EXISTS(posix_fadvise HAVE_POSIX_FADVISE) | |
100 | CHECK_FUNCTION_EXISTS(posix_fallocate HAVE_POSIX_FALLOCATE) | |
101 | CHECK_FUNCTION_EXISTS(syncfs HAVE_SYS_SYNCFS) | |
102 | CHECK_FUNCTION_EXISTS(sync_file_range HAVE_SYNC_FILE_RANGE) | |
103 | CHECK_FUNCTION_EXISTS(pwritev HAVE_PWRITEV) | |
104 | CHECK_FUNCTION_EXISTS(splice CEPH_HAVE_SPLICE) | |
105 | CHECK_FUNCTION_EXISTS(getgrouplist HAVE_GETGROUPLIST) | |
106 | CHECK_FUNCTION_EXISTS(fdatasync HAVE_FDATASYNC) | |
107 | CHECK_FUNCTION_EXISTS(strerror_r HAVE_STRERROR_R) | |
108 | CHECK_FUNCTION_EXISTS(name_to_handle_at HAVE_NAME_TO_HANDLE_AT) | |
109 | CHECK_FUNCTION_EXISTS(pipe2 HAVE_PIPE2) | |
91327a77 AA |
110 | CHECK_FUNCTION_EXISTS(accept4 HAVE_ACCEPT4) |
111 | ||
7c673cae FG |
112 | set(CMAKE_REQUIRED_LIBRARIES pthread) |
113 | CHECK_FUNCTION_EXISTS(pthread_spin_init HAVE_PTHREAD_SPINLOCK) | |
114 | CHECK_FUNCTION_EXISTS(pthread_set_name_np HAVE_PTHREAD_SET_NAME_NP) | |
115 | CHECK_FUNCTION_EXISTS(pthread_setname_np HAVE_PTHREAD_SETNAME_NP) | |
116 | CHECK_FUNCTION_EXISTS(pthread_getname_np HAVE_PTHREAD_GETNAME_NP) | |
b32b8144 | 117 | CHECK_FUNCTION_EXISTS(pthread_rwlockattr_setkind_np HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP) |
7c673cae | 118 | CHECK_FUNCTION_EXISTS(eventfd HAVE_EVENTFD) |
31f18b77 | 119 | CHECK_FUNCTION_EXISTS(getprogname HAVE_GETPROGNAME) |
7c673cae | 120 | |
7c673cae FG |
121 | CHECK_INCLUDE_FILES("linux/types.h" HAVE_LINUX_TYPES_H) |
122 | CHECK_INCLUDE_FILES("linux/version.h" HAVE_LINUX_VERSION_H) | |
7c673cae FG |
123 | CHECK_INCLUDE_FILES("arpa/nameser_compat.h" HAVE_ARPA_NAMESER_COMPAT_H) |
124 | CHECK_INCLUDE_FILES("sys/mount.h" HAVE_SYS_MOUNT_H) | |
125 | CHECK_INCLUDE_FILES("sys/param.h" HAVE_SYS_PARAM_H) | |
126 | CHECK_INCLUDE_FILES("sys/types.h" HAVE_SYS_TYPES_H) | |
127 | CHECK_INCLUDE_FILES("sys/vfs.h" HAVE_SYS_VFS_H) | |
128 | CHECK_INCLUDE_FILES("sys/prctl.h" HAVE_SYS_PRCTL_H) | |
129 | CHECK_INCLUDE_FILES("execinfo.h" HAVE_EXECINFO_H) | |
130 | if(LINUX) | |
131 | CHECK_INCLUDE_FILES("sched.h" HAVE_SCHED) | |
132 | endif(LINUX) | |
133 | CHECK_INCLUDE_FILES("valgrind/helgrind.h" HAVE_VALGRIND_HELGRIND_H) | |
134 | ||
135 | include(CheckTypeSize) | |
136 | set(CMAKE_EXTRA_INCLUDE_FILES "linux/types.h") | |
137 | CHECK_TYPE_SIZE(__be16 __BE16) | |
138 | CHECK_TYPE_SIZE(__be32 __BE32) | |
139 | CHECK_TYPE_SIZE(__be64 __BE64) | |
140 | CHECK_TYPE_SIZE(__le16 __LE16) | |
141 | CHECK_TYPE_SIZE(__le32 __LE32) | |
142 | CHECK_TYPE_SIZE(__le64 __LE64) | |
143 | CHECK_TYPE_SIZE(__u8 __U8) | |
144 | CHECK_TYPE_SIZE(__u16 __U16) | |
145 | CHECK_TYPE_SIZE(__u32 __U32) | |
146 | CHECK_TYPE_SIZE(__u64 __U64) | |
147 | CHECK_TYPE_SIZE(__s8 __S8) | |
148 | CHECK_TYPE_SIZE(__s16 __S16) | |
149 | CHECK_TYPE_SIZE(__s32 __S32) | |
150 | CHECK_TYPE_SIZE(__s64 __S64) | |
151 | unset(CMAKE_EXTRA_INCLUDE_FILES) | |
152 | ||
153 | include(CheckSymbolExists) | |
154 | CHECK_SYMBOL_EXISTS(res_nquery "resolv.h" HAVE_RES_NQUERY) | |
155 | CHECK_SYMBOL_EXISTS(F_SETPIPE_SZ "linux/fcntl.h" CEPH_HAVE_SETPIPE_SZ) | |
156 | CHECK_SYMBOL_EXISTS(__func__ "" HAVE_FUNC) | |
157 | CHECK_SYMBOL_EXISTS(__PRETTY_FUNCTION__ "" HAVE_PRETTY_FUNC) | |
158 | ||
159 | include(CheckCXXSourceCompiles) | |
160 | CHECK_CXX_SOURCE_COMPILES(" | |
161 | #include <string.h> | |
162 | int main() { char x = *strerror_r(0, &x, sizeof(x)); return 0; } | |
163 | " STRERROR_R_CHAR_P) | |
164 | ||
165 | include(CheckStructHasMember) | |
166 | CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtim.tv_nsec sys/stat.h | |
167 | HAVE_STAT_ST_MTIM_TV_NSEC LANGUAGE C) | |
168 | CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec sys/stat.h | |
169 | HAVE_STAT_ST_MTIMESPEC_TV_NSEC LANGUAGE C) | |
170 | ||
171 | set(CEPH_MAN_DIR "share/man" CACHE STRING "Install location for man pages (relative to prefix).") | |
172 | ||
173 | option(ENABLE_SHARED "build shared libraries" ON) | |
174 | if(ENABLE_SHARED) | |
175 | set(CEPH_SHARED SHARED) | |
176 | else(ENABLE_SHARED) | |
177 | set(CEPH_SHARED STATIC) | |
178 | endif(ENABLE_SHARED) | |
179 | set(CMAKE_POSITION_INDEPENDENT_CODE ${ENABLE_SHARED}) | |
180 | ||
181 | option(WITH_RDMA "Enable RDMA in async messenger" ON) | |
182 | if(WITH_RDMA) | |
183 | find_package(rdma REQUIRED) | |
184 | set(HAVE_RDMA ${RDMA_FOUND}) | |
185 | endif(WITH_RDMA) | |
186 | ||
187 | find_package(Backtrace) | |
188 | ||
189 | if(LINUX) | |
190 | find_package(udev REQUIRED) | |
191 | set(HAVE_UDEV ${UDEV_FOUND}) | |
192 | ||
193 | find_package(aio REQUIRED) | |
194 | set(HAVE_LIBAIO ${AIO_FOUND}) | |
195 | ||
196 | find_package(blkid REQUIRED) | |
197 | set(HAVE_BLKID ${BLKID_FOUND}) | |
198 | else() | |
199 | set(HAVE_UDEV OFF) | |
200 | message(STATUS "Not using udev") | |
201 | set(HAVE_LIBAIO OFF) | |
202 | message(STATUS "Not using AIO") | |
203 | set(HAVE_BLKID OFF) | |
204 | message(STATUS "Not using BLKID") | |
205 | endif(LINUX) | |
206 | ||
207 | option(WITH_OPENLDAP "OPENLDAP is here" ON) | |
208 | if(${WITH_OPENLDAP}) | |
209 | find_package(OpenLdap REQUIRED) | |
210 | set(HAVE_OPENLDAP ${OPENLDAP_FOUND}) | |
211 | endif(${WITH_OPENLDAP}) | |
212 | ||
213 | option(WITH_FUSE "Fuse is here" ON) | |
214 | if(${WITH_FUSE}) | |
215 | find_package(fuse) | |
216 | set(HAVE_LIBFUSE ${FUSE_FOUND}) | |
217 | endif(${WITH_FUSE}) | |
218 | ||
219 | option(WITH_XFS "XFS is here" ON) | |
224ce89b WB |
220 | if(WITH_XFS) |
221 | find_package(xfs) | |
222 | set(HAVE_LIBXFS ${XFS_FOUND}) | |
223 | endif() | |
224 | ||
225 | option(WITH_ZFS "enable LibZFS if found" OFF) | |
226 | if(WITH_ZFS) | |
227 | find_package(zfs) | |
228 | set(HAVE_LIBZFS ${ZFS_FOUND}) | |
229 | endif() | |
7c673cae FG |
230 | |
231 | option(WITH_SPDK "Enable SPDK" OFF) | |
232 | if(WITH_SPDK) | |
233 | find_package(dpdk REQUIRED) | |
234 | set(HAVE_SPDK TRUE) | |
235 | endif(WITH_SPDK) | |
236 | ||
31f18b77 FG |
237 | option(WITH_PMEM "Enable PMEM" OFF) |
238 | if(WITH_PMEM) | |
239 | find_package(pmem REQUIRED) | |
240 | set(HAVE_PMEM ${PMEM_FOUND}) | |
241 | endif(WITH_PMEM) | |
242 | ||
7c673cae FG |
243 | # needs mds and? XXX |
244 | option(WITH_LIBCEPHFS "libcephfs client library" ON) | |
245 | ||
246 | # key-value store | |
247 | option(WITH_KVS "Key value store is here" ON) | |
248 | ||
249 | # remote block storage | |
250 | option(WITH_RBD "Remote block storage is here" ON) | |
251 | ||
252 | # KERNEL remote block storage | |
253 | option(WITH_KRBD "Kernel Remote block storage is here" ON) | |
254 | ||
255 | if(WITH_KRBD AND WITHOUT_RBD) | |
256 | message(FATAL_ERROR "Cannot have WITH_KRBD with WITH_RBD.") | |
257 | endif() | |
258 | ||
7c673cae FG |
259 | option(WITH_LEVELDB "LevelDB is here" ON) |
260 | if(WITH_LEVELDB) | |
261 | if(LEVELDB_PREFIX) | |
262 | include_directories(${LEVELDB_PREFIX}/include) | |
263 | link_directories(${LEVELDB_PREFIX}/lib) | |
264 | endif() | |
265 | find_package(leveldb REQUIRED) | |
266 | find_file(HAVE_LEVELDB_FILTER_POLICY leveldb/filter_policy.h PATHS ${LEVELDB_INCLUDE_DIR}) | |
267 | endif(WITH_LEVELDB) | |
268 | ||
7c673cae FG |
269 | find_package(snappy REQUIRED) |
270 | ||
31f18b77 FG |
271 | option(WITH_LZ4 "LZ4 compression support" OFF) |
272 | if(WITH_LZ4) | |
b5b8bbf5 | 273 | find_package(LZ4 1.7 REQUIRED) |
31f18b77 FG |
274 | set(HAVE_LZ4 ${LZ4_FOUND}) |
275 | endif(WITH_LZ4) | |
276 | ||
7c673cae FG |
277 | #if allocator is set on command line make sure it matches below strings |
278 | if(ALLOCATOR) | |
279 | if(${ALLOCATOR} MATCHES "tcmalloc(_minimal)?") | |
280 | find_package(gperftools REQUIRED) | |
281 | set(HAVE_LIBTCMALLOC ON) | |
282 | elseif(${ALLOCATOR} STREQUAL "jemalloc") | |
283 | find_package(JeMalloc REQUIRED) | |
284 | set(HAVE_LIBJEMALLOC ${JEMALLOC_FOUND}) | |
285 | set(HAVE_JEMALLOC 1) | |
286 | endif() | |
287 | else(ALLOCATOR) | |
288 | find_package(gperftools) | |
289 | set(HAVE_LIBTCMALLOC ${GPERFTOOLS_FOUND}) | |
290 | if(NOT GPERFTOOLS_FOUND) | |
291 | find_package(JeMalloc) | |
292 | set(HAVE_LIBJEMALLOC ${JEMALLOC_FOUND}) | |
293 | endif(NOT GPERFTOOLS_FOUND) | |
294 | if(GPERFTOOLS_FOUND) | |
295 | set(ALLOCATOR tcmalloc) | |
296 | elseif(JEMALLOC_FOUND) | |
297 | set(ALLOCATOR jemalloc) | |
298 | else() | |
299 | if(NOT FREEBSD) | |
300 | # FreeBSD already has jemalloc as its default allocator | |
301 | message(WARNING "tcmalloc and jemalloc not found, falling back to libc") | |
302 | endif() | |
303 | set(ALLOCATOR "libc") | |
304 | endif(GPERFTOOLS_FOUND) | |
305 | endif(ALLOCATOR) | |
306 | ||
307 | ||
308 | if(WITH_LIBCEPHFS OR WITH_KRBD) | |
309 | find_package(keyutils REQUIRED) | |
310 | endif() | |
311 | ||
312 | find_package(CURL REQUIRED) | |
313 | set(CMAKE_REQUIRED_INCLUDES ${CURL_INCLUDE_DIRS}) | |
314 | set(CMAKE_REQUIRED_LIBRARIES ${CURL_LIBRARIES}) | |
315 | CHECK_SYMBOL_EXISTS(curl_multi_wait curl/curl.h HAVE_CURL_MULTI_WAIT) | |
316 | ||
317 | # nss or cryptopp? | |
318 | option(WITH_NSS "Use NSS crypto and SSL implementations" ON) | |
319 | if (${WITH_NSS}) | |
320 | find_package(NSS REQUIRED) | |
321 | set(USE_NSS 1) | |
322 | find_package(NSPR REQUIRED) | |
323 | set(CRYPTO_LIBS ${NSS_LIBRARIES} ${NSPR_LIBRARIES}) | |
324 | else () | |
325 | find_package(cryptopp REQUIRED) | |
326 | set(CRYPTO_LIBS ${CRYPTOPP_LIBRARIES}) | |
327 | set(USE_CRYPTOPP 1) | |
328 | endif (${WITH_NSS}) | |
329 | ||
330 | option(WITH_SSL "SSL build selected" ON) | |
331 | if(USE_NSS) | |
332 | #nss | |
333 | set(SSL_LIBRARIES ${NSS_LIBRARIES}) | |
334 | message(STATUS "SSL with NSS selected (Libs: ${SSL_LIBRARIES})") | |
335 | else(USE_NSS) | |
336 | #openssl | |
337 | find_package(OpenSSL REQUIRED) | |
338 | set(USE_OPENSSL ON) | |
339 | set(SSL_LIBRARIES ${OPENSSL_LIBRARIES}) | |
340 | message(STATUS "SSL with OpenSSL selected (Libs: ${SSL_LIBRARIES})") | |
341 | endif(USE_NSS) | |
342 | ||
343 | option(WITH_XIO "Enable XIO messaging" OFF) | |
344 | if(WITH_XIO) | |
345 | find_package(xio REQUIRED) | |
346 | set(HAVE_XIO ${XIO_FOUND}) | |
347 | endif(WITH_XIO) | |
348 | ||
349 | option(WITH_DPDK "Enable DPDK messaging" OFF) | |
350 | if(WITH_DPDK) | |
351 | find_package(dpdk) | |
352 | set(HAVE_DPDK ${DPDK_FOUND}) | |
353 | endif(WITH_DPDK) | |
354 | ||
355 | option(WITH_BLKIN "Use blkin to emit LTTng tracepoints for Zipkin" OFF) | |
356 | if(WITH_BLKIN) | |
357 | set(BLKIN_LIBRARIES blkin lttng-ust) | |
358 | include_directories(src/blkin/blkin-lib) | |
359 | endif(WITH_BLKIN) | |
360 | ||
b32b8144 FG |
361 | option(WITH_BOOST_CONTEXT "Enable boost::asio stackful coroutines" ON) |
362 | if(WITH_BOOST_CONTEXT) | |
363 | set(HAVE_BOOST_CONTEXT ON) | |
364 | endif() | |
365 | ||
7c673cae FG |
366 | #option for RGW |
367 | option(WITH_RADOSGW "Rados Gateway is enabled" ON) | |
31f18b77 | 368 | option(WITH_RADOSGW_FCGI_FRONTEND "Rados Gateway's FCGI frontend is enabled" OFF) |
7c673cae FG |
369 | option(WITH_RADOSGW_BEAST_FRONTEND "Rados Gateway's Beast frontend is enabled" ON) |
370 | if(WITH_RADOSGW) | |
371 | find_package(EXPAT REQUIRED) | |
372 | if(WITH_RADOSGW_FCGI_FRONTEND) | |
373 | find_package(fcgi REQUIRED) | |
374 | endif() | |
b32b8144 FG |
375 | if(WITH_RADOSGW_BEAST_FRONTEND AND NOT WITH_BOOST_CONTEXT) |
376 | message(WARNING "disabling WITH_RADOSGW_BEAST_FRONTEND, which depends on WITH_BOOST_CONTEXT") | |
377 | set(WITH_RADOSGW_BEAST_FRONTEND OFF) | |
378 | endif() | |
7c673cae FG |
379 | endif(WITH_RADOSGW) |
380 | ||
381 | ||
382 | if (WITH_RADOSGW) | |
383 | if (NOT DEFINED OPENSSL_FOUND) | |
384 | message(STATUS "Looking for openssl anyways, because radosgw selected") | |
385 | find_package(OpenSSL) | |
386 | endif() | |
94b18763 FG |
387 | # https://curl.haxx.se/docs/install.html mentions the |
388 | # configure flags for various ssl backends | |
389 | execute_process( | |
390 | COMMAND | |
391 | "sh" "-c" | |
392 | "curl-config --configure | grep with-ssl" | |
393 | RESULT_VARIABLE NO_CURL_SSL_LINK | |
394 | ERROR_VARIABLE CURL_CONFIG_ERRORS | |
395 | ) | |
396 | if (CURL_CONFIG_ERRORS) | |
397 | message(WARNING "unable to run curl-config; rgw cannot make ssl requests to external systems reliably") | |
398 | endif() | |
399 | find_package(OpenSSL) | |
7c673cae | 400 | if (OPENSSL_FOUND) |
94b18763 FG |
401 | if (NOT NO_CURL_SSL_LINK) |
402 | message(STATUS "libcurl is linked with openssl: explicitly setting locks") | |
403 | set(WITH_CURL_OPENSSL ON) | |
404 | endif() # CURL_SSL_LINK | |
7c673cae FG |
405 | execute_process( |
406 | COMMAND | |
407 | "sh" "-c" | |
408 | "objdump -p ${OPENSSL_SSL_LIBRARY} | sed -n 's/^ SONAME *//p'" | |
409 | OUTPUT_VARIABLE LIBSSL_SONAME | |
410 | ERROR_VARIABLE OBJDUMP_ERRORS | |
411 | RESULT_VARIABLE OBJDUMP_RESULTS | |
412 | OUTPUT_STRIP_TRAILING_WHITESPACE) | |
413 | if (OBJDUMP_RESULTS) | |
414 | message(FATAL_ERROR "can't run objdump: ${OBJDUMP_RESULTS}") | |
415 | endif() | |
416 | if (NOT OBJDUMP_ERRORS STREQUAL "") | |
417 | message(WARNING "message from objdump: ${OBJDUMP_ERRORS}") | |
418 | endif() | |
419 | execute_process( | |
420 | COMMAND | |
421 | "sh" "-c" | |
422 | "objdump -p ${OPENSSL_CRYPTO_LIBRARY} | sed -n 's/^ SONAME *//p'" | |
423 | OUTPUT_VARIABLE LIBCRYPTO_SONAME | |
424 | ERROR_VARIABLE OBJDUMP_ERRORS | |
425 | RESULT_VARIABLE OBJDUMP_RESULTS | |
426 | OUTPUT_STRIP_TRAILING_WHITESPACE) | |
427 | if (OBJDUMP_RESULTS) | |
428 | message(FATAL_ERROR "can't run objdump: ${OBJDUMP_RESULTS}") | |
429 | endif() | |
430 | if (NOT OBJDUMP_ERRORS STREQUAL "") | |
431 | message(WARNING "message from objdump: ${OBJDUMP_ERRORS}") | |
432 | endif() | |
433 | message(STATUS "ssl soname: ${LIBSSL_SONAME}") | |
434 | message(STATUS "crypto soname: ${LIBCRYPTO_SONAME}") | |
435 | else() | |
436 | message(WARNING "ssl not found: rgw civetweb may fail to dlopen libssl libcrypto") | |
94b18763 | 437 | endif() # OPENSSL_FOUND |
7c673cae FG |
438 | endif (WITH_RADOSGW) |
439 | ||
440 | #option for CephFS | |
441 | option(WITH_CEPHFS "CephFS is enabled" ON) | |
442 | ||
443 | #option for Mgr | |
444 | option(WITH_MGR "ceph-mgr is enabled" ON) | |
445 | if(WITH_MGR) | |
446 | set(Python_ADDITIONAL_VERSIONS 2.7) | |
447 | find_package(PythonInterp 2.7 REQUIRED) | |
448 | find_package(PythonLibs 2.7 REQUIRED) | |
449 | # Boost dependency check deferred to Boost section | |
450 | endif(WITH_MGR) | |
451 | ||
452 | option(WITH_THREAD_SAFE_RES_QUERY "res_query is thread safe" OFF) | |
453 | if(WITH_THREAD_SAFE_RES_QUERY) | |
454 | set(HAVE_THREAD_SAFE_RES_QUERY 1 CACHE INTERNAL "Thread safe res_query supported.") | |
455 | endif(WITH_THREAD_SAFE_RES_QUERY) | |
456 | ||
457 | option(WITH_REENTRANT_STRSIGNAL "strsignal is reentrant" OFF) | |
458 | if(WITH_REENTRANT_STRSIGNAL) | |
459 | set(HAVE_REENTRANT_STRSIGNAL 1 CACHE INTERNAL "Reentrant strsignal is supported.") | |
460 | endif(WITH_REENTRANT_STRSIGNAL) | |
461 | ||
462 | set(HAVE_LIBROCKSDB 1) | |
463 | ||
464 | # -lz link into kv | |
465 | find_package(ZLIB REQUIRED) | |
466 | ||
467 | #option for EventTrace | |
468 | option(WITH_EVENTTRACE "Event tracing support" OFF) | |
469 | ||
470 | #option for LTTng | |
471 | option(WITH_LTTNG "LTTng tracing is enabled" ON) | |
472 | if(${WITH_LTTNG}) | |
473 | find_package(LTTngUST REQUIRED) | |
474 | find_program(LTTNG_GEN_TP | |
475 | lttng-gen-tp) | |
476 | if(NOT LTTNG_GEN_TP) | |
477 | message(FATAL_ERROR "Can't find lttng-gen-tp.") | |
478 | endif() | |
479 | endif(${WITH_LTTNG}) | |
480 | ||
31f18b77 FG |
481 | option(WITH_OSD_INSTRUMENT_FUNCTIONS OFF) |
482 | ||
7c673cae | 483 | #option for Babeltrace |
224ce89b WB |
484 | option(WITH_BABELTRACE "Babeltrace libraries are enabled" ON) |
485 | if(WITH_BABELTRACE) | |
486 | set(HAVE_BABELTRACE ON) | |
7c673cae | 487 | find_package(babeltrace REQUIRED) |
7c673cae FG |
488 | set(HAVE_BABELTRACE_BABELTRACE_H ${BABELTRACE_FOUND}) |
489 | set(HAVE_BABELTRACE_CTF_EVENTS_H ${BABELTRACE_FOUND}) | |
490 | set(HAVE_BABELTRACE_CTF_ITERATOR_H ${BABELTRACE_FOUND}) | |
224ce89b | 491 | endif(WITH_BABELTRACE) |
7c673cae FG |
492 | |
493 | option(DEBUG_GATHER "C_Gather debugging is enabled" ON) | |
7c673cae FG |
494 | option(ENABLE_COVERAGE "Coverage is enabled" OFF) |
495 | option(PG_DEBUG_REFS "PG Ref debugging is enabled" OFF) | |
496 | ||
497 | option(WITH_TESTS "enable the build of ceph-test package scripts/binaries" ON) | |
498 | ||
499 | option(WITH_FIO "Support for fio engines" OFF) | |
500 | if(WITH_FIO) | |
501 | find_package(fio REQUIRED) | |
502 | endif(WITH_FIO) | |
503 | ||
504 | if(LINUX) | |
505 | add_definitions(-D__linux__) | |
506 | endif(LINUX) | |
507 | ||
508 | # ASAN and friends | |
509 | option(WITH_ASAN "build with ASAN" OFF) | |
510 | option(WITH_ASAN_LEAK "explicitly enable ASAN leak detection" OFF) | |
511 | ||
512 | if(WITH_ASAN) | |
513 | set(ASAN_CFLAGS "-fsanitize=address -fno-omit-frame-pointer") | |
514 | if(WITH_ASAN_LEAK) | |
515 | set(ASAN_CFLAGS "${ASAN_CFLAGS} -fsanitize=leak") | |
516 | endif() | |
517 | set(ASAN_LFLAGS "${CMAKE_EXE_LINKER_FLAGS} ${ASAN_CFLAGS} -lasan") | |
518 | set(CMAKE_EXE_LINKER_FLAGS "${ASAN_LFLAGS}") | |
519 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ASAN_CFLAGS}") | |
520 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ASAN_CFLAGS}") | |
521 | if(HAVE_JEMALLOC) | |
522 | message(FATAL "ASAN does not work well with JeMalloc") | |
523 | endif() | |
524 | endif() | |
525 | ||
526 | option(WITH_TSAN "build with TSAN" OFF) | |
527 | if(WITH_TSAN) | |
528 | if (WITH_ASAN AND WITH_ASAN_LEAK) | |
529 | message(FATAL_ERROR "Cannot combine -fsanitize-leak w/-fsanitize-thread") | |
530 | endif() | |
531 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread -fno-omit-frame-pointer -pie -ltsan ") | |
532 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer -fPIC") | |
533 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread -fno-omit-frame-pointer -fPIC") | |
534 | if(HAVE_JEMALLOC) | |
535 | message(FATAL "TSAN does not work well with JeMalloc") | |
536 | endif() | |
537 | endif() | |
538 | ||
539 | option(WITH_UBSAN "build with UBSAN" OFF) | |
540 | if(WITH_UBSAN) | |
541 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined") | |
542 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined") | |
543 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined") | |
544 | if(HAVE_JEMALLOC) | |
545 | message(FATAL "UBSAN does not work well with JeMalloc") | |
546 | endif() | |
547 | endif() | |
548 | ||
549 | # Rocksdb | |
550 | option(WITH_SYSTEM_ROCKSDB "require and build with system rocksdb" OFF) | |
551 | if (WITH_SYSTEM_ROCKSDB) | |
552 | find_package(rocksdb REQUIRED) | |
553 | endif() | |
554 | ||
555 | # Boost | |
556 | option(WITH_SYSTEM_BOOST "require and build with system Boost" OFF) | |
557 | ||
31f18b77 | 558 | # Boost::thread depends on Boost::atomic, so list it explicitly. |
7c673cae | 559 | set(BOOST_COMPONENTS |
31f18b77 FG |
560 | atomic thread system regex random program_options date_time iostreams |
561 | filesystem) | |
562 | set(BOOST_HEADER_COMPONENTS container) | |
563 | ||
7c673cae FG |
564 | if(WITH_MGR) |
565 | list(APPEND BOOST_COMPONENTS python) | |
566 | endif() | |
b32b8144 FG |
567 | if(WITH_BOOST_CONTEXT) |
568 | list(APPEND BOOST_COMPONENTS context coroutine) | |
31f18b77 FG |
569 | endif() |
570 | ||
571 | set(Boost_USE_MULTITHREADED ON) | |
572 | # require minimally the bundled version | |
573 | if(WITH_SYSTEM_BOOST) | |
7c673cae FG |
574 | if(ENABLE_SHARED) |
575 | set(Boost_USE_STATIC_LIBS OFF) | |
576 | else() | |
577 | set(Boost_USE_STATIC_LIBS ON) | |
578 | endif() | |
b32b8144 | 579 | find_package(Boost 1.66 COMPONENTS ${BOOST_COMPONENTS} REQUIRED) |
7c673cae | 580 | else() |
7c673cae FG |
581 | set(BOOST_J 1 CACHE STRING |
582 | "max jobs for Boost build") # override w/-DBOOST_J=<n> | |
7c673cae | 583 | set(Boost_USE_STATIC_LIBS ON) |
31f18b77 | 584 | include(BuildBoost) |
b32b8144 | 585 | build_boost(1.66 |
31f18b77 FG |
586 | COMPONENTS ${BOOST_COMPONENTS} ${BOOST_HEADER_COMPONENTS}) |
587 | include_directories(BEFORE SYSTEM ${Boost_INCLUDE_DIRS}) | |
7c673cae | 588 | endif() |
7c673cae FG |
589 | set(Boost_USE_MULTITHREADED ON) |
590 | ||
7c673cae FG |
591 | include_directories(SYSTEM ${PROJECT_BINARY_DIR}/include) |
592 | ||
7c673cae FG |
593 | find_package(Threads REQUIRED) |
594 | ||
595 | option(WITH_SELINUX "build SELinux policy" OFF) | |
596 | if(WITH_SELINUX) | |
597 | find_file(SELINUX_MAKEFILE selinux/devel/Makefile | |
598 | PATH /usr/share) | |
599 | if(NOT SELINUX_MAKEFILE) | |
600 | message(FATAL_ERROR "Can't find selinux's Makefile") | |
601 | endif() | |
602 | add_subdirectory(selinux) | |
603 | endif(WITH_SELINUX) | |
604 | ||
605 | # enables testing and creates Make check command | |
606 | add_custom_target(tests | |
607 | COMMENT "Building tests") | |
608 | enable_testing() | |
609 | set(CMAKE_CTEST_COMMAND ctest) | |
610 | add_custom_target(check | |
611 | COMMAND ${CMAKE_CTEST_COMMAND} | |
612 | DEPENDS tests) | |
613 | ||
614 | add_subdirectory(src) | |
615 | ||
616 | add_subdirectory(doc) | |
617 | if(WITH_MANPAGE) | |
618 | add_subdirectory(man) | |
619 | endif(WITH_MANPAGE) | |
620 | ||
621 | option(WITH_SYSTEMD "install systemd target and service files" OFF) | |
622 | if(WITH_SYSTEMD) | |
623 | add_subdirectory(systemd) | |
624 | endif() | |
625 | ||
b32b8144 FG |
626 | if(LINUX) |
627 | add_subdirectory(etc/sysctl) | |
628 | endif() | |
629 | ||
7c673cae FG |
630 | include(CTags) |
631 | option(CTAG_EXCLUDES "Exclude files/directories when running ctag.") | |
632 | add_tags(ctags | |
633 | SRC_DIR src | |
634 | TAG_FILE tags | |
635 | EXCLUDE_OPTS ${CTAG_EXCLUDES} | |
31f18b77 | 636 | EXCLUDES "*.js" "*.css") |
7c673cae | 637 | add_custom_target(tags DEPENDS ctags) |