1 cmake_minimum_required(VERSION 3.16)
7 foreach(policy CMP0127 CMP0135)
9 cmake_policy(SET ${policy} NEW)
13 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")
15 if(NOT CMAKE_BUILD_TYPE)
16 if (EXISTS "${CMAKE_SOURCE_DIR}/.git")
17 message(WARNING "CMAKE_BUILD_TYPE not specified, assuming CMAKE_BUILD_TYPE=Debug because .git exists.")
18 set(default_build_type "Debug")
19 set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
20 STRING "Default BUILD_TYPE is Debug, other options are: RelWithDebInfo, Release, and MinSizeRel." FORCE)
22 message(WARNING "CMAKE_BUILD_TYPE not specified, leaving unset because .git does NOT exist.")
26 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
29 elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
32 endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
35 # The Windows headers (e.g. coming from mingw or the Windows SDK) check
36 # the targeted Windows version. The availability of certain functions and
37 # structures will depend on it.
38 set(WIN32_WINNT "0x0A00" CACHE STRING "Targeted Windows version.")
40 -D_WIN32_WINNT=${WIN32_WINNT}
43 # In order to avoid known winpthread issues, we're using the Boost
44 # shared mutex implementation. This isn't required with llvm/libc++.
45 # https://github.com/msys2/MINGW-packages/issues/3319
46 if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
48 -DBOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
49 -DBOOST_THREAD_V2_SHARED_MUTEX
52 set(Boost_THREADAPI "win32")
56 string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl,-allow-multiple-definition")
57 string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,-allow-multiple-definition")
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>")
68 link_directories(${MINGW_LINK_DIRECTORIES})
71 option(WITH_CCACHE "Build with ccache.")
73 if(CMAKE_C_COMPILER_LAUNCHER OR CMAKE_CXX_COMPILER_LAUNCHER)
74 message(WARNING "Compiler launcher already set. stop configuring ccache")
76 find_program(CCACHE_EXECUTABLE ccache)
77 if(NOT CCACHE_EXECUTABLE)
78 message(FATAL_ERROR "Can't find ccache. Is it installed?")
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})
86 option(WITH_MANPAGE "Build man pages." ON)
88 find_program(SPHINX_BUILD
89 NAMES sphinx-build sphinx-build-3)
91 message(FATAL_ERROR "Can't find sphinx-build.")
92 endif(NOT SPHINX_BUILD)
96 ${PROJECT_BINARY_DIR}/src/include
97 ${PROJECT_SOURCE_DIR}/src)
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")
110 include_directories(SYSTEM /usr/local/include)
111 link_directories(/usr/local/lib)
112 list(APPEND CMAKE_REQUIRED_INCLUDES /usr/local/include)
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)
121 include(GNUInstallDirs)
123 if(CMAKE_GENERATOR MATCHES Ninja)
127 set(CEPH_MAN_DIR "share/man" CACHE STRING "Install location for man pages (relative to prefix).")
129 option(ENABLE_SHARED "build shared libraries" ON)
131 set(CEPH_SHARED SHARED)
133 set(CEPH_SHARED STATIC)
135 set(CMAKE_POSITION_INDEPENDENT_CODE ${ENABLE_SHARED})
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")
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)
148 include(CheckCxxAtomic)
149 if(NOT HAVE_CXX11_ATOMIC)
150 string(APPEND CMAKE_CXX_STANDARD_LIBRARIES
151 " ${LIBATOMIC_LINK_FLAGS}")
154 option(WITH_RDMA "Enable RDMA in async messenger" ON)
156 find_package(verbs REQUIRED)
157 set(HAVE_VERBS ${VERBS_FOUND})
158 find_package(rdmacm REQUIRED)
159 set(HAVE_RDMACM ${RDMACM_FOUND})
163 find_package(Backtrace)
165 option(WITH_RBD "Enable RADOS Block Device related targets" ON)
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})
179 set(HAVE_KEYUTILS OFF)
185 option(WITH_OPENLDAP "OPENLDAP is here" ON)
187 find_package(OpenLDAP REQUIRED)
188 set(HAVE_OPENLDAP ${OpenLDAP_FOUND})
191 option(WITH_GSSAPI "GSSAPI/KRB5 is here" OFF)
193 find_package(GSSApi REQUIRED)
194 set(HAVE_GSSAPI ${GSSApi_FOUND})
197 option(WITH_FUSE "Fuse is here" ON)
199 find_package(FUSE REQUIRED)
200 set(HAVE_LIBFUSE ${FUSE_FOUND})
203 option(WITH_DOKAN "Dokan is here" OFF)
205 option(WITH_XFS "XFS is here" ON)
208 set(HAVE_LIBXFS ${XFS_FOUND})
211 option(WITH_ZFS "enable LibZFS if found" OFF)
214 set(HAVE_LIBZFS ${ZFS_FOUND})
217 option(WITH_BLUESTORE "Bluestore OSD backend" ON)
221 set(HAVE_LIBAIO ${AIO_FOUND})
223 # POSIX AIO is integrated into FreeBSD kernel, and exposed by libc.
224 set(HAVE_POSIXAIO ON)
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})
234 include(CMakeDependentOption)
236 CMAKE_DEPENDENT_OPTION(WITH_LIBURING "Enable io_uring bluestore backend" ON
237 "WITH_BLUESTORE;HAVE_LIBAIO" OFF)
238 set(HAVE_LIBURING ${WITH_LIBURING})
240 CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_LIBURING "Require and build with system liburing" OFF
241 "HAVE_LIBAIO;WITH_BLUESTORE" OFF)
244 if(WITH_SYSTEM_LIBURING)
245 find_package(uring REQUIRED)
250 # enable uring in boost::asio
251 add_compile_definitions("BOOST_ASIO_HAS_IO_URING")
254 CMAKE_DEPENDENT_OPTION(WITH_BLUESTORE_PMEM "Enable PMDK libraries" OFF
255 "WITH_BLUESTORE" OFF)
256 if(WITH_BLUESTORE_PMEM)
258 set(HAVE_LIBDML ${DML_FOUND})
261 CMAKE_DEPENDENT_OPTION(WITH_RBD_MIRROR "Enable build for rbd-mirror daemon executable" OFF
264 CMAKE_DEPENDENT_OPTION(WITH_RBD_MIGRATION_FORMAT_QCOW_V1
265 "Enable librbd QCOW v1 migration format support" ON
268 CMAKE_DEPENDENT_OPTION(WITH_RBD_RWL "Enable librbd persistent write back cache" OFF
271 CMAKE_DEPENDENT_OPTION(WITH_RBD_SSD_CACHE "Enable librbd persistent write back cache for SSDs" OFF
274 CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_PMDK "Require and build with system PMDK" OFF
275 "WITH_RBD_RWL OR WITH_BLUESTORE_PMEM" OFF)
277 CMAKE_DEPENDENT_OPTION(WITH_RBD_UBBD "Enable ubbd support for rbd device utility" OFF
285 if(WITH_BLUESTORE_PMEM)
286 set(HAVE_BLUESTORE_PMEM ON)
289 CMAKE_DEPENDENT_OPTION(WITH_SPDK "Enable SPDK" OFF
290 "CMAKE_SYSTEM_PROCESSOR MATCHES i386|i686|amd64|x86_64|AMD64|aarch64" OFF)
292 if(NOT WITH_BLUESTORE)
293 message(SEND_ERROR "Please enable WITH_BLUESTORE for using SPDK")
301 if(NOT AIO_FOUND AND NOT HAVE_POSIXAIO AND NOT WITH_SPDK AND NOT WITH_BLUESTORE_PMEM)
302 message(SEND_ERROR "WITH_BLUESTORE is ON, "
303 "but none of the bluestore backends is enabled. "
304 "Please install libaio, or enable WITH_SPDK or WITH_BLUESTORE_PMEM (experimental)")
308 option(WITH_BLUEFS "libbluefs library" OFF)
310 CMAKE_DEPENDENT_OPTION(WITH_QATLIB "Enable QAT with qatlib" ON
311 "CMAKE_SYSTEM_PROCESSOR MATCHES amd64|x86_64|AMD64" OFF)
312 option(WITH_SYSTEM_QATLIB "Use system packages for qatlib" OFF)
313 option(WITH_QATDRV "Enable QAT with out-of-tree driver" OFF)
314 CMAKE_DEPENDENT_OPTION(WITH_QATZIP "Enable QATzip" ON
315 "CMAKE_SYSTEM_PROCESSOR MATCHES amd64|x86_64|AMD64" OFF)
316 option(WITH_SYSTEM_QATZIP "Use system packages for QATzip" OFF)
319 find_package(QatDrv REQUIRED COMPONENTS qat_s usdm_drv_s)
322 if(NOT WITH_SYSTEM_QAT)
326 find_package(QAT REQUIRED)
327 if(NOT WITH_SYSTEM_QAT)
328 add_dependencies(QAT::qat qatlib_ext)
329 add_dependencies(QAT::usdm qatlib_ext)
336 message(FATAL_ERROR "WITH_QATZIP requires WITH_QATLIB or WITH_QATDRV")
338 if(NOT WITH_SYSTEM_QATZIP)
341 # qatzip build depends on qatlib
342 add_dependencies(qatzip_ext QAT::qat)
344 find_package(QATzip REQUIRED)
345 if(NOT WITH_SYSTEM_QATZIP)
346 add_dependencies(QAT::zip qatzip_ext)
348 set(HAVE_QATZIP TRUE)
352 option(WITH_LIBCEPHFS "libcephfs client library" ON)
354 option(WITH_LIBCEPHSQLITE "libcephsqlite client library" ON)
355 if(WITH_LIBCEPHSQLITE)
356 find_package(SQLite3 REQUIRED)
360 option(WITH_KVS "Key value store is here" OFF)
362 option(WITH_KRBD "Enable Linux krbd support of 'rbd' utility" ON)
364 if(WITH_KRBD AND NOT WITH_RBD)
365 message(FATAL_ERROR "Cannot have WITH_KRBD without WITH_RBD.")
368 if(WITH_LIBCEPHFS OR WITH_KRBD)
369 # keyutils is only used when talking to the Linux Kernel key store
370 find_package(keyutils REQUIRED)
371 set(HAVE_KEYUTILS ${KEYUTILS_FOUND})
375 find_package(snappy REQUIRED)
377 option(WITH_BROTLI "Brotli compression support" OFF)
379 set(HAVE_BROTLI TRUE)
382 option(WITH_LZ4 "LZ4 compression support" ON)
384 find_package(LZ4 1.7 REQUIRED)
385 set(HAVE_LZ4 ${LZ4_FOUND})
388 CMAKE_DEPENDENT_OPTION(WITH_CEPH_DEBUG_MUTEX "Use debug ceph::mutex with lockdep" ON
389 "CMAKE_BUILD_TYPE STREQUAL Debug" OFF)
391 #if allocator is set on command line make sure it matches below strings
392 set(ALLOCATOR "" CACHE STRING
393 "specify memory allocator to use. currently tcmalloc, tcmalloc_minimal, \
394 jemalloc, and libc is supported. if not specified, will try to find tcmalloc, \
395 and then jemalloc. If neither of then is found. use the one in libc.")
397 if(${ALLOCATOR} MATCHES "tcmalloc(_minimal)?")
398 find_package(gperftools 2.6.2 REQUIRED)
399 set(ALLOC_LIBS gperftools::${ALLOCATOR})
400 set(HAVE_LIBTCMALLOC ON)
401 elseif(${ALLOCATOR} STREQUAL "jemalloc")
402 find_package(JeMalloc REQUIRED)
403 set(ALLOC_LIBS JeMalloc::JeMalloc)
405 elseif(NOT ALLOCATOR STREQUAL "libc")
406 message(FATAL_ERROR "Unsupported allocator selected: ${ALLOCATOR}")
409 find_package(gperftools 2.6.2)
410 set(HAVE_LIBTCMALLOC ${gperftools_FOUND})
411 if(NOT gperftools_FOUND)
412 find_package(JeMalloc)
415 set(ALLOCATOR tcmalloc)
416 set(ALLOC_LIBS gperftools::tcmalloc)
417 elseif(JeMalloc_FOUND)
418 set(ALLOCATOR jemalloc)
419 set(ALLOC_LIBS JeMalloc::JeMalloc)
422 # FreeBSD already has jemalloc as its default allocator
423 message(WARNING "tcmalloc and jemalloc not found, falling back to libc")
425 set(ALLOCATOR "libc")
426 endif(gperftools_FOUND)
428 if(NOT ALLOCATOR STREQUAL "libc")
430 $<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-malloc>
431 $<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-calloc>
432 $<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-realloc>
433 $<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-free>)
435 message(STATUS "allocator selected: ${ALLOCATOR}")
437 # Mingw generates incorrect entry points when using "-pie".
438 if(WIN32 OR (HAVE_LIBTCMALLOC AND WITH_STATIC_LIBSTDCXX))
439 set(EXE_LINKER_USE_PIE FALSE)
441 set(EXE_LINKER_USE_PIE ${ENABLE_SHARED})
445 # require libcurl with good curl_multi_wait(), see https://tracker.ceph.com/issues/15915
446 find_package(CURL 7.32 REQUIRED)
449 find_package(OpenSSL REQUIRED)
450 set(CRYPTO_LIBS OpenSSL::Crypto)
452 option(WITH_DPDK "Enable DPDK messaging" OFF)
457 build_dpdk(${CMAKE_BINARY_DIR}/src/dpdk)
462 option(WITH_BLKIN "Use blkin to emit LTTng tracepoints for Zipkin" OFF)
464 find_package(LTTngUST REQUIRED)
465 set(BLKIN_LIBRARIES blkin ${LTTNGUST_LIBRARIES} lttng-ust-fork)
466 include_directories(SYSTEM src/blkin/blkin-lib)
469 option(WITH_JAEGER "Enable jaegertracing and it's dependent libraries" ON)
471 set(HAVE_JAEGER TRUE)
475 option(WITH_RADOSGW "RADOS Gateway is enabled" ON)
476 option(WITH_RADOSGW_BEAST_OPENSSL "RADOS Gateway's Beast frontend uses OpenSSL" ON)
477 option(WITH_RADOSGW_AMQP_ENDPOINT "RADOS Gateway's pubsub support for AMQP push endpoint" ON)
478 option(WITH_RADOSGW_KAFKA_ENDPOINT "RADOS Gateway's pubsub support for Kafka push endpoint" ON)
479 option(WITH_RADOSGW_LUA_PACKAGES "RADOS Gateway's support for dynamically adding lua packagess" ON)
480 option(WITH_RADOSGW_DBSTORE "DBStore backend for RADOS Gateway" ON)
481 option(WITH_RADOSGW_MOTR "CORTX-Motr backend for RADOS Gateway" OFF)
482 option(WITH_RADOSGW_DAOS "DAOS backend for RADOS Gateway" OFF)
483 option(WITH_RADOSGW_D4N "D4N wrapper for RADOS Gateway" ON)
484 option(WITH_RADOSGW_POSIX "POSIX backend for Rados Gateway" ON)
485 option(WITH_RADOSGW_SELECT_PARQUET "Support for s3 select on parquet objects" ON)
486 option(WITH_RADOSGW_ARROW_FLIGHT "Build arrow flight when not using system-provided arrow" OFF)
487 option(WITH_RADOSGW_BACKTRACE_LOGGING "Enable backtraces in rgw logs" OFF)
489 option(WITH_SYSTEM_ARROW "Use system-provided arrow" OFF)
490 option(WITH_SYSTEM_UTF8PROC "Use system-provided utf8proc" OFF)
493 find_package(EXPAT REQUIRED)
494 find_package(OATH REQUIRED)
496 # https://curl.haxx.se/docs/install.html mentions the
497 # configure flags for various ssl backends
501 "curl-config --configure | grep with-ssl"
502 RESULT_VARIABLE NO_CURL_SSL_LINK
503 ERROR_VARIABLE CURL_CONFIG_ERRORS
505 if (CURL_CONFIG_ERRORS)
506 message(WARNING "unable to run curl-config; rgw cannot make ssl requests to external systems reliably")
509 if (NOT NO_CURL_SSL_LINK)
510 message(STATUS "libcurl is linked with openssl: explicitly setting locks")
511 set(WITH_CURL_OPENSSL ON)
512 endif() # CURL_SSL_LINK
516 "objdump -p ${OPENSSL_SSL_LIBRARY} | sed -n 's/^ SONAME *//p'"
517 OUTPUT_VARIABLE LIBSSL_SONAME
518 ERROR_VARIABLE OBJDUMP_ERRORS
519 RESULT_VARIABLE OBJDUMP_RESULTS
520 OUTPUT_STRIP_TRAILING_WHITESPACE)
522 message(FATAL_ERROR "can't run objdump: ${OBJDUMP_RESULTS}")
524 if (NOT OBJDUMP_ERRORS STREQUAL "")
525 message(WARNING "message from objdump: ${OBJDUMP_ERRORS}")
530 "objdump -p ${OPENSSL_CRYPTO_LIBRARY} | sed -n 's/^ SONAME *//p'"
531 OUTPUT_VARIABLE LIBCRYPTO_SONAME
532 ERROR_VARIABLE OBJDUMP_ERRORS
533 RESULT_VARIABLE OBJDUMP_RESULTS
534 OUTPUT_STRIP_TRAILING_WHITESPACE)
536 message(FATAL_ERROR "can't run objdump: ${OBJDUMP_RESULTS}")
538 if (NOT OBJDUMP_ERRORS STREQUAL "")
539 message(WARNING "message from objdump: ${OBJDUMP_ERRORS}")
541 message(STATUS "ssl soname: ${LIBSSL_SONAME}")
542 message(STATUS "crypto soname: ${LIBCRYPTO_SONAME}")
546 option(WITH_CEPHFS "CephFS is enabled" ON)
549 # Please specify 3.[0-7] if you want to build with a certain version of python3.
550 set(WITH_PYTHON3 "3" CACHE STRING "build with specified python3 version")
551 find_package(Python3 ${WITH_PYTHON3} EXACT REQUIRED
552 COMPONENTS Interpreter Development)
554 option(WITH_MGR "ceph-mgr is enabled" ON)
556 set(MGR_PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
557 set(MGR_PYTHON_LIBRARIES ${Python3_LIBRARIES})
558 set(MGR_PYTHON_VERSION_MAJOR ${Python3_VERSION_MAJOR})
559 set(MGR_PYTHON_VERSION_MINOR ${Python3_VERSION_MINOR})
560 # Boost dependency check deferred to Boost section
564 option(WITH_THREAD_SAFE_RES_QUERY "res_query is thread safe" OFF)
565 if(WITH_THREAD_SAFE_RES_QUERY)
566 set(HAVE_THREAD_SAFE_RES_QUERY 1 CACHE INTERNAL "Thread safe res_query supported.")
569 option(WITH_REENTRANT_STRSIGNAL "strsignal is reentrant" OFF)
570 if(WITH_REENTRANT_STRSIGNAL)
571 set(HAVE_REENTRANT_STRSIGNAL 1 CACHE INTERNAL "Reentrant strsignal is supported.")
575 find_package(ZLIB REQUIRED)
577 #option for EventTrace
578 CMAKE_DEPENDENT_OPTION(
579 WITH_EVENTTRACE "Event tracing support, requires WITH_LTTNG"
583 option(WITH_LTTNG "LTTng tracing is enabled" ON)
585 find_package(LTTngUST REQUIRED)
586 find_program(LTTNG_GEN_TP
589 message(FATAL_ERROR "Can't find lttng-gen-tp.")
593 option(WITH_OSD_INSTRUMENT_FUNCTIONS OFF)
595 #option for Babeltrace
596 option(WITH_BABELTRACE "Babeltrace libraries are enabled" ON)
598 set(HAVE_BABELTRACE ON)
599 find_package(babeltrace REQUIRED)
600 set(HAVE_BABELTRACE_BABELTRACE_H ${BABELTRACE_FOUND})
601 set(HAVE_BABELTRACE_CTF_EVENTS_H ${BABELTRACE_FOUND})
602 set(HAVE_BABELTRACE_CTF_ITERATOR_H ${BABELTRACE_FOUND})
603 endif(WITH_BABELTRACE)
605 option(DEBUG_GATHER "C_Gather debugging is enabled" ON)
606 option(ENABLE_COVERAGE "Coverage is enabled" OFF)
607 option(PG_DEBUG_REFS "PG Ref debugging is enabled" OFF)
609 option(WITH_TESTS "enable the build of ceph-test package scripts/binaries" ON)
610 set(UNIT_TESTS_BUILT ${WITH_TESTS})
611 set(CEPH_TEST_TIMEOUT 7200 CACHE STRING
612 "Maximum time before a CTest gets killed" )
615 option(WITH_FIO "build with fio plugin enabled" OFF)
622 add_definitions(-D__linux__)
626 option(WITH_ASAN "build with ASAN" OFF)
628 list(APPEND sanitizers "address")
631 option(WITH_ASAN_LEAK "explicitly enable ASAN leak detection" OFF)
633 list(APPEND sanitizers "leak")
636 option(WITH_TSAN "build with TSAN" OFF)
638 list(APPEND sanitizers "thread")
641 option(WITH_UBSAN "build with UBSAN" OFF)
643 list(APPEND sanitizers "undefined_behavior")
647 find_package(Sanitizers REQUIRED ${sanitizers})
648 add_compile_options(${Sanitizers_COMPILE_OPTIONS})
649 string(REPLACE ";" " " sanitiers_compile_flags "${Sanitizers_COMPILE_OPTIONS}")
650 string(APPEND CMAKE_EXE_LINKER_FLAGS " ${sanitiers_compile_flags}")
651 string(APPEND CMAKE_SHARED_LINKER_FLAGS " ${sanitiers_compile_flags}")
655 option(WITH_SYSTEM_ROCKSDB "require and build with system rocksdb" OFF)
656 if (WITH_SYSTEM_ROCKSDB)
657 find_package(RocksDB 5.14 REQUIRED)
660 option(WITH_SEASTAR "Build seastar components")
661 set(HAVE_SEASTAR ${WITH_SEASTAR})
664 option(WITH_SYSTEM_BOOST "require and build with system Boost" OFF)
666 # Boost::thread depends on Boost::atomic, so list it explicitly.
668 atomic chrono thread system regex random program_options date_time
669 iostreams context coroutine)
670 set(BOOST_HEADER_COMPONENTS container)
673 list(APPEND BOOST_COMPONENTS
674 python${MGR_PYTHON_VERSION_MAJOR}${MGR_PYTHON_VERSION_MINOR})
677 list(APPEND BOOST_COMPONENTS timer)
680 if(WITH_RADOSGW AND WITH_RADOSGW_LUA_PACKAGES)
681 list(APPEND BOOST_COMPONENTS filesystem)
684 set(Boost_USE_MULTITHREADED ON)
686 CMAKE_DEPENDENT_OPTION(WITH_BOOST_VALGRIND "Boost support for valgrind" OFF
687 "NOT WITH_SYSTEM_BOOST" OFF)
688 # require minimally the bundled version
689 if(WITH_SYSTEM_BOOST)
691 set(Boost_USE_STATIC_LIBS OFF)
693 set(Boost_USE_STATIC_LIBS ON)
695 if(BOOST_ROOT AND CMAKE_LIBRARY_ARCHITECTURE)
696 set(BOOST_LIBRARYDIR "${BOOST_ROOT}/lib/${CMAKE_LIBRARY_ARCHITECTURE}")
698 find_package(Boost 1.82 COMPONENTS ${BOOST_COMPONENTS} REQUIRED)
699 if(NOT ENABLE_SHARED)
700 set_property(TARGET Boost::iostreams APPEND PROPERTY
701 INTERFACE_LINK_LIBRARIES ZLIB::ZLIB)
704 include(ProcessorCount)
705 ProcessorCount(DEFAULT_BOOST_J)
706 if(DEFAULT_BOOST_J EQUAL 0)
707 set(DEFAULT_BOOST_J 1)
709 set(BOOST_J ${DEFAULT_BOOST_J} CACHE STRING "max jobs for Boost build") # override w/-DBOOST_J=<n>
710 set(Boost_USE_STATIC_LIBS ON)
713 COMPONENTS ${BOOST_COMPONENTS} ${BOOST_HEADER_COMPONENTS})
715 include_directories(BEFORE SYSTEM ${Boost_INCLUDE_DIRS})
717 if(Boost_VERSION VERSION_LESS 1.84)
718 # This is a workaround for https://github.com/boostorg/phoenix/issues/111
719 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-DBOOST_PHOENIX_STL_TUPLE_H_>)
722 # dashboard angular2 frontend
723 option(WITH_MGR_DASHBOARD_FRONTEND "Build the mgr/dashboard frontend using `npm`" ON)
724 option(WITH_SYSTEM_NPM "Assume that dashboard build tools already installed through packages" OFF)
726 find_program(NPM_EXECUTABLE npm)
727 if(NOT NPM_EXECUTABLE)
728 message(FATAL_ERROR "Can't find npm.")
731 set(DASHBOARD_FRONTEND_LANGS "ALL" CACHE STRING
732 "List of comma separated ceph-dashboard frontend languages to build. \
733 Use value `ALL` to build all languages")
734 CMAKE_DEPENDENT_OPTION(WITH_MGR_ROOK_CLIENT "Enable the mgr's Rook support" ON
737 include_directories(SYSTEM ${PROJECT_BINARY_DIR}/include)
739 find_package(Threads REQUIRED)
740 find_package(StdFilesystem REQUIRED)
742 option(WITH_SELINUX "build SELinux policy" OFF)
744 find_file(SELINUX_MAKEFILE selinux/devel/Makefile
746 if(NOT SELINUX_MAKEFILE)
747 message(FATAL_ERROR "Can't find selinux's Makefile")
749 add_subdirectory(selinux)
752 # enables testing and creates Make check command
753 add_custom_target(tests
754 COMMENT "Building tests")
756 set(CMAKE_CTEST_COMMAND ctest)
757 add_custom_target(check
758 COMMAND ${CMAKE_CTEST_COMMAND}
761 option(WITH_SYSTEMD "build with systemd support" ON)
763 add_subdirectory(src)
766 add_subdirectory(doc)
768 add_subdirectory(man)
772 add_subdirectory(systemd)
776 add_subdirectory(etc/sysctl)
779 option(WITH_GRAFANA "install grafana dashboards" OFF)
780 add_subdirectory(monitoring/ceph-mixin)
783 option(CTAG_EXCLUDES "Exclude files/directories when running ctag.")
787 EXCLUDE_OPTS ${CTAG_EXCLUDES}
788 EXCLUDES "*.js" "*.css" ".tox" "python-common/build")
789 add_custom_target(tags DEPENDS ctags)