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