1 include(GetGitRevisionDescription)
2 include(CheckCXXCompilerFlag)
4 # for erasure and compressor plugins
5 set(CEPH_INSTALL_PKGLIBDIR ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME})
6 set(CEPH_INSTALL_FULL_PKGLIBDIR ${CMAKE_INSTALL_FULL_LIBDIR}/${PROJECT_NAME})
8 set(CEPH_INSTALL_DATADIR ${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME})
9 # so libceph-common can be found
10 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
11 if(NOT CMAKE_INSTALL_RPATH)
12 set(CMAKE_INSTALL_RPATH "${CEPH_INSTALL_FULL_PKGLIBDIR}")
15 # to be compatible with configure_files shared with autoconfig
16 set(bindir ${CMAKE_INSTALL_FULL_BINDIR})
17 set(sbindir ${CMAKE_INSTALL_FULL_SBINDIR})
18 set(libdir ${CMAKE_INSTALL_FULL_LIBDIR})
19 set(sysconfdir ${CMAKE_INSTALL_FULL_SYSCONFDIR})
20 set(libexecdir ${CMAKE_INSTALL_FULL_LIBEXECDIR})
21 set(pkgdatadir ${CMAKE_INSTALL_FULL_DATADIR})
22 set(datadir ${CEPH_INSTALL_DATADIR})
23 set(prefix ${CMAKE_INSTALL_PREFIX})
30 -D__STDC_FORMAT_MACROS
31 -D_FILE_OFFSET_BITS=64
32 -DBOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION)
33 if(Boost_VERSION VERSION_GREATER_EQUAL 1.74)
34 add_definitions(-DBOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
38 add_definitions("-D_GNU_SOURCE")
51 -Werror=format-security
54 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wnon-virtual-dtor>)
55 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-ignored-qualifiers>)
58 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-ftemplate-depth-1024>)
60 CHECK_CXX_COMPILER_FLAG("-Wpessimizing-move" COMPILER_SUPPORTS_PESSIMIZING_MOVE)
61 if(COMPILER_SUPPORTS_PESSIMIZING_MOVE)
62 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wpessimizing-move>)
64 CHECK_CXX_COMPILER_FLAG("-Wredundant-move" COMPILER_SUPPORTS_REDUNDANT_MOVE)
65 if(COMPILER_SUPPORTS_REDUNDANT_MOVE)
66 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wredundant-move>)
68 if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
70 # The MINGW headers are missing some "const" qualifiers.
71 add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-fpermissive>)
73 string(APPEND CMAKE_EXE_LINKER_FLAGS " -rdynamic")
75 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wstrict-null-sentinel>)
76 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Woverloaded-virtual>)
77 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-new-ttp-matching>)
78 # cmake does not add '-pie' for executables even if
79 # CMAKE_POSITION_INDEPENDENT_CODE is TRUE.
80 if(EXE_LINKER_USE_PIE)
81 if (NOT WITH_OSD_INSTRUMENT_FUNCTIONS AND NOT HAVE_SEASTAR)
82 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
85 elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
86 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_EXPORTS_C_FLAG}")
87 string(APPEND CMAKE_LINKER_FLAGS " -rdynamic -export-dynamic ${CMAKE_EXE_EXPORTS_C_FLAG}")
88 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-inconsistent-missing-override>)
89 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-mismatched-tags>)
90 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-unused-private-field>)
91 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-address-of-packed-member>)
94 -Wno-unused-local-typedef
99 -Wno-deprecated-register)
101 # Need to use the GNU binutils linker to get versioning right.
102 string(APPEND CMAKE_EXE_LINKER_FLAGS " -fuse-ld=/usr/local/bin/ld -Wno-unused-command-line-argument")
103 string(APPEND CMAKE_SHARED_LINKER_FLAGS " -fuse-ld=/usr/local/bin/ld -Wno-unused-command-line-argument")
106 string(APPEND CMAKE_SHARED_LINKER_FLAGS " -undefined dynamic_lookup")
108 endif(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
110 if(NOT CMAKE_BUILD_TYPE)
111 if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
112 set(default_build_type "Debug")
114 set(default_build_type "RelWithDebInfo")
116 set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
117 STRING "Default BUILD_TYPE is Debug, other options are: RelWithDebInfo, Release, and MinSizeRel." FORCE)
120 if(WITH_CEPH_DEBUG_MUTEX OR CMAKE_BUILD_TYPE STREQUAL Debug)
121 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-DCEPH_DEBUG_MUTEX>)
124 include(CheckCCompilerFlag)
125 if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
126 CHECK_C_COMPILER_FLAG("-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2" HAS_FORTIFY_SOURCE)
127 if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
128 if(HAS_FORTIFY_SOURCE)
135 CHECK_C_COMPILER_FLAG(-fstack-protector-strong HAS_STACK_PROTECT)
136 if (HAS_STACK_PROTECT)
137 add_compile_options(-fstack-protector-strong)
140 endif(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
142 CHECK_C_COMPILER_FLAG("-D_GLIBCXX_ASSERTIONS" HAS_GLIBCXX_ASSERTIONS)
143 if(HAS_GLIBCXX_ASSERTIONS AND CMAKE_BUILD_TYPE STREQUAL Debug)
144 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-D_GLIBCXX_ASSERTIONS>)
150 set(object_format "macho64")
152 set(object_format "elf64")
154 set(CMAKE_ASM_FLAGS "-f ${object_format}")
155 set(CMAKE_ASM_COMPILER ${PROJECT_SOURCE_DIR}/src/nasm-wrapper)
157 # The native tools might be located even when cross compiling, which
158 # might not work in this case (especially when targeting Windows).
160 check_nasm_support(${object_format}
163 HAVE_NASM_X64_AVX512)
168 set(CMAKE_CXX_STANDARD 17)
169 set(CMAKE_CXX_EXTENSIONS OFF)
170 set(CMAKE_CXX_STANDARD_REQUIRED ON)
171 set(CMAKE_C_STANDARD 99)
172 # we use `asm()` to inline assembly, so enable the GNU extension
173 set(CMAKE_C_EXTENSIONS ON)
174 set(C_STANDARD_REQUIRED ON)
176 include(CheckCXXSourceCompiles)
177 CHECK_CXX_SOURCE_COMPILES("
179 using Map = std::map<int, int>;
184 " HAVE_STDLIB_MAP_SPLICING)
186 ## Handle diagnostics color if compiler supports them.
187 CHECK_C_COMPILER_FLAG("-fdiagnostics-color=always"
188 COMPILER_SUPPORTS_DIAGNOSTICS_COLOR)
190 set(DIAGNOSTICS_COLOR "auto"
191 CACHE STRING "Used if the C/C++ compiler supports the -fdiagnostics-color option. May have one of three values -- 'auto' (default), 'always', or 'never'. If set to 'always' and the compiler supports the option, 'make [...] | less -R' will make visible diagnostics colorization of compiler output.")
193 if(COMPILER_SUPPORTS_DIAGNOSTICS_COLOR)
194 add_compile_options(-fdiagnostics-color=${DIAGNOSTICS_COLOR})
197 set(EXTRALIBS ${CMAKE_DL_LIBS})
198 if(HAVE_POSIX_TIMERS)
199 list(APPEND EXTRALIBS ${RT_LIBRARY})
202 set(LIB_RESOLV resolv)
203 list(APPEND EXTRALIBS ${LIB_RESOLV})
206 if(${ENABLE_COVERAGE})
207 find_program(HAVE_GCOV gcov)
209 message(FATAL_ERROR "Coverage Enabled but gcov Not Found")
215 list(APPEND EXTRALIBS gcov)
216 endif(${ENABLE_COVERAGE})
218 set(GCOV_PREFIX_STRIP 4)
220 # the src/.git_version file may be written out by make-dist; otherwise
221 # we pull the git version from .git
222 option(ENABLE_GIT_VERSION "build Ceph with git version string" ON)
223 if(${ENABLE_GIT_VERSION})
224 get_git_head_revision(GIT_REFSPEC CEPH_GIT_VER)
225 git_describe(CEPH_GIT_NICE_VER_WITH_V --always)
227 string(SUBSTRING ${CEPH_GIT_NICE_VER_WITH_V} 1 -1 CEPH_GIT_NICE_VER)
228 #if building from a source tarball via make-dist
229 if(${CEPH_GIT_VER} STREQUAL "GITDIR-NOTFOUND")
230 message(STATUS "Ceph/.git directory not found, parsing ${CMAKE_CURRENT_SOURCE_DIR}/.git_version for CEPH_GIT_VER and CEPH_GIT_NICE_VER")
231 file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/.git_version CEPH_GIT_SHA_AND_TAG)
232 list(GET CEPH_GIT_SHA_AND_TAG 0 CEPH_GIT_VER)
233 list(GET CEPH_GIT_SHA_AND_TAG 1 CEPH_GIT_NICE_VER)
234 endif(${CEPH_GIT_VER} STREQUAL "GITDIR-NOTFOUND")
235 else(${ENABLE_GIT_VERSION})
236 set(CEPH_GIT_VER "no_version")
237 set(CEPH_GIT_NICE_VER "Development")
238 endif(${ENABLE_GIT_VERSION})
240 # the src/ceph_release file is 3 lines,
241 # <release number, e.g. '12' for luminous>
242 # <release name, e.g. 'luminous'>
243 # <release type: 'dev' for x.0.z, 'rc' or x.1.z, or 'stable' or x.2.z>
244 # note that the release name is semi-redundant and must match CEPH_RELEASE_*
245 # definitions in include/rados.h and common/ceph_strings.c.
246 file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/ceph_release CEPH_RELEASE_FILE)
247 list(GET CEPH_RELEASE_FILE 0 CEPH_RELEASE)
248 list(GET CEPH_RELEASE_FILE 1 CEPH_RELEASE_NAME)
249 list(GET CEPH_RELEASE_FILE 2 CEPH_RELEASE_TYPE)
251 option(WITH_OCF "build OCF-compliant cluster resource agent" OFF)
253 add_subdirectory(ocf)
256 option(WITH_CEPHFS_JAVA "build libcephfs Java bindings" OFF)
258 add_subdirectory(java)
261 # sort out which allocator to use
262 if(ALLOCATOR STREQUAL "tcmalloc")
263 set(ALLOC_LIBS gperftools::tcmalloc)
264 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-malloc>)
265 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-calloc>)
266 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-realloc>)
267 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-free>)
268 elseif(ALLOCATOR STREQUAL "tcmalloc_minimal")
269 set(ALLOC_LIBS gperftools::tcmalloc_minimal)
270 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-malloc>)
271 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-calloc>)
272 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-realloc>)
273 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-free>)
274 elseif(ALLOCATOR STREQUAL "jemalloc")
275 set(ALLOC_LIBS JeMalloc::JeMalloc)
276 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-malloc>)
277 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-calloc>)
278 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-realloc>)
279 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-free>)
283 add_subdirectory(blkin/blkin-lib)
286 # Common infrastructure
288 ${CMAKE_SOURCE_DIR}/src/ceph_ver.h.in.cmake
289 ${CMAKE_BINARY_DIR}/src/include/ceph_ver.h
293 list(APPEND mds_files
297 mds/inode_backtrace.cc
300 mds/cephfs_features.cc)
302 add_subdirectory(json_spirit)
304 include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/src/xxHash")
305 include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/src/rapidjson/include")
307 find_package(fmt 6.0.0 QUIET)
309 include_directories(SYSTEM "${fmt_INCLUDE_DIR}")
311 message(STATUS "Could not find fmt, will build it")
312 add_subdirectory(fmt)
313 include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/src/fmt/include")
316 # in osd/PeeringState.h, the number of elements in PeeringState::Active::reactions
317 # is now 21 which exceeds the default value of BOOST_MPL_LIMIT_VECTOR_SIZE, which
318 # is 20. so we need to override it. see
319 # https://www.boost.org/doc/libs/1_74_0/libs/mpl/doc/refmanual/limit-list-size.html
320 # link with this library, if your code includes osd/PeeringState.h (indirectly)
321 add_library(Boost::MPL INTERFACE IMPORTED)
322 set_target_properties(Boost::MPL PROPERTIES
323 INTERFACE_COMPILE_DEFINITIONS
324 "BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS;BOOST_MPL_LIMIT_LIST_SIZE=30")
327 find_package(c-ares 1.13.0 QUIET)
329 message(STATUS "Could not find c-ares, will build it")
333 macro(find_package name)
334 if(NOT TARGET ${name})
335 _find_package(${ARGV})
338 set(Seastar_API_LEVEL "6" CACHE STRING "" FORCE)
339 set(Seastar_HWLOC OFF CACHE BOOL "" FORCE)
340 set(Seastar_STD_OPTIONAL_VARIANT_STRINGVIEW ON CACHE BOOL "" FORCE)
342 find_package(dpdk QUIET)
345 build_dpdk(${CMAKE_BINARY_DIR}/src/dpdk)
348 list(APPEND Seastar_CXX_FLAGS
352 "-Wno-pessimizing-move"
353 "-Wno-address-of-packed-member"
354 "-Wno-non-virtual-dtor")
355 set(Seastar_CXX_FLAGS "${Seastar_CXX_FLAGS}" CACHE STRING "" FORCE)
356 add_subdirectory(seastar)
357 # create the directory so cmake won't complain when looking at the imported
358 # target: Seastar exports this directory created at build-time
359 file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/seastar/gen/include")
360 add_subdirectory(crimson)
364 ${CMAKE_BINARY_DIR}/src/include/ceph_ver.h
366 global/global_context.cc
384 osd/PGPeeringEvent.cc
394 list(APPEND libcommon_files common/tracer.cc)
396 set_source_files_properties(ceph_ver.c
397 APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_BINARY_DIR}/src/include/ceph_ver.h)
398 add_library(common-objs OBJECT ${libcommon_files})
401 find_package(yaml-cpp 0.6.0)
402 if(NOT yaml-cpp_FOUND)
403 set(jaeger_libs ${CMAKE_BINARY_DIR}/external/lib/libyaml-cpp.so
404 ${CMAKE_BINARY_DIR}/external/lib/libyaml-cpp.so.0.6
405 ${CMAKE_BINARY_DIR}/external/lib/libyaml-cpp.so.0.6.2)
406 #customize libjaeger.install
407 execute_process(COMMAND bash -c "sed -i 's/#//' debian/libjaeger.install"
408 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
409 execute_process(COMMAND bash -c "grep -q 'yaml-cpp' debian/libjaeger.install || echo 'usr/lib/libyaml-cpp.so.*' >> debian/libjaeger.install"
410 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
412 include(IncludeJaeger)
413 add_library(jaeger-base INTERFACE)
414 add_dependencies(common-objs
416 opentracing::libopentracing
418 jaegertracing::libjaegertracing)
419 target_link_libraries(jaeger-base INTERFACE
421 opentracing::libopentracing
423 jaegertracing::libjaegertracing)
424 include_directories(SYSTEM ${CMAKE_BINARY_DIR}/external/include)
425 #with CMake 3.12+ the following can be replaced by:
426 #target_link_libraries(common-objs jaeger-base)
427 list(APPEND jaeger_libs
428 ${CMAKE_BINARY_DIR}/external/lib/libjaegertracing.so.0
429 ${CMAKE_BINARY_DIR}/external/lib/libjaegertracing.so.0.6.1
430 ${CMAKE_BINARY_DIR}/external/lib/libopentracing.so.1
431 ${CMAKE_BINARY_DIR}/external/lib/libopentracing.so.1.6.0
432 ${CMAKE_BINARY_DIR}/external/lib/libthrift.so.0.13.0)
433 install(FILES ${jaeger_libs}
434 DESTINATION ${CMAKE_INSTALL_LIBDIR})
437 CHECK_C_COMPILER_FLAG("-fvar-tracking-assignments" HAS_VTA)
438 add_subdirectory(auth)
439 add_subdirectory(common)
440 add_subdirectory(crush)
441 add_subdirectory(msg)
442 add_subdirectory(arch)
445 $<TARGET_OBJECTS:common-auth-objs>
446 $<TARGET_OBJECTS:common-common-objs>
447 $<TARGET_OBJECTS:common-msg-objs>
448 $<TARGET_OBJECTS:common_buffer_obj>
449 $<TARGET_OBJECTS:common_texttable_obj>
450 $<TARGET_OBJECTS:compressor_objs>
451 $<TARGET_OBJECTS:common-objs>
452 $<TARGET_OBJECTS:common_mountcephfs_objs>
453 $<TARGET_OBJECTS:crush_objs>)
455 json_spirit erasure_code arch crc32
460 Boost::program_options
464 StdFilesystem::filesystem
467 ${Backtrace_LIBRARIES}
471 ${CMAKE_THREAD_LIBS_INIT}
474 list(APPEND ceph_common_deps ${UDEV_LIBRARIES})
478 list(APPEND ceph_common_deps IBVerbs::verbs)
482 list(APPEND ceph_common_deps RDMA::RDMAcm)
485 if(NOT WITH_SYSTEM_BOOST)
486 list(APPEND ceph_common_deps ${ZLIB_LIBRARIES})
490 list(APPEND ceph_common_deps ${QATZIP_LIBRARIES})
494 list(APPEND ceph_common_deps common_async_dpdk)
498 list(APPEND ceph_common_deps jaeger-base)
502 list(APPEND ceph_common_deps ws2_32 mswsock iphlpapi bcrypt)
503 list(APPEND ceph_common_deps dlfcn_win32)
506 if(WITH_BLUESTORE_PMEM OR WITH_RBD_RWL)
508 if(WITH_BLUESTORE_PMEM)
509 find_package(pmem REQUIRED COMPONENTS pmem)
512 find_package(pmem REQUIRED COMPONENTS pmemobj)
520 add_library(common STATIC ${ceph_common_objs})
521 target_link_libraries(common ${ceph_common_deps})
523 add_library(ceph-common SHARED ${ceph_common_objs})
524 target_link_libraries(ceph-common ${ceph_common_deps})
525 # appease dpkg-shlibdeps
526 set_target_properties(ceph-common PROPERTIES
529 if(NOT APPLE AND NOT FREEBSD)
530 # Apple uses Mach-O, not ELF. so this option does not apply to APPLE.
532 # prefer the local symbol definitions when binding references to global
533 # symbols. otherwise we could reference the symbols defined by the application
534 # with the same name, instead of using the one defined in libceph-common.
535 # in other words, we require libceph-common to use local symbols, even if redefined
540 PROPERTY LINK_FLAGS "-Wl,-Bsymbolic -Wl,-Bsymbolic-functions")
547 DESTINATION ${CEPH_INSTALL_PKGLIBDIR})
552 DESTINATION ${CEPH_INSTALL_PKGLIBDIR}
557 add_subdirectory(tracing)
558 add_dependencies(common-objs oprequest-tp)
561 add_subdirectory(global)
564 find_package(Lua 5.3 REQUIRED)
567 # rados object classes
568 add_subdirectory(cls)
570 # RADOS client/library
571 add_subdirectory(osdc)
574 add_subdirectory(perfglue)
576 add_library(rados_snap_set_diff_obj OBJECT librados/snap_set_diff.cc)
578 option(WITH_LIBRADOSSTRIPER "build with libradosstriper support" ON)
580 add_subdirectory(include)
581 add_subdirectory(librados)
582 add_subdirectory(neorados)
584 if(WITH_LIBRADOSSTRIPER)
585 add_subdirectory(libradosstriper)
588 add_subdirectory(mgr)
590 set(librados_config_srcs
592 add_executable(librados-config ${librados_config_srcs})
593 target_link_libraries(librados-config librados Boost::program_options)
595 install(TARGETS librados-config DESTINATION bin)
597 # virtualenv base directory for ceph-disk and ceph-detect-init
598 set(CEPH_BUILD_VIRTUALENV $ENV{TMPDIR})
599 if(NOT CEPH_BUILD_VIRTUALENV)
600 set(CEPH_BUILD_VIRTUALENV ${CMAKE_BINARY_DIR})
604 add_subdirectory(pybind)
605 add_subdirectory(ceph-volume)
606 add_subdirectory(python-common)
607 add_subdirectory(cephadm)
611 add_subdirectory(mon)
614 add_executable(ceph-mon ${ceph_mon_srcs}
615 $<TARGET_OBJECTS:common_texttable_obj>)
616 add_dependencies(ceph-mon erasure_code_plugins)
617 target_link_libraries(ceph-mon mon os global-static ceph-common
619 ${CMAKE_DL_LIBS} ${GSSAPI_LIBRARIES})
620 install(TARGETS ceph-mon DESTINATION bin)
623 # make rocksdb statically
625 if(NOT WITH_SYSTEM_ROCKSDB)
626 include(BuildRocksDB)
628 endif(NOT WITH_SYSTEM_ROCKSDB)
630 include(TestBigEndian)
631 test_big_endian(CEPH_BIG_ENDIAN)
632 if(NOT CEPH_BIG_ENDIAN)
633 set(CEPH_LITTLE_ENDIAN 1)
640 add_subdirectory(blk)
641 add_subdirectory(osd)
644 # Link the Object Class API implementation directly as intermediary
645 # static library (like libosd.a) nullifies the effect of `-rdynamic`.
647 objclass/class_api.cc
650 list(APPEND ceph_osd_srcs common/tracer.cc)
652 add_executable(ceph-osd ${ceph_osd_srcs})
653 add_dependencies(ceph-osd erasure_code_plugins)
654 target_link_libraries(ceph-osd osd os global-static common
657 target_link_libraries(ceph-osd FUSE::FUSE)
659 set_target_properties(ceph-osd PROPERTIES
660 POSITION_INDEPENDENT_CODE ${EXE_LINKER_USE_PIE}
662 install(TARGETS ceph-osd DESTINATION bin)
667 add_subdirectory(mds)
670 add_executable(ceph-mds ${ceph_mds_srcs})
671 target_link_libraries(ceph-mds mds ${CMAKE_DL_LIBS} global-static ceph-common
673 install(TARGETS ceph-mds DESTINATION bin)
676 add_subdirectory(erasure-code)
680 option(WITH_SYSTEM_GTEST "require and build with system gtest and gmock" OFF)
681 if(WITH_SYSTEM_GTEST)
682 find_package(GTest REQUIRED)
683 find_package(GMock REQUIRED)
685 set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
686 add_subdirectory(googletest)
687 add_library(GMock::GMock ALIAS gmock)
688 add_library(GMock::Main ALIAS gmock_main)
689 target_include_directories(gmock INTERFACE
690 $<TARGET_PROPERTY:gtest,INTERFACE_INCLUDE_DIRECTORIES>)
691 target_include_directories(gmock_main INTERFACE
692 $<TARGET_PROPERTY:gtest,INTERFACE_INCLUDE_DIRECTORIES>)
693 add_library(GTest::GTest ALIAS gtest)
694 add_library(GTest::Main ALIAS gtest_main)
698 # dmClock (after gmock)
699 option(WITH_DMCLOCK_TESTS
700 "enable the build of dmclock-tests and dmclock-data-struct tests binaries"
702 if(WITH_TESTS AND WITH_DMCLOCK_TESTS)
703 # note: add_test is not being called, so dmclock tests aren't part
705 set(dmclock_TEST ON CACHE BOOL "" FORCE)
707 add_subdirectory(dmclock)
709 add_subdirectory(compressor)
711 add_subdirectory(tools)
714 add_subdirectory(test)
717 add_subdirectory(crypto)
720 configure_file(${CMAKE_SOURCE_DIR}/src/ceph-coverage.in
721 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-coverage @ONLY)
722 configure_file(${CMAKE_SOURCE_DIR}/src/ceph-debugpack.in
723 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-debugpack @ONLY)
726 configure_file(${CMAKE_SOURCE_DIR}/src/ceph.in
727 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph @ONLY)
729 configure_file(${CMAKE_SOURCE_DIR}/src/init-ceph.in
730 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/init-ceph @ONLY)
732 configure_file(ceph-post-file.in
733 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-post-file @ONLY)
735 configure_file(ceph-crash.in
736 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-crash @ONLY)
740 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-debugpack
741 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-coverage
746 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph
747 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-post-file
748 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-crash
749 ${CMAKE_SOURCE_DIR}/src/ceph-run
750 ${CMAKE_SOURCE_DIR}/src/ceph-clsinfo
753 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/init-ceph
754 DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/init.d
758 ${CMAKE_SOURCE_DIR}/share/id_rsa_drop.ceph.com
759 ${CMAKE_SOURCE_DIR}/share/id_rsa_drop.ceph.com.pub
760 ${CMAKE_SOURCE_DIR}/share/known_hosts_drop.ceph.com
761 DESTINATION ${CMAKE_INSTALL_DATADIR}/ceph)
766 DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/ceph)
769 ${CMAKE_SOURCE_DIR}/src/ceph-create-keys
772 add_subdirectory(bash_completion)
773 add_subdirectory(client)
776 set(libcephfs_srcs libcephfs.cc)
777 add_library(cephfs ${CEPH_SHARED} ${libcephfs_srcs})
778 target_link_libraries(cephfs PRIVATE client ceph-common
779 ${CRYPTO_LIBS} ${EXTRALIBS})
781 set_target_properties(cephfs PROPERTIES
786 foreach(name ceph-common client osdc)
787 set_property(TARGET cephfs APPEND_STRING PROPERTY
788 LINK_FLAGS " -Wl,--exclude-libs,lib${name}.a")
792 install(TARGETS cephfs DESTINATION ${CMAKE_INSTALL_LIBDIR})
794 "${CMAKE_SOURCE_DIR}/src/include/cephfs"
795 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
798 client/SyntheticClient.cc)
799 add_executable(ceph-syn ${ceph_syn_srcs})
800 target_link_libraries(ceph-syn client global-static ceph-common)
801 install(TARGETS ceph-syn DESTINATION bin)
803 add_subdirectory(mount)
805 endif(WITH_LIBCEPHFS)
807 if(WITH_LIBCEPHSQLITE)
808 set(cephsqlite_srcs libcephsqlite.cc SimpleRADOSStriper.cc)
809 add_library(cephsqlite ${CEPH_SHARED} ${cephsqlite_srcs})
810 target_link_libraries(cephsqlite PRIVATE cls_lock_client librados ceph-common SQLite3::SQLite3 ${EXTRALIBS})
811 set_target_properties(cephsqlite PROPERTIES
812 CXX_VISIBILITY_PRESET hidden
813 VISIBILITY_INLINES_HIDDEN ON)
814 if(NOT APPLE AND NOT WIN32)
815 set_property(TARGET cephsqlite APPEND_STRING PROPERTY
816 LINK_FLAGS " -Wl,--exclude-libs,ALL")
818 install(TARGETS cephsqlite DESTINATION ${CMAKE_INSTALL_LIBDIR})
819 endif(WITH_LIBCEPHSQLITE)
825 add_executable(ceph-fuse ${ceph_fuse_srcs})
826 target_link_libraries(ceph-fuse FUSE::FUSE
827 ${GSSAPI_LIBRARIES} client ceph-common global-static ${EXTRALIBS})
828 set_target_properties(ceph-fuse PROPERTIES
829 POSITION_INDEPENDENT_CODE ${EXE_LINKER_USE_PIE})
830 install(TARGETS ceph-fuse DESTINATION bin)
831 install(PROGRAMS mount.fuse.ceph DESTINATION ${CMAKE_INSTALL_SBINDIR})
835 add_subdirectory(dokan)
838 add_subdirectory(journal)
842 add_library(krbd STATIC krbd.cc
843 $<TARGET_OBJECTS:parse_secret_objs>)
844 target_link_libraries(krbd keyutils::keyutils)
846 add_subdirectory(librbd)
848 add_subdirectory(rbd_fuse)
852 ${CMAKE_SOURCE_DIR}/src/ceph-rbdnamer
853 ${CMAKE_SOURCE_DIR}/src/rbd-replay-many
854 ${CMAKE_SOURCE_DIR}/src/rbdmap
855 DESTINATION ${CMAKE_INSTALL_BINDIR})
856 add_subdirectory(rbd_replay)
859 set(SPAWN_BUILD_TESTS OFF CACHE INTERNAL "disable building of spawn unit tests")
860 set(SPAWN_INSTALL OFF CACHE INTERNAL "disable installation of spawn headers")
861 add_subdirectory(spawn)
865 add_subdirectory(key_value_store)
869 add_subdirectory(libkmip)
871 set(civetweb_common_files civetweb/src/civetweb.c)
872 add_library(civetweb_common_objs OBJECT ${civetweb_common_files})
873 target_include_directories(civetweb_common_objs SYSTEM PRIVATE
874 "${CMAKE_SOURCE_DIR}/src/civetweb/include")
875 set_property(TARGET civetweb_common_objs
876 APPEND PROPERTY COMPILE_DEFINITIONS USE_IPV6=1)
878 set_property(TARGET civetweb_common_objs
879 APPEND PROPERTY COMPILE_DEFINITIONS SSL_LIB="${LIBSSL_SONAME}")
880 set_property(TARGET civetweb_common_objs
881 APPEND PROPERTY COMPILE_DEFINITIONS CRYPTO_LIB="${LIBCRYPTO_SONAME}")
885 # Use cmake to determine openssl version, a TODO is to make
886 # civetweb itself do this based on openssl_api_compat strings
887 if (NOT (OPENSSL_VERSION VERSION_LESS "1.1"))
888 message(STATUS "Setting civetweb to use OPENSSL >= 1.1")
889 set_property(TARGET civetweb_common_objs
890 APPEND PROPERTY COMPILE_DEFINITIONS OPENSSL_API_1_1=1)
893 add_subdirectory(rgw)
899 DESTINATION ${CMAKE_INSTALL_DOCDIR})
901 # Now create a usable config.h
903 ${CMAKE_SOURCE_DIR}/src/include/config-h.in.cmake
904 ${CMAKE_BINARY_DIR}/include/acconfig.h
908 # Everything you need to spin up a cluster with vstart.sh
909 add_custom_target(vstart-base DEPENDS
919 add_dependencies(vstart-base ceph-mgr)
922 add_custom_target(vstart DEPENDS vstart-base)
924 add_dependencies(vstart cython_rbd)
927 add_dependencies(vstart ceph-mds cephfs cython_cephfs)
930 add_dependencies(vstart radosgwd radosgw-admin)
934 add_dependencies(vstart tracepoint_libraries)
937 if(WITH_MGR AND WITH_MGR_DASHBOARD_FRONTEND AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64")
938 add_dependencies(vstart mgr-dashboard-frontend-build)
942 add_dependencies(vstart ceph-volume-venv-setup)
946 # Everything you need to run CephFS tests
947 add_custom_target(cephfs_testing DEPENDS
956 cephfs-meta-injection
960 if (IS_DIRECTORY "${PROJECT_SOURCE_DIR}/.git")
963 COMMAND git submodule sync
964 COMMAND git submodule update --force --init --recursive
965 WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
968 add_subdirectory(script)
971 find_package(Doxygen)
973 set(DOXYGEN_FILE_PATTERNS *.cc *.c *.cpp *.C *.cxx *.c++ *.CC *.H *.h *.hh *.hpp)
974 set(DOXYGEN_SOURCE_BROWSER YES)
975 set(DOXYGEN_WARN_IF_UNDOCUMENTED NO)
976 # enabling clang slows down doxygen significantly
977 set(DOXYGEN_CLANG_ASSISTED_PARSING NO)
978 set(DOXYGEN_CLANG_DATABASE_PATH "${PROJECT_BINARY_DIR}")
979 set(DOXYGEN_BUILTIN_STL_SUPPORT YES)
980 set(DOXYGEN_RECURSIVE YES)
981 set(DOXYGEN_QUIET YES)
982 set(DOXYGEN_GENERATE_LATEX NO)
983 set(DOXYGEN_GENERATE_XML NO)
984 set(DOXYGEN_GENERATE_HTML YES)
985 set(DOXYGEN_PROJECT_NAME Ceph)
986 set(DOXYGEN_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/build-doc/doxygen")
987 set(DOXYGEN_STRIP_FROM_PATH "src/")
988 set(DOXYGEN_STRIP_FROM_INC_PATH "src/include")
989 set(DOXYGEN_JAVADOC_AUTOBRIEF YES)
990 set(DOXYGEN_HAVE_DOT NO)
991 set(DOXYGEN_VERBATIM_HEADERS YES)
992 doxygen_add_docs(doxygen
1027 COMMENT "Generate C++ documentation")