]> git.proxmox.com Git - ceph.git/blob - ceph/CMakeLists.txt
91f4923c5791f2858e2a31f8fdf7ea8d0872b5a2
[ceph.git] / ceph / CMakeLists.txt
1 cmake_minimum_required(VERSION 3.16)
2
3 project(ceph
4 VERSION 18.2.0
5 LANGUAGES CXX C ASM)
6
7 cmake_policy(SET CMP0028 NEW)
8 cmake_policy(SET CMP0046 NEW)
9 cmake_policy(SET CMP0048 NEW)
10 cmake_policy(SET CMP0051 NEW)
11 cmake_policy(SET CMP0054 NEW)
12 cmake_policy(SET CMP0056 NEW)
13 cmake_policy(SET CMP0065 NEW)
14 cmake_policy(SET CMP0074 NEW)
15 cmake_policy(SET CMP0075 NEW)
16 cmake_policy(SET CMP0093 NEW)
17 foreach(policy CMP0127 CMP0135)
18 if(POLICY ${policy})
19 cmake_policy(SET ${policy} NEW)
20 endif()
21 endforeach()
22
23 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")
24
25 if(NOT CMAKE_BUILD_TYPE AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
26 set(default_build_type "Debug")
27 set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
28 STRING "Default BUILD_TYPE is Debug, other options are: RelWithDebInfo, Release, and MinSizeRel." FORCE)
29 endif()
30
31 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
32 set(LINUX ON)
33 FIND_PACKAGE(Threads)
34 elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
35 set(FREEBSD ON)
36 FIND_PACKAGE(Threads)
37 endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
38
39 if(WIN32)
40 # The Windows headers (e.g. coming from mingw or the Windows SDK) check
41 # the targeted Windows version. The availability of certain functions and
42 # structures will depend on it.
43 set(WIN32_WINNT "0x0A00" CACHE STRING "Targeted Windows version.")
44 # In order to avoid known winpthread issues, we're using the boost
45 # shared mutex implementation.
46 # https://github.com/msys2/MINGW-packages/issues/3319
47 add_definitions(
48 -D_WIN32_WINNT=${WIN32_WINNT}
49 -DBOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
50 -DBOOST_THREAD_V2_SHARED_MUTEX
51 )
52 set(Boost_THREADAPI "win32")
53 endif()
54
55 if(MINGW)
56 string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl,-allow-multiple-definition")
57 string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,-allow-multiple-definition")
58
59 # By default, cmake generates import libs for executables. The issue is that
60 # for rados and rbd, the executable import lib overrides the library import lib.
61 # For example, for rados.exe, it will end up generating a librados.dll.a import lib.
62 # We're providing custom rules to disable import libs for executables.
63 set(CMAKE_C_LINK_EXECUTABLE
64 "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>")
65 set(CMAKE_CXX_LINK_EXECUTABLE
66 "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>")
67
68 link_directories(${MINGW_LINK_DIRECTORIES})
69 endif()
70
71 option(WITH_CCACHE "Build with ccache.")
72 if(WITH_CCACHE)
73 if(CMAKE_C_COMPILER_LAUNCHER OR CMAKE_CXX_COMPILER_LAUNCHER)
74 message(WARNING "Compiler launcher already set. stop configuring ccache")
75 else()
76 find_program(CCACHE_EXECUTABLE ccache)
77 if(NOT CCACHE_EXECUTABLE)
78 message(FATAL_ERROR "Can't find ccache. Is it installed?")
79 endif()
80 message(STATUS "Building with ccache: ${CCACHE_EXECUTABLE}, CCACHE_DIR=$ENV{CCACHE_DIR}")
81 set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE})
82 set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE})
83 endif()
84 endif(WITH_CCACHE)
85
86 option(WITH_MANPAGE "Build man pages." ON)
87 if(WITH_MANPAGE)
88 find_program(SPHINX_BUILD
89 NAMES sphinx-build sphinx-build-3)
90 if(NOT SPHINX_BUILD)
91 message(FATAL_ERROR "Can't find sphinx-build.")
92 endif(NOT SPHINX_BUILD)
93 endif(WITH_MANPAGE)
94
95 include_directories(
96 ${PROJECT_BINARY_DIR}/src/include
97 ${PROJECT_SOURCE_DIR}/src)
98
99 if(WIN32)
100 include_directories(
101 ${PROJECT_SOURCE_DIR}/src/include/win32)
102 # Boost complains if winsock2.h (or windows.h) is included before asio.hpp.
103 add_compile_options("SHELL:-include winsock_wrapper.h")
104 # Boost is also defining some of the errno values, we'll have
105 # to avoid mismatches.
106 add_compile_options("SHELL:-include win32_errno.h")
107 endif()
108
109 if(FREEBSD)
110 include_directories(SYSTEM /usr/local/include)
111 link_directories(/usr/local/lib)
112 list(APPEND CMAKE_REQUIRED_INCLUDES /usr/local/include)
113 endif(FREEBSD)
114
115
116 #put all the libs and binaries in one place
117 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
118 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
119 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
120
121 include(GNUInstallDirs)
122 include(CephChecks)
123 if(CMAKE_GENERATOR MATCHES Ninja)
124 include(LimitJobs)
125 endif()
126
127 set(CEPH_MAN_DIR "share/man" CACHE STRING "Install location for man pages (relative to prefix).")
128
129 option(ENABLE_SHARED "build shared libraries" ON)
130 if(ENABLE_SHARED)
131 set(CEPH_SHARED SHARED)
132 else(ENABLE_SHARED)
133 set(CEPH_SHARED STATIC)
134 endif(ENABLE_SHARED)
135 set(CMAKE_POSITION_INDEPENDENT_CODE ${ENABLE_SHARED})
136
137 option(WITH_STATIC_LIBSTDCXX "Link against libstdc++ statically" OFF)
138 if(WITH_STATIC_LIBSTDCXX)
139 if(NOT CMAKE_COMPILER_IS_GNUCXX)
140 message(FATAL_ERROR "Please use GCC to enable WITH_STATIC_LIBSTDCXX")
141 endif()
142 set(static_linker_flags "-static-libstdc++ -static-libgcc")
143 string(APPEND CMAKE_SHARED_LINKER_FLAGS " ${static_linker_flags}")
144 string(APPEND CMAKE_EXE_LINKER_FLAGS " ${static_linker_flags}")
145 unset(static_linker_flags)
146 set(GPERFTOOLS_USE_STATIC_LIBS TRUE)
147 endif()
148 include(CheckCxxAtomic)
149 if(NOT HAVE_CXX11_ATOMIC)
150 string(APPEND CMAKE_CXX_STANDARD_LIBRARIES
151 " ${LIBATOMIC_LINK_FLAGS}")
152 endif()
153
154 option(WITH_RDMA "Enable RDMA in async messenger" ON)
155 if(WITH_RDMA)
156 find_package(verbs REQUIRED)
157 set(HAVE_VERBS ${VERBS_FOUND})
158 find_package(rdmacm REQUIRED)
159 set(HAVE_RDMACM ${RDMACM_FOUND})
160 set(HAVE_RDMA TRUE)
161 endif()
162
163 find_package(Backtrace)
164
165 option(WITH_RBD "Enable RADOS Block Device related targets" ON)
166
167 if(LINUX)
168 find_package(udev REQUIRED)
169 set(HAVE_UDEV ${UDEV_FOUND})
170 find_package(blkid REQUIRED)
171 set(HAVE_BLKID ${BLKID_FOUND})
172 find_package(keyutils REQUIRED)
173 set(HAVE_KEYUTILS ${KEYUTILS_FOUND})
174 elseif(FREEBSD)
175 set(HAVE_UDEV OFF)
176 set(HAVE_LIBAIO OFF)
177 set(HAVE_LIBDML OFF)
178 set(HAVE_BLKID OFF)
179 set(HAVE_KEYUTILS OFF)
180 else()
181 set(HAVE_UDEV OFF)
182 set(HAVE_BLKID OFF)
183 endif(LINUX)
184
185 option(WITH_OPENLDAP "OPENLDAP is here" ON)
186 if(WITH_OPENLDAP)
187 find_package(OpenLDAP REQUIRED)
188 set(HAVE_OPENLDAP ${OpenLDAP_FOUND})
189 endif()
190
191 option(WITH_GSSAPI "GSSAPI/KRB5 is here" OFF)
192 if(WITH_GSSAPI)
193 find_package(GSSApi REQUIRED)
194 set(HAVE_GSSAPI ${GSSApi_FOUND})
195 endif()
196
197 option(WITH_FUSE "Fuse is here" ON)
198 if(WITH_FUSE)
199 find_package(FUSE REQUIRED)
200 set(HAVE_LIBFUSE ${FUSE_FOUND})
201 endif()
202
203 option(WITH_DOKAN "Dokan is here" OFF)
204
205 option(WITH_XFS "XFS is here" ON)
206 if(WITH_XFS)
207 find_package(xfs)
208 set(HAVE_LIBXFS ${XFS_FOUND})
209 endif()
210
211 option(WITH_ZFS "enable LibZFS if found" OFF)
212 if(WITH_ZFS)
213 find_package(zfs)
214 set(HAVE_LIBZFS ${ZFS_FOUND})
215 endif()
216
217 option(WITH_BLUESTORE "Bluestore OSD backend" ON)
218 if(WITH_BLUESTORE)
219 if(LINUX)
220 find_package(aio)
221 set(HAVE_LIBAIO ${AIO_FOUND})
222 elseif(FREEBSD)
223 # POSIX AIO is integrated into FreeBSD kernel, and exposed by libc.
224 set(HAVE_POSIXAIO ON)
225 endif()
226 endif()
227
228 # libcryptsetup is only available on linux
229 if(WITH_RBD AND LINUX)
230 find_package(libcryptsetup 2.0.5 REQUIRED)
231 set(HAVE_LIBCRYPTSETUP ${LIBCRYPTSETUP_FOUND})
232 endif()
233
234 include(CMakeDependentOption)
235
236 CMAKE_DEPENDENT_OPTION(WITH_ZBD "Enable libzbd bluestore backend" OFF
237 "WITH_BLUESTORE" OFF)
238 if(WITH_ZBD)
239 find_package(zbd REQUIRED)
240 set(HAVE_LIBZBD ${ZBD_FOUND})
241 endif()
242
243 CMAKE_DEPENDENT_OPTION(WITH_LIBURING "Enable io_uring bluestore backend" ON
244 "WITH_BLUESTORE;HAVE_LIBAIO" OFF)
245 set(HAVE_LIBURING ${WITH_LIBURING})
246
247 CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_LIBURING "Require and build with system liburing" OFF
248 "HAVE_LIBAIO;WITH_BLUESTORE" OFF)
249
250 CMAKE_DEPENDENT_OPTION(WITH_BLUESTORE_PMEM "Enable PMDK libraries" OFF
251 "WITH_BLUESTORE" OFF)
252 if(WITH_BLUESTORE_PMEM)
253 find_package(dml)
254 set(HAVE_LIBDML ${DML_FOUND})
255 endif()
256
257 CMAKE_DEPENDENT_OPTION(WITH_RBD_MIRROR "Enable build for rbd-mirror daemon executable" OFF
258 "WITH_RBD" OFF)
259
260 CMAKE_DEPENDENT_OPTION(WITH_RBD_MIGRATION_FORMAT_QCOW_V1
261 "Enable librbd QCOW v1 migration format support" ON
262 "WITH_RBD" OFF)
263
264 CMAKE_DEPENDENT_OPTION(WITH_RBD_RWL "Enable librbd persistent write back cache" OFF
265 "WITH_RBD" OFF)
266
267 CMAKE_DEPENDENT_OPTION(WITH_RBD_SSD_CACHE "Enable librbd persistent write back cache for SSDs" OFF
268 "WITH_RBD" OFF)
269
270 CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_PMDK "Require and build with system PMDK" OFF
271 "WITH_RBD_RWL OR WITH_BLUESTORE_PMEM" OFF)
272
273 if(WITH_BLUESTORE_PMEM)
274 set(HAVE_BLUESTORE_PMEM ON)
275 endif()
276
277 CMAKE_DEPENDENT_OPTION(WITH_SPDK "Enable SPDK" OFF
278 "CMAKE_SYSTEM_PROCESSOR MATCHES i386|i686|amd64|x86_64|AMD64|aarch64" OFF)
279 if(WITH_SPDK)
280 if(NOT WITH_BLUESTORE)
281 message(SEND_ERROR "Please enable WITH_BLUESTORE for using SPDK")
282 endif()
283 include(BuildSPDK)
284 build_spdk()
285 set(HAVE_SPDK TRUE)
286 endif(WITH_SPDK)
287
288 if(WITH_BLUESTORE)
289 if(NOT AIO_FOUND AND NOT HAVE_POSIXAIO AND NOT WITH_SPDK AND NOT WITH_BLUESTORE_PMEM)
290 message(SEND_ERROR "WITH_BLUESTORE is ON, "
291 "but none of the bluestore backends is enabled. "
292 "Please install libaio, or enable WITH_SPDK or WITH_BLUESTORE_PMEM (experimental)")
293 endif()
294 endif()
295
296 option(WITH_BLUEFS "libbluefs library" OFF)
297
298 option(WITH_QAT "Enable Qat driver" OFF)
299 if(WITH_QAT)
300 find_package(QatDrv REQUIRED COMPONENTS qat_s usdm_drv_s)
301 set(HAVE_QATDRV $(QatDrv_FOUND))
302 endif()
303
304 option(WITH_QATZIP "Enable QATZIP" OFF)
305 if(WITH_QATZIP)
306 find_package(qatzip REQUIRED)
307 set(HAVE_QATZIP ${qatzip_FOUND})
308 endif(WITH_QATZIP)
309
310 # needs mds and? XXX
311 option(WITH_LIBCEPHFS "libcephfs client library" ON)
312
313 option(WITH_LIBCEPHSQLITE "libcephsqlite client library" ON)
314 if(WITH_LIBCEPHSQLITE)
315 find_package(SQLite3 REQUIRED)
316 endif()
317
318 # key-value store
319 option(WITH_KVS "Key value store is here" OFF)
320
321 option(WITH_KRBD "Enable Linux krbd support of 'rbd' utility" ON)
322
323 if(WITH_KRBD AND NOT WITH_RBD)
324 message(FATAL_ERROR "Cannot have WITH_KRBD without WITH_RBD.")
325 endif()
326 if(LINUX)
327 if(WITH_LIBCEPHFS OR WITH_KRBD)
328 # keyutils is only used when talking to the Linux Kernel key store
329 find_package(keyutils REQUIRED)
330 set(HAVE_KEYUTILS ${KEYUTILS_FOUND})
331 endif()
332 endif()
333
334 find_package(snappy REQUIRED)
335
336 option(WITH_BROTLI "Brotli compression support" OFF)
337 if(WITH_BROTLI)
338 set(HAVE_BROTLI TRUE)
339 endif()
340
341 option(WITH_LZ4 "LZ4 compression support" ON)
342 if(WITH_LZ4)
343 find_package(LZ4 1.7 REQUIRED)
344 set(HAVE_LZ4 ${LZ4_FOUND})
345 endif(WITH_LZ4)
346
347 CMAKE_DEPENDENT_OPTION(WITH_CEPH_DEBUG_MUTEX "Use debug ceph::mutex with lockdep" ON
348 "CMAKE_BUILD_TYPE STREQUAL Debug" OFF)
349
350 #if allocator is set on command line make sure it matches below strings
351 set(ALLOCATOR "" CACHE STRING
352 "specify memory allocator to use. currently tcmalloc, tcmalloc_minimal, \
353 jemalloc, and libc is supported. if not specified, will try to find tcmalloc, \
354 and then jemalloc. If neither of then is found. use the one in libc.")
355 if(ALLOCATOR)
356 if(${ALLOCATOR} MATCHES "tcmalloc(_minimal)?")
357 find_package(gperftools 2.6.2 REQUIRED)
358 set(ALLOC_LIBS gperftools::${ALLOCATOR})
359 set(HAVE_LIBTCMALLOC ON)
360 elseif(${ALLOCATOR} STREQUAL "jemalloc")
361 find_package(JeMalloc REQUIRED)
362 set(ALLOC_LIBS JeMalloc::JeMalloc)
363 set(HAVE_JEMALLOC 1)
364 elseif(NOT ALLOCATOR STREQUAL "libc")
365 message(FATAL_ERROR "Unsupported allocator selected: ${ALLOCATOR}")
366 endif()
367 else(ALLOCATOR)
368 find_package(gperftools 2.6.2)
369 set(HAVE_LIBTCMALLOC ${gperftools_FOUND})
370 if(NOT gperftools_FOUND)
371 find_package(JeMalloc)
372 endif()
373 if(gperftools_FOUND)
374 set(ALLOCATOR tcmalloc)
375 set(ALLOC_LIBS gperftools::tcmalloc)
376 elseif(JeMalloc_FOUND)
377 set(ALLOCATOR jemalloc)
378 set(ALLOC_LIBS JeMalloc::JeMalloc)
379 else()
380 if(NOT FREEBSD)
381 # FreeBSD already has jemalloc as its default allocator
382 message(WARNING "tcmalloc and jemalloc not found, falling back to libc")
383 endif()
384 set(ALLOCATOR "libc")
385 endif(gperftools_FOUND)
386 endif(ALLOCATOR)
387 if(NOT ALLOCATOR STREQUAL "libc")
388 add_compile_options(
389 $<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-malloc>
390 $<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-calloc>
391 $<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-realloc>
392 $<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-free>)
393 endif()
394
395 # Mingw generates incorrect entry points when using "-pie".
396 if(WIN32 OR (HAVE_LIBTCMALLOC AND WITH_STATIC_LIBSTDCXX))
397 set(EXE_LINKER_USE_PIE FALSE)
398 else()
399 set(EXE_LINKER_USE_PIE ${ENABLE_SHARED})
400 endif()
401
402 if(NOT WIN32)
403 # require libcurl with good curl_multi_wait(), see https://tracker.ceph.com/issues/15915
404 find_package(CURL 7.32 REQUIRED)
405 endif()
406
407 find_package(OpenSSL REQUIRED)
408 set(CRYPTO_LIBS OpenSSL::Crypto)
409
410 option(WITH_DPDK "Enable DPDK messaging" OFF)
411 if(WITH_DPDK)
412 find_package(dpdk)
413 if(NOT DPDK_FOUND)
414 include(BuildDPDK)
415 build_dpdk(${CMAKE_BINARY_DIR}/src/dpdk)
416 endif()
417 set(HAVE_DPDK TRUE)
418 endif()
419
420 option(WITH_BLKIN "Use blkin to emit LTTng tracepoints for Zipkin" OFF)
421 if(WITH_BLKIN)
422 find_package(LTTngUST REQUIRED)
423 set(BLKIN_LIBRARIES blkin ${LTTNGUST_LIBRARIES} lttng-ust-fork)
424 include_directories(SYSTEM src/blkin/blkin-lib)
425 endif(WITH_BLKIN)
426
427 option(WITH_JAEGER "Enable jaegertracing and it's dependent libraries" ON)
428 if(WITH_JAEGER)
429 set(HAVE_JAEGER TRUE)
430 endif()
431
432 #option for RGW
433 option(WITH_RADOSGW "Rados Gateway is enabled" ON)
434 option(WITH_RADOSGW_BEAST_OPENSSL "Rados Gateway's Beast frontend uses OpenSSL" ON)
435 option(WITH_RADOSGW_AMQP_ENDPOINT "Rados Gateway's pubsub support for AMQP push endpoint" ON)
436 option(WITH_RADOSGW_KAFKA_ENDPOINT "Rados Gateway's pubsub support for Kafka push endpoint" ON)
437 option(WITH_RADOSGW_LUA_PACKAGES "Rados Gateway's support for dynamically adding lua packagess" ON)
438 option(WITH_RADOSGW_DBSTORE "DBStore backend for Rados Gateway" ON)
439 option(WITH_RADOSGW_MOTR "CORTX-Motr backend for Rados Gateway" OFF)
440 option(WITH_RADOSGW_DAOS "DAOS backend for RADOS Gateway" OFF)
441 option(WITH_RADOSGW_SELECT_PARQUET "Support for s3 select on parquet objects" ON)
442 option(WITH_RADOSGW_ARROW_FLIGHT "Build arrow flight when not using system-provided arrow" OFF)
443 option(WITH_RADOSGW_BACKTRACE_LOGGING "Enable backtraces in rgw logs" OFF)
444
445 option(WITH_SYSTEM_ARROW "Use system-provided arrow" OFF)
446 option(WITH_SYSTEM_UTF8PROC "Use system-provided utf8proc" OFF)
447
448 if(WITH_RADOSGW)
449 find_package(EXPAT REQUIRED)
450 find_package(OATH REQUIRED)
451
452 # https://curl.haxx.se/docs/install.html mentions the
453 # configure flags for various ssl backends
454 execute_process(
455 COMMAND
456 "sh" "-c"
457 "curl-config --configure | grep with-ssl"
458 RESULT_VARIABLE NO_CURL_SSL_LINK
459 ERROR_VARIABLE CURL_CONFIG_ERRORS
460 )
461 if (CURL_CONFIG_ERRORS)
462 message(WARNING "unable to run curl-config; rgw cannot make ssl requests to external systems reliably")
463 endif()
464
465 if (NOT NO_CURL_SSL_LINK)
466 message(STATUS "libcurl is linked with openssl: explicitly setting locks")
467 set(WITH_CURL_OPENSSL ON)
468 endif() # CURL_SSL_LINK
469 execute_process(
470 COMMAND
471 "sh" "-c"
472 "objdump -p ${OPENSSL_SSL_LIBRARY} | sed -n 's/^ SONAME *//p'"
473 OUTPUT_VARIABLE LIBSSL_SONAME
474 ERROR_VARIABLE OBJDUMP_ERRORS
475 RESULT_VARIABLE OBJDUMP_RESULTS
476 OUTPUT_STRIP_TRAILING_WHITESPACE)
477 if (OBJDUMP_RESULTS)
478 message(FATAL_ERROR "can't run objdump: ${OBJDUMP_RESULTS}")
479 endif()
480 if (NOT OBJDUMP_ERRORS STREQUAL "")
481 message(WARNING "message from objdump: ${OBJDUMP_ERRORS}")
482 endif()
483 execute_process(
484 COMMAND
485 "sh" "-c"
486 "objdump -p ${OPENSSL_CRYPTO_LIBRARY} | sed -n 's/^ SONAME *//p'"
487 OUTPUT_VARIABLE LIBCRYPTO_SONAME
488 ERROR_VARIABLE OBJDUMP_ERRORS
489 RESULT_VARIABLE OBJDUMP_RESULTS
490 OUTPUT_STRIP_TRAILING_WHITESPACE)
491 if (OBJDUMP_RESULTS)
492 message(FATAL_ERROR "can't run objdump: ${OBJDUMP_RESULTS}")
493 endif()
494 if (NOT OBJDUMP_ERRORS STREQUAL "")
495 message(WARNING "message from objdump: ${OBJDUMP_ERRORS}")
496 endif()
497 message(STATUS "ssl soname: ${LIBSSL_SONAME}")
498 message(STATUS "crypto soname: ${LIBCRYPTO_SONAME}")
499 endif (WITH_RADOSGW)
500
501 #option for CephFS
502 option(WITH_CEPHFS "CephFS is enabled" ON)
503
504 if(NOT WIN32)
505 # Please specify 3.[0-7] if you want to build with a certain version of python3.
506 set(WITH_PYTHON3 "3" CACHE STRING "build with specified python3 version")
507 find_package(Python3 ${WITH_PYTHON3} EXACT REQUIRED
508 COMPONENTS Interpreter Development)
509
510 option(WITH_MGR "ceph-mgr is enabled" ON)
511 if(WITH_MGR)
512 set(MGR_PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
513 set(MGR_PYTHON_LIBRARIES ${Python3_LIBRARIES})
514 set(MGR_PYTHON_VERSION_MAJOR ${Python3_VERSION_MAJOR})
515 set(MGR_PYTHON_VERSION_MINOR ${Python3_VERSION_MINOR})
516 # Boost dependency check deferred to Boost section
517 endif(WITH_MGR)
518 endif(NOT WIN32)
519
520 option(WITH_THREAD_SAFE_RES_QUERY "res_query is thread safe" OFF)
521 if(WITH_THREAD_SAFE_RES_QUERY)
522 set(HAVE_THREAD_SAFE_RES_QUERY 1 CACHE INTERNAL "Thread safe res_query supported.")
523 endif()
524
525 option(WITH_REENTRANT_STRSIGNAL "strsignal is reentrant" OFF)
526 if(WITH_REENTRANT_STRSIGNAL)
527 set(HAVE_REENTRANT_STRSIGNAL 1 CACHE INTERNAL "Reentrant strsignal is supported.")
528 endif()
529
530 # -lz link into kv
531 find_package(ZLIB REQUIRED)
532
533 #option for EventTrace
534 CMAKE_DEPENDENT_OPTION(
535 WITH_EVENTTRACE "Event tracing support, requires WITH_LTTNG"
536 OFF "USE_LTTNG" OFF)
537
538 #option for LTTng
539 option(WITH_LTTNG "LTTng tracing is enabled" ON)
540 if(${WITH_LTTNG})
541 find_package(LTTngUST REQUIRED)
542 find_program(LTTNG_GEN_TP
543 lttng-gen-tp)
544 if(NOT LTTNG_GEN_TP)
545 message(FATAL_ERROR "Can't find lttng-gen-tp.")
546 endif()
547 endif(${WITH_LTTNG})
548
549 option(WITH_OSD_INSTRUMENT_FUNCTIONS OFF)
550
551 #option for Babeltrace
552 option(WITH_BABELTRACE "Babeltrace libraries are enabled" ON)
553 if(WITH_BABELTRACE)
554 set(HAVE_BABELTRACE ON)
555 find_package(babeltrace REQUIRED)
556 set(HAVE_BABELTRACE_BABELTRACE_H ${BABELTRACE_FOUND})
557 set(HAVE_BABELTRACE_CTF_EVENTS_H ${BABELTRACE_FOUND})
558 set(HAVE_BABELTRACE_CTF_ITERATOR_H ${BABELTRACE_FOUND})
559 endif(WITH_BABELTRACE)
560
561 option(DEBUG_GATHER "C_Gather debugging is enabled" ON)
562 option(ENABLE_COVERAGE "Coverage is enabled" OFF)
563 option(PG_DEBUG_REFS "PG Ref debugging is enabled" OFF)
564
565 option(WITH_TESTS "enable the build of ceph-test package scripts/binaries" ON)
566 set(UNIT_TESTS_BUILT ${WITH_TESTS})
567 set(CEPH_TEST_TIMEOUT 3600 CACHE STRING
568 "Maximum time before a CTest gets killed" )
569
570 # fio
571 option(WITH_FIO "build with fio plugin enabled" OFF)
572 if(WITH_FIO)
573 include(BuildFIO)
574 build_fio()
575 endif()
576
577 if(LINUX)
578 add_definitions(-D__linux__)
579 endif(LINUX)
580
581 # ASAN and friends
582 option(WITH_ASAN "build with ASAN" OFF)
583 if(WITH_ASAN)
584 list(APPEND sanitizers "address")
585 endif()
586
587 option(WITH_ASAN_LEAK "explicitly enable ASAN leak detection" OFF)
588 if(WITH_ASAN_LEAK)
589 list(APPEND sanitizers "leak")
590 endif()
591
592 option(WITH_TSAN "build with TSAN" OFF)
593 if(WITH_TSAN)
594 list(APPEND sanitizers "thread")
595 endif()
596
597 option(WITH_UBSAN "build with UBSAN" OFF)
598 if(WITH_UBSAN)
599 list(APPEND sanitizers "undefined_behavior")
600 endif()
601
602 if(sanitizers)
603 find_package(Sanitizers REQUIRED ${sanitizers})
604 add_compile_options(${Sanitizers_COMPILE_OPTIONS})
605 string(REPLACE ";" " " sanitiers_compile_flags "${Sanitizers_COMPILE_OPTIONS}")
606 string(APPEND CMAKE_EXE_LINKER_FLAGS " ${sanitiers_compile_flags}")
607 string(APPEND CMAKE_SHARED_LINKER_FLAGS " ${sanitiers_compile_flags}")
608 endif()
609
610 # Rocksdb
611 option(WITH_SYSTEM_ROCKSDB "require and build with system rocksdb" OFF)
612 if (WITH_SYSTEM_ROCKSDB)
613 find_package(RocksDB 5.14 REQUIRED)
614 endif()
615
616 option(WITH_SEASTAR "Build seastar components")
617 set(HAVE_SEASTAR ${WITH_SEASTAR})
618
619 # Boost
620 option(WITH_SYSTEM_BOOST "require and build with system Boost" OFF)
621
622 # Boost::thread depends on Boost::atomic, so list it explicitly.
623 set(BOOST_COMPONENTS
624 atomic chrono thread system regex random program_options date_time
625 iostreams context coroutine)
626 set(BOOST_HEADER_COMPONENTS container)
627
628 if(WITH_MGR)
629 list(APPEND BOOST_COMPONENTS
630 python${MGR_PYTHON_VERSION_MAJOR}${MGR_PYTHON_VERSION_MINOR})
631 endif()
632 if(WITH_SEASTAR)
633 list(APPEND BOOST_COMPONENTS timer)
634 endif()
635
636 if(WITH_RADOSGW AND WITH_RADOSGW_LUA_PACKAGES)
637 list(APPEND BOOST_COMPONENTS filesystem)
638 endif()
639
640 set(Boost_USE_MULTITHREADED ON)
641
642 CMAKE_DEPENDENT_OPTION(WITH_BOOST_VALGRIND "Boost support for valgrind" OFF
643 "NOT WITH_SYSTEM_BOOST" OFF)
644 # require minimally the bundled version
645 if(WITH_SYSTEM_BOOST)
646 if(ENABLE_SHARED)
647 set(Boost_USE_STATIC_LIBS OFF)
648 else()
649 set(Boost_USE_STATIC_LIBS ON)
650 endif()
651 if(BOOST_ROOT AND CMAKE_LIBRARY_ARCHITECTURE)
652 set(BOOST_LIBRARYDIR "${BOOST_ROOT}/lib/${CMAKE_LIBRARY_ARCHITECTURE}")
653 endif()
654 find_package(Boost 1.79 COMPONENTS ${BOOST_COMPONENTS} REQUIRED)
655 if(NOT ENABLE_SHARED)
656 set_property(TARGET Boost::iostreams APPEND PROPERTY
657 INTERFACE_LINK_LIBRARIES ZLIB::ZLIB)
658 endif()
659 else()
660 include(ProcessorCount)
661 ProcessorCount(DEFAULT_BOOST_J)
662 if(DEFAULT_BOOST_J EQUAL 0)
663 set(DEFAULT_BOOST_J 1)
664 endif()
665 set(BOOST_J ${DEFAULT_BOOST_J} CACHE STRING "max jobs for Boost build") # override w/-DBOOST_J=<n>
666 set(Boost_USE_STATIC_LIBS ON)
667 include(BuildBoost)
668 build_boost(1.79
669 COMPONENTS ${BOOST_COMPONENTS} ${BOOST_HEADER_COMPONENTS})
670 endif()
671 include_directories(BEFORE SYSTEM ${Boost_INCLUDE_DIRS})
672
673 # dashboard angular2 frontend
674 option(WITH_MGR_DASHBOARD_FRONTEND "Build the mgr/dashboard frontend using `npm`" ON)
675 option(WITH_SYSTEM_NPM "Assume that dashboard build tools already installed through packages" OFF)
676 if(WITH_SYSTEM_NPM)
677 find_program(NPM_EXECUTABLE npm)
678 if(NOT NPM_EXECUTABLE)
679 message(FATAL_ERROR "Can't find npm.")
680 endif()
681 endif()
682 set(DASHBOARD_FRONTEND_LANGS "" CACHE STRING
683 "List of comma separated ceph-dashboard frontend languages to build. \
684 Use value `ALL` to build all languages")
685 CMAKE_DEPENDENT_OPTION(WITH_MGR_ROOK_CLIENT "Enable the mgr's Rook support" ON
686 "WITH_MGR" OFF)
687
688 include_directories(SYSTEM ${PROJECT_BINARY_DIR}/include)
689
690 find_package(Threads REQUIRED)
691 find_package(StdFilesystem REQUIRED)
692
693 option(WITH_SELINUX "build SELinux policy" OFF)
694 if(WITH_SELINUX)
695 find_file(SELINUX_MAKEFILE selinux/devel/Makefile
696 PATH /usr/share)
697 if(NOT SELINUX_MAKEFILE)
698 message(FATAL_ERROR "Can't find selinux's Makefile")
699 endif()
700 add_subdirectory(selinux)
701 endif(WITH_SELINUX)
702
703 # enables testing and creates Make check command
704 add_custom_target(tests
705 COMMENT "Building tests")
706 enable_testing()
707 set(CMAKE_CTEST_COMMAND ctest)
708 add_custom_target(check
709 COMMAND ${CMAKE_CTEST_COMMAND}
710 DEPENDS tests)
711
712 option(WITH_SYSTEMD "build with systemd support" ON)
713
714 add_subdirectory(src)
715
716 add_subdirectory(qa)
717 add_subdirectory(doc)
718 if(WITH_MANPAGE)
719 add_subdirectory(man)
720 endif(WITH_MANPAGE)
721
722 if(WITH_SYSTEMD)
723 add_subdirectory(systemd)
724 endif()
725
726 if(LINUX)
727 add_subdirectory(etc/sysctl)
728 endif()
729
730 option(WITH_GRAFANA "install grafana dashboards" OFF)
731 add_subdirectory(monitoring/ceph-mixin)
732
733 include(CTags)
734 option(CTAG_EXCLUDES "Exclude files/directories when running ctag.")
735 add_tags(ctags
736 SRC_DIR src
737 TAG_FILE tags
738 EXCLUDE_OPTS ${CTAG_EXCLUDES}
739 EXCLUDES "*.js" "*.css" ".tox" "python-common/build")
740 add_custom_target(tags DEPENDS ctags)