]> git.proxmox.com Git - ceph.git/blob - ceph/src/CMakeLists.txt
c779c8521ff1271df36da06f77b95992960ef17b
[ceph.git] / ceph / src / CMakeLists.txt
1 include(GetGitRevisionDescription)
2 include(CheckCXXCompilerFlag)
3
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})
7 # for mgr plugins
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}")
13 endif()
14
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})
24
25 configure_file(${CMAKE_SOURCE_DIR}/src/init-ceph.in
26 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/init-ceph @ONLY)
27
28 configure_file(ceph-post-file.in
29 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-post-file @ONLY)
30
31 configure_file(ceph-crash.in
32 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-crash @ONLY)
33
34 # the src/.git_version file may be written out by make-dist; otherwise
35 # we pull the git version from .git
36 option(ENABLE_GIT_VERSION "build Ceph with git version string" ON)
37 if(ENABLE_GIT_VERSION)
38 get_git_head_revision(GIT_REFSPEC CEPH_GIT_VER)
39 git_describe(CEPH_GIT_NICE_VER_WITH_V --always)
40 # remove leading 'v'
41 string(SUBSTRING ${CEPH_GIT_NICE_VER_WITH_V} 1 -1 CEPH_GIT_NICE_VER)
42 #if building from a source tarball via make-dist
43 if(${CEPH_GIT_VER} STREQUAL "GITDIR-NOTFOUND")
44 message(STATUS "Ceph/.git directory not found, parsing ${CMAKE_CURRENT_SOURCE_DIR}/.git_version for CEPH_GIT_VER and CEPH_GIT_NICE_VER")
45 file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/.git_version CEPH_GIT_SHA_AND_TAG)
46 list(GET CEPH_GIT_SHA_AND_TAG 0 CEPH_GIT_VER)
47 list(GET CEPH_GIT_SHA_AND_TAG 1 CEPH_GIT_NICE_VER)
48 endif(${CEPH_GIT_VER} STREQUAL "GITDIR-NOTFOUND")
49 else(ENABLE_GIT_VERSION)
50 set(CEPH_GIT_VER "no_version")
51 set(CEPH_GIT_NICE_VER "Development")
52 endif(ENABLE_GIT_VERSION)
53
54 # the src/ceph_release file is 3 lines,
55 # <release number, e.g. '12' for luminous>
56 # <release name, e.g. 'luminous'>
57 # <release type: 'dev' for x.0.z, 'rc' or x.1.z, or 'stable' or x.2.z>
58 # note that the release name is semi-redundant and must match CEPH_RELEASE_*
59 # definitions in include/rados.h and common/ceph_strings.c.
60 file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/ceph_release CEPH_RELEASE_FILE)
61 list(GET CEPH_RELEASE_FILE 0 CEPH_RELEASE)
62 list(GET CEPH_RELEASE_FILE 1 CEPH_RELEASE_NAME)
63 list(GET CEPH_RELEASE_FILE 2 CEPH_RELEASE_TYPE)
64
65 configure_file(${CMAKE_SOURCE_DIR}/src/ceph.in
66 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph @ONLY)
67
68 # Common infrastructure
69 configure_file(
70 ${CMAKE_SOURCE_DIR}/src/ceph_ver.h.in.cmake
71 ${CMAKE_BINARY_DIR}/src/include/ceph_ver.h
72 @ONLY)
73
74 add_definitions(
75 -DHAVE_CONFIG_H
76 -D__CEPH__
77 -D_REENTRANT
78 -D_THREAD_SAFE
79 -D__STDC_FORMAT_MACROS
80 -D_FILE_OFFSET_BITS=64
81 -DBOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION)
82 if(Boost_VERSION VERSION_GREATER_EQUAL 1.74)
83 add_definitions(-DBOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
84 endif()
85
86 if(LINUX)
87 add_definitions("-D_GNU_SOURCE")
88 endif()
89
90 add_compile_options(
91 -Wall
92 -fno-strict-aliasing
93 -fsigned-char)
94
95 if(NOT MSVC)
96 add_compile_options(
97 -Wtype-limits
98 -Wignored-qualifiers
99 -Wpointer-arith
100 -Werror=format-security
101 -Winit-self
102 -Wno-unknown-pragmas)
103 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wnon-virtual-dtor>)
104 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-ignored-qualifiers>)
105 endif()
106
107 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-ftemplate-depth-1024>)
108
109 CHECK_CXX_COMPILER_FLAG("-Wpessimizing-move" COMPILER_SUPPORTS_PESSIMIZING_MOVE)
110 if(COMPILER_SUPPORTS_PESSIMIZING_MOVE)
111 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wpessimizing-move>)
112 endif()
113 CHECK_CXX_COMPILER_FLAG("-Wredundant-move" COMPILER_SUPPORTS_REDUNDANT_MOVE)
114 if(COMPILER_SUPPORTS_REDUNDANT_MOVE)
115 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wredundant-move>)
116 endif()
117 if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
118 if(MINGW)
119 # The MINGW headers are missing some "const" qualifiers.
120 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fpermissive>)
121 else()
122 string(APPEND CMAKE_EXE_LINKER_FLAGS " -rdynamic")
123 endif()
124 string(APPEND CMAKE_CXX_FLAGS_DEBUG " -Og")
125 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wstrict-null-sentinel>)
126 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Woverloaded-virtual>)
127 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-new-ttp-matching>)
128 # cmake does not add '-pie' for executables even if
129 # CMAKE_POSITION_INDEPENDENT_CODE is TRUE.
130 if(EXE_LINKER_USE_PIE)
131 if (NOT WITH_OSD_INSTRUMENT_FUNCTIONS AND NOT HAVE_SEASTAR)
132 string(APPEND CMAKE_EXE_LINKER_FLAGS " -pie")
133 endif()
134 endif()
135 elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
136 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_EXPORTS_C_FLAG}")
137 string(APPEND CMAKE_LINKER_FLAGS " -rdynamic -export-dynamic ${CMAKE_EXE_EXPORTS_C_FLAG}")
138 string(APPEND CMAKE_CXX_FLAGS_DEBUG " -g")
139 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-inconsistent-missing-override>)
140 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-mismatched-tags>)
141 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-unused-private-field>)
142 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-address-of-packed-member>)
143 add_compile_options(
144 -Wno-unused-function
145 -Wno-unused-local-typedef
146 -Wno-varargs
147 -Wno-gnu-designator
148 -Wno-missing-braces
149 -Wno-parentheses
150 -Wno-deprecated-register)
151 if(FREEBSD)
152 # Need to use the GNU binutils linker to get versioning right.
153 string(APPEND CMAKE_EXE_LINKER_FLAGS " -fuse-ld=/usr/local/bin/ld -Wno-unused-command-line-argument")
154 string(APPEND CMAKE_SHARED_LINKER_FLAGS " -fuse-ld=/usr/local/bin/ld -Wno-unused-command-line-argument")
155 endif()
156 if(APPLE)
157 string(APPEND CMAKE_SHARED_LINKER_FLAGS " -undefined dynamic_lookup")
158 endif()
159 endif(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
160
161 if(WITH_CEPH_DEBUG_MUTEX)
162 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-DCEPH_DEBUG_MUTEX>)
163 endif()
164
165 include(CheckCCompilerFlag)
166 if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
167 CHECK_C_COMPILER_FLAG("-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2" HAS_FORTIFY_SOURCE)
168 if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
169 if(HAS_FORTIFY_SOURCE)
170 add_definitions(
171 -U_FORTIFY_SOURCE
172 -D_FORTIFY_SOURCE=2)
173 endif()
174 endif()
175 if(NOT WIN32)
176 CHECK_C_COMPILER_FLAG(-fstack-protector-strong HAS_STACK_PROTECT)
177 if (HAS_STACK_PROTECT)
178 add_compile_options(-fstack-protector-strong)
179 endif()
180 endif(NOT WIN32)
181 endif(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
182
183 CHECK_C_COMPILER_FLAG("-D_GLIBCXX_ASSERTIONS" HAS_GLIBCXX_ASSERTIONS)
184 if(HAS_GLIBCXX_ASSERTIONS AND CMAKE_BUILD_TYPE STREQUAL Debug)
185 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-D_GLIBCXX_ASSERTIONS>)
186 endif()
187
188 include(SIMDExt)
189 if(HAVE_INTEL)
190 if(APPLE)
191 set(object_format "macho64")
192 else()
193 set(object_format "elf64")
194 endif()
195 set(CMAKE_ASM_FLAGS "-f ${object_format}")
196 set(CMAKE_ASM_COMPILER ${PROJECT_SOURCE_DIR}/src/nasm-wrapper)
197 if(NOT WIN32)
198 # The native tools might be located even when cross compiling, which
199 # might not work in this case (especially when targeting Windows).
200 include(CheckNasm)
201 check_nasm_support(${object_format}
202 HAVE_NASM_X64
203 HAVE_NASM_X64_AVX2
204 HAVE_NASM_X64_AVX512)
205 endif()
206 endif()
207
208 # require c++17
209 set(CMAKE_CXX_STANDARD 17)
210 set(CMAKE_CXX_EXTENSIONS OFF)
211 set(CMAKE_CXX_STANDARD_REQUIRED ON)
212 set(CMAKE_C_STANDARD 99)
213 # we use `asm()` to inline assembly, so enable the GNU extension
214 set(CMAKE_C_EXTENSIONS ON)
215 set(C_STANDARD_REQUIRED ON)
216
217 include(CheckCXXSourceCompiles)
218 CHECK_CXX_SOURCE_COMPILES("
219 #include <map>
220 using Map = std::map<int, int>;
221 int main() {
222 Map m;
223 m.merge(Map{});
224 }
225 " HAVE_STDLIB_MAP_SPLICING)
226
227 ## Handle diagnostics color if compiler supports them.
228 CHECK_C_COMPILER_FLAG("-fdiagnostics-color=always"
229 COMPILER_SUPPORTS_DIAGNOSTICS_COLOR)
230
231 set(DIAGNOSTICS_COLOR "auto"
232 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.")
233
234 if(COMPILER_SUPPORTS_DIAGNOSTICS_COLOR)
235 add_compile_options(
236 "$<$<COMPILE_LANGUAGE:C>:-fdiagnostics-color=${DIAGNOSTICS_COLOR}>"
237 "$<$<COMPILE_LANGUAGE:CXX>:-fdiagnostics-color=${DIAGNOSTICS_COLOR}>")
238 endif()
239
240 set(EXTRALIBS ${CMAKE_DL_LIBS})
241 if(HAVE_POSIX_TIMERS)
242 list(APPEND EXTRALIBS ${RT_LIBRARY})
243 endif()
244 if(LINUX OR APPLE)
245 set(LIB_RESOLV resolv)
246 list(APPEND EXTRALIBS ${LIB_RESOLV})
247 endif()
248
249 if(${ENABLE_COVERAGE})
250 find_program(HAVE_GCOV gcov)
251 if(NOT HAVE_GCOV)
252 message(FATAL_ERROR "Coverage Enabled but gcov Not Found")
253 endif()
254 add_compile_options(
255 -fprofile-arcs
256 -ftest-coverage
257 -O0)
258 list(APPEND EXTRALIBS gcov)
259 endif(${ENABLE_COVERAGE})
260
261 if(WITH_TESTS)
262 set(GCOV_PREFIX_STRIP 4)
263 configure_file(${CMAKE_SOURCE_DIR}/src/ceph-coverage.in
264 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-coverage @ONLY)
265 configure_file(${CMAKE_SOURCE_DIR}/src/ceph-debugpack.in
266 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-debugpack @ONLY)
267 endif()
268
269 option(WITH_OCF "build OCF-compliant cluster resource agent" OFF)
270 if(WITH_OCF)
271 add_subdirectory(ocf)
272 endif()
273
274 option(WITH_CEPHFS_JAVA "build libcephfs Java bindings" OFF)
275 if(WITH_CEPHFS_JAVA)
276 add_subdirectory(java)
277 endif()
278
279 # sort out which allocator to use
280 if(ALLOCATOR STREQUAL "tcmalloc")
281 set(ALLOC_LIBS gperftools::tcmalloc)
282 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-malloc>)
283 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-calloc>)
284 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-realloc>)
285 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-free>)
286 elseif(ALLOCATOR STREQUAL "tcmalloc_minimal")
287 set(ALLOC_LIBS gperftools::tcmalloc_minimal)
288 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-malloc>)
289 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-calloc>)
290 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-realloc>)
291 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-free>)
292 elseif(ALLOCATOR STREQUAL "jemalloc")
293 set(ALLOC_LIBS JeMalloc::JeMalloc)
294 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-malloc>)
295 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-calloc>)
296 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-realloc>)
297 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-free>)
298 endif()
299
300 if (WITH_BLKIN)
301 add_subdirectory(blkin/blkin-lib)
302 endif(WITH_BLKIN)
303
304 set(mds_files)
305 list(APPEND mds_files
306 mds/MDSMap.cc
307 mds/FSMap.cc
308 mds/FSMapUser.cc
309 mds/inode_backtrace.cc
310 mds/mdstypes.cc
311 mds/flock.cc
312 mds/cephfs_features.cc)
313
314 add_subdirectory(json_spirit)
315
316 include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/src/xxHash")
317 include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/src/rapidjson/include")
318
319 option(WITH_FMT_HEADER_ONLY "use header-only version of fmt library" OFF)
320 find_package(fmt 6.0.0 QUIET)
321 if(fmt_FOUND)
322 include_directories(SYSTEM "${fmt_INCLUDE_DIR}")
323 else()
324 message(STATUS "Could not find fmt, will build it")
325 set(old_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
326 set(BUILD_SHARED_LIBS FALSE)
327 add_subdirectory(fmt)
328 set(BUILD_SHARED_LIBS ${old_BUILD_SHARED_LIBS})
329 unset(old_BUILD_SHARED_LIBS)
330 include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/src/fmt/include")
331 endif()
332
333 # in osd/PeeringState.h, the number of elements in PeeringState::Active::reactions
334 # is now 21 which exceeds the default value of BOOST_MPL_LIMIT_VECTOR_SIZE, which
335 # is 20. so we need to override it. see
336 # https://www.boost.org/doc/libs/1_74_0/libs/mpl/doc/refmanual/limit-list-size.html
337 # link with this library, if your code includes osd/PeeringState.h (indirectly)
338 add_library(Boost::MPL INTERFACE IMPORTED)
339 set_target_properties(Boost::MPL PROPERTIES
340 INTERFACE_COMPILE_DEFINITIONS
341 "BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS;BOOST_MPL_LIMIT_LIST_SIZE=30")
342
343 if(WITH_SEASTAR)
344 find_package(c-ares 1.13.0 QUIET)
345 if(NOT c-ares_FOUND)
346 message(STATUS "Could not find c-ares, will build it")
347 include(Buildc-ares)
348 build_c_ares()
349 endif()
350 macro(find_package name)
351 if(NOT TARGET ${name})
352 _find_package(${ARGV})
353 endif()
354 endmacro ()
355 set(Seastar_API_LEVEL "6" CACHE STRING "" FORCE)
356 set(Seastar_HWLOC OFF CACHE BOOL "" FORCE)
357 set(Seastar_STD_OPTIONAL_VARIANT_STRINGVIEW ON CACHE BOOL "" FORCE)
358 if(Seastar_DPDK)
359 find_package(dpdk QUIET)
360 if(NOT DPDK_FOUND)
361 include(BuildDPDK)
362 build_dpdk(${CMAKE_BINARY_DIR}/src/dpdk)
363 endif()
364 endif()
365 list(APPEND Seastar_CXX_FLAGS
366 "-Wno-error"
367 "-Wno-sign-compare"
368 "-Wno-attributes"
369 "-Wno-pessimizing-move"
370 "-Wno-address-of-packed-member"
371 "-Wno-non-virtual-dtor")
372 set(Seastar_CXX_FLAGS "${Seastar_CXX_FLAGS}" CACHE STRING "" FORCE)
373 add_subdirectory(seastar)
374 # create the directory so cmake won't complain when looking at the imported
375 # target: Seastar exports this directory created at build-time
376 file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/seastar/gen/include")
377 add_subdirectory(crimson)
378 endif()
379
380 include(CheckTypeSize)
381 set(CMAKE_EXTRA_INCLUDE_FILES "sys/time.h")
382 CHECK_TYPE_SIZE(suseconds_t SUSECONDS_T)
383 unset(CMAKE_EXTRA_INCLUDE_FILES)
384
385 set(libcommon_files
386 ${CMAKE_BINARY_DIR}/src/include/ceph_ver.h
387 ceph_ver.c
388 global/global_context.cc
389 xxHash/xxhash.c
390 common/error_code.cc
391 common/tracer.cc
392 log/Log.cc
393 mon/MonCap.cc
394 mon/MonClient.cc
395 mon/MonMap.cc
396 mon/MonSub.cc
397 mon/error_code.cc
398 mgr/MgrClient.cc
399 mon/PGMap.cc
400 mgr/ServiceMap.cc
401 osd/ECMsgTypes.cc
402 osd/HitSet.cc
403 osd/OSDMap.cc
404 osd/OSDMapMapping.cc
405 osd/osd_types.cc
406 osd/error_code.cc
407 osd/PGPeeringEvent.cc
408 osd/OpRequest.cc
409 osd/ClassHandler.cc
410 osd/osd_op_util.cc
411 osdc/Striper.cc
412 osdc/Objecter.cc
413 osdc/error_code.cc
414 librbd/Features.cc
415 librbd/io/IoOperations.cc
416 ${mds_files})
417
418 set_source_files_properties(ceph_ver.c
419 APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_BINARY_DIR}/src/include/ceph_ver.h)
420 add_library(common-objs OBJECT ${libcommon_files})
421 target_compile_definitions(common-objs PRIVATE
422 $<TARGET_PROPERTY:fmt::fmt,INTERFACE_COMPILE_DEFINITIONS>)
423 add_dependencies(common-objs legacy-option-headers)
424
425 if(WITH_JAEGER)
426 find_package(thrift 0.13.0 REQUIRED)
427 include(BuildOpentelemetry)
428 build_opentelemetry()
429 set(jaeger_base opentelemetry::libopentelemetry thrift::libthrift)
430 add_dependencies(common-objs ${jaeger_base})
431 target_link_libraries(common-objs ${jaeger_base})
432 endif()
433
434 CHECK_C_COMPILER_FLAG("-fvar-tracking-assignments" HAS_VTA)
435 add_subdirectory(auth)
436 add_subdirectory(common)
437 add_subdirectory(crush)
438 add_subdirectory(msg)
439 add_subdirectory(arch)
440
441 set(ceph_common_objs
442 $<TARGET_OBJECTS:common-auth-objs>
443 $<TARGET_OBJECTS:common-common-objs>
444 $<TARGET_OBJECTS:common-options-objs>
445 $<TARGET_OBJECTS:common-msg-objs>
446 $<TARGET_OBJECTS:common_buffer_obj>
447 $<TARGET_OBJECTS:common_texttable_obj>
448 $<TARGET_OBJECTS:compressor_objs>
449 $<TARGET_OBJECTS:common-objs>
450 $<TARGET_OBJECTS:common_mountcephfs_objs>
451 $<TARGET_OBJECTS:crush_objs>)
452 set(ceph_common_deps
453 json_spirit erasure_code arch crc32
454 ${LIB_RESOLV}
455 Boost::thread
456 Boost::system
457 Boost::random
458 Boost::program_options
459 Boost::date_time
460 Boost::iostreams
461 StdFilesystem::filesystem
462 fmt::fmt
463 ${BLKID_LIBRARIES}
464 ${Backtrace_LIBRARIES}
465 ${BLKIN_LIBRARIES}
466 ${CRYPTO_LIBS}
467 ${GSSAPI_LIBRARIES}
468 ${CMAKE_THREAD_LIBS_INIT}
469 ${CMAKE_DL_LIBS})
470 if(HAVE_UDEV)
471 list(APPEND ceph_common_deps ${UDEV_LIBRARIES})
472 endif()
473
474 if(HAVE_VERBS)
475 list(APPEND ceph_common_deps IBVerbs::verbs)
476 endif()
477
478 if(HAVE_RDMACM)
479 list(APPEND ceph_common_deps RDMA::RDMAcm)
480 endif()
481
482 if(NOT WITH_SYSTEM_BOOST)
483 list(APPEND ceph_common_deps ${ZLIB_LIBRARIES})
484 endif()
485
486 if(HAVE_QATZIP)
487 list(APPEND ceph_common_deps ${qatzip_LIBRARIES})
488 endif()
489
490 if(WITH_DPDK)
491 list(APPEND ceph_common_deps common_async_dpdk)
492 endif()
493
494 if(WITH_JAEGER)
495 list(APPEND ceph_common_deps ${jaeger_base})
496 endif()
497
498 if(WIN32)
499 list(APPEND ceph_common_deps ws2_32 mswsock iphlpapi bcrypt)
500 list(APPEND ceph_common_deps dlfcn_win32)
501 endif()
502
503 if(WITH_BLUESTORE_PMEM OR WITH_RBD_RWL)
504 if(WITH_SYSTEM_PMDK)
505 set(pmem_COMPONENTS)
506 if(WITH_BLUESTORE_PMEM)
507 list(APPEND pmem_COMPONENTS pmem)
508 endif()
509 if(WITH_RBD_RWL)
510 list(APPEND pmem_COMPONENTS pmemobj)
511 endif()
512 find_package(pmem 1.10 REQUIRED COMPONENTS ${pmem_COMPONENTS})
513 else()
514 include(Buildpmem)
515 build_pmem()
516 endif()
517 endif()
518
519 add_library(common STATIC ${ceph_common_objs})
520 target_link_libraries(common ${ceph_common_deps})
521 add_dependencies(common legacy-option-headers ${jaeger_base})
522
523 add_library(ceph-common SHARED ${ceph_common_objs})
524 target_link_libraries(ceph-common ${ceph_common_deps})
525 add_dependencies(ceph-common legacy-option-headers ${jaeger_base})
526 # appease dpkg-shlibdeps
527 set_target_properties(ceph-common PROPERTIES
528 SOVERSION 2
529 SKIP_RPATH TRUE)
530 if(NOT APPLE AND NOT FREEBSD)
531 # Apple uses Mach-O, not ELF. so this option does not apply to APPLE.
532 #
533 # prefer the local symbol definitions when binding references to global
534 # symbols. otherwise we could reference the symbols defined by the application
535 # with the same name, instead of using the one defined in libceph-common.
536 # in other words, we require libceph-common to use local symbols, even if redefined
537 # in application".
538 set_property(
539 TARGET ceph-common
540 APPEND APPEND_STRING
541 PROPERTY LINK_FLAGS "-Wl,-Bsymbolic -Wl,-Bsymbolic-functions")
542 endif()
543
544 if(MINGW)
545 install(
546 TARGETS ceph-common
547 RUNTIME
548 DESTINATION ${CEPH_INSTALL_PKGLIBDIR})
549 else()
550 install(
551 TARGETS ceph-common
552 LIBRARY
553 DESTINATION ${CEPH_INSTALL_PKGLIBDIR}
554 NAMELINK_SKIP)
555 endif()
556
557 if(${WITH_LTTNG})
558 add_subdirectory(tracing)
559 add_dependencies(common-objs oprequest-tp)
560 endif(${WITH_LTTNG})
561
562 add_subdirectory(global)
563
564 # RGW also support Lua scripting
565 if(WITH_CEPHFS OR WITH_RADOSGW)
566 find_package(Lua 5.3 REQUIRED)
567 endif()
568
569 # rados object classes
570 add_subdirectory(cls)
571
572 # RADOS client/library
573 add_subdirectory(osdc)
574
575 # heal_profiler
576 add_subdirectory(perfglue)
577
578 add_library(rados_snap_set_diff_obj OBJECT librados/snap_set_diff.cc)
579
580 option(WITH_LIBRADOSSTRIPER "build with libradosstriper support" ON)
581
582 add_subdirectory(include)
583 add_subdirectory(librados)
584 add_subdirectory(neorados)
585
586 if(WITH_LIBRADOSSTRIPER)
587 add_subdirectory(libradosstriper)
588 endif()
589
590 # make rocksdb statically
591
592 if(NOT WITH_SYSTEM_ROCKSDB)
593 include(BuildRocksDB)
594 build_rocksdb()
595 endif(NOT WITH_SYSTEM_ROCKSDB)
596
597 if(WITH_MGR)
598 add_subdirectory(mgr)
599 add_subdirectory(exporter)
600 endif()
601
602 set(librados_config_srcs
603 librados-config.cc)
604 add_executable(librados-config ${librados_config_srcs})
605 target_link_libraries(librados-config librados Boost::program_options)
606
607 install(TARGETS librados-config DESTINATION bin)
608
609 # virtualenv base directory for ceph-disk and ceph-detect-init
610 set(CEPH_BUILD_VIRTUALENV $ENV{TMPDIR})
611 if(NOT CEPH_BUILD_VIRTUALENV)
612 set(CEPH_BUILD_VIRTUALENV ${CMAKE_BINARY_DIR})
613 endif()
614
615 if(NOT WIN32)
616 add_subdirectory(pybind)
617 add_subdirectory(ceph-volume)
618 add_subdirectory(python-common)
619 add_subdirectory(cephadm)
620 endif(NOT WIN32)
621
622 # Monitor
623 add_subdirectory(mon)
624 set(ceph_mon_srcs
625 ceph_mon.cc)
626 add_executable(ceph-mon ${ceph_mon_srcs}
627 $<TARGET_OBJECTS:common_texttable_obj>)
628 add_dependencies(ceph-mon erasure_code_plugins)
629 target_link_libraries(ceph-mon mon os global-static ceph-common
630 ${EXTRALIBS}
631 ${CMAKE_DL_LIBS} ${GSSAPI_LIBRARIES})
632 install(TARGETS ceph-mon DESTINATION bin)
633
634 # OSD/ObjectStore
635
636 include(TestBigEndian)
637 test_big_endian(CEPH_BIG_ENDIAN)
638 if(NOT CEPH_BIG_ENDIAN)
639 set(CEPH_LITTLE_ENDIAN 1)
640 endif()
641
642 add_subdirectory(kv)
643 add_subdirectory(os)
644
645 if(NOT WIN32)
646 add_subdirectory(blk)
647 add_subdirectory(osd)
648
649 set(ceph_osd_srcs
650 # Link the Object Class API implementation directly as intermediary
651 # static library (like libosd.a) nullifies the effect of `-rdynamic`.
652 osd/objclass.cc
653 objclass/class_api.cc
654 ceph_osd.cc)
655
656 add_executable(ceph-osd ${ceph_osd_srcs})
657 add_dependencies(ceph-osd erasure_code_plugins)
658 target_link_libraries(ceph-osd osd os global-static common
659 ${BLKID_LIBRARIES})
660 if(WITH_FUSE)
661 target_link_libraries(ceph-osd FUSE::FUSE)
662 endif()
663 set_target_properties(ceph-osd PROPERTIES
664 POSITION_INDEPENDENT_CODE ${EXE_LINKER_USE_PIE}
665 INSTALL_RPATH "")
666 install(TARGETS ceph-osd DESTINATION bin)
667
668 endif(NOT WIN32)
669
670 if (WITH_CEPHFS)
671 add_subdirectory(mds)
672 set(ceph_mds_srcs
673 ceph_mds.cc)
674 add_executable(ceph-mds ${ceph_mds_srcs})
675 target_link_libraries(ceph-mds mds ${CMAKE_DL_LIBS} global-static ceph-common
676 Boost::thread)
677 install(TARGETS ceph-mds DESTINATION bin)
678 endif()
679
680 add_subdirectory(erasure-code)
681
682 # Support/Tools
683 if(WITH_TESTS)
684 option(WITH_SYSTEM_GTEST "require and build with system gtest and gmock" OFF)
685 if(WITH_SYSTEM_GTEST)
686 find_package(GTest REQUIRED)
687 find_package(GMock REQUIRED)
688 else()
689 set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
690 add_subdirectory(googletest)
691 add_library(GMock::GMock ALIAS gmock)
692 add_library(GMock::Main ALIAS gmock_main)
693 target_include_directories(gmock INTERFACE
694 $<TARGET_PROPERTY:gtest,INTERFACE_INCLUDE_DIRECTORIES>)
695 target_include_directories(gmock_main INTERFACE
696 $<TARGET_PROPERTY:gtest,INTERFACE_INCLUDE_DIRECTORIES>)
697 add_library(GTest::GTest ALIAS gtest)
698 add_library(GTest::Main ALIAS gtest_main)
699 endif()
700 endif(WITH_TESTS)
701
702 # dmClock (after gmock)
703 option(WITH_DMCLOCK_TESTS
704 "enable the build of dmclock-tests and dmclock-data-struct tests binaries"
705 OFF)
706 if(WITH_TESTS AND WITH_DMCLOCK_TESTS)
707 # note: add_test is not being called, so dmclock tests aren't part
708 # of ceph tests
709 set(dmclock_TEST ON CACHE BOOL "" FORCE)
710 endif()
711 add_subdirectory(dmclock)
712
713 add_subdirectory(compressor)
714
715 add_subdirectory(tools)
716
717 if(WITH_TESTS)
718 add_subdirectory(test)
719 endif()
720
721 add_subdirectory(crypto)
722
723 if(WITH_TESTS)
724 install(PROGRAMS
725 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-debugpack
726 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-coverage
727 DESTINATION bin)
728 endif()
729
730 install(PROGRAMS
731 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph
732 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-post-file
733 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-crash
734 ceph-run
735 ceph-clsinfo
736 DESTINATION bin)
737 install(PROGRAMS
738 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/init-ceph
739 DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/init.d
740 RENAME ceph)
741
742 install(FILES
743 ${CMAKE_SOURCE_DIR}/share/id_rsa_drop.ceph.com
744 ${CMAKE_SOURCE_DIR}/share/id_rsa_drop.ceph.com.pub
745 ${CMAKE_SOURCE_DIR}/share/known_hosts_drop.ceph.com
746 DESTINATION ${CMAKE_INSTALL_DATADIR}/ceph)
747
748 install(PROGRAMS
749 ceph_common.sh
750 ceph-osd-prestart.sh
751 DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/ceph)
752
753 install(PROGRAMS
754 ceph-create-keys
755 DESTINATION sbin)
756
757 add_subdirectory(bash_completion)
758 add_subdirectory(client)
759
760 if(WITH_LIBCEPHFS)
761 set(libcephfs_srcs libcephfs.cc)
762 add_library(cephfs ${CEPH_SHARED} ${libcephfs_srcs})
763 target_link_libraries(cephfs PRIVATE client ceph-common
764 ${CRYPTO_LIBS} ${EXTRALIBS})
765 if(ENABLE_SHARED)
766 set_target_properties(cephfs PROPERTIES
767 OUTPUT_NAME cephfs
768 VERSION 2.0.0
769 SOVERSION 2)
770 if(NOT APPLE)
771 foreach(name ceph-common client osdc)
772 set_property(TARGET cephfs APPEND_STRING PROPERTY
773 LINK_FLAGS " -Wl,--exclude-libs,lib${name}.a")
774 endforeach()
775 endif()
776 endif(ENABLE_SHARED)
777 install(TARGETS cephfs DESTINATION ${CMAKE_INSTALL_LIBDIR})
778 install(DIRECTORY
779 "include/cephfs"
780 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
781 set(ceph_syn_srcs
782 ceph_syn.cc
783 client/SyntheticClient.cc)
784 add_executable(ceph-syn ${ceph_syn_srcs})
785 target_link_libraries(ceph-syn client global-static ceph-common)
786 install(TARGETS ceph-syn DESTINATION bin)
787 if(LINUX)
788 add_subdirectory(mount)
789 endif()
790 endif(WITH_LIBCEPHFS)
791
792 if(WITH_LIBCEPHSQLITE)
793 set(cephsqlite_srcs libcephsqlite.cc SimpleRADOSStriper.cc)
794 add_library(cephsqlite ${CEPH_SHARED} ${cephsqlite_srcs})
795 target_link_libraries(cephsqlite PRIVATE cls_lock_client librados ceph-common SQLite3::SQLite3 ${EXTRALIBS})
796 set_target_properties(cephsqlite PROPERTIES
797 CXX_VISIBILITY_PRESET hidden
798 VISIBILITY_INLINES_HIDDEN ON)
799 if(NOT APPLE AND NOT WIN32)
800 set_property(TARGET cephsqlite APPEND_STRING PROPERTY
801 LINK_FLAGS " -Wl,--exclude-libs,ALL")
802 endif()
803 install(TARGETS cephsqlite DESTINATION ${CMAKE_INSTALL_LIBDIR})
804 endif(WITH_LIBCEPHSQLITE)
805
806 if(WITH_FUSE)
807 set(ceph_fuse_srcs
808 ceph_fuse.cc
809 client/fuse_ll.cc)
810 add_executable(ceph-fuse ${ceph_fuse_srcs})
811 target_link_libraries(ceph-fuse FUSE::FUSE
812 ${GSSAPI_LIBRARIES} client ceph-common global-static ${EXTRALIBS})
813 set_target_properties(ceph-fuse PROPERTIES
814 POSITION_INDEPENDENT_CODE ${EXE_LINKER_USE_PIE})
815 install(TARGETS ceph-fuse DESTINATION bin)
816 install(PROGRAMS mount.fuse.ceph DESTINATION ${CMAKE_INSTALL_SBINDIR})
817 endif(WITH_FUSE)
818
819 if(WITH_DOKAN)
820 add_subdirectory(dokan)
821 endif(WITH_DOKAN)
822
823 add_subdirectory(journal)
824
825 if(WITH_RBD)
826 if(WITH_KRBD)
827 add_library(krbd STATIC krbd.cc
828 $<TARGET_OBJECTS:parse_secret_objs>)
829 target_link_libraries(krbd keyutils::keyutils)
830 endif()
831 add_subdirectory(librbd)
832 if(WITH_FUSE)
833 add_subdirectory(rbd_fuse)
834 endif()
835
836 install(PROGRAMS
837 ceph-rbdnamer
838 rbd-replay-many
839 rbdmap
840 DESTINATION ${CMAKE_INSTALL_BINDIR})
841 add_subdirectory(rbd_replay)
842 endif(WITH_RBD)
843
844 set(SPAWN_BUILD_TESTS OFF CACHE INTERNAL "disable building of spawn unit tests")
845 set(SPAWN_INSTALL OFF CACHE INTERNAL "disable installation of spawn headers")
846 add_subdirectory(spawn)
847
848 # RadosGW
849 if(WITH_KVS)
850 add_subdirectory(key_value_store)
851 endif(WITH_KVS)
852
853 if(WITH_RADOSGW)
854 if(WITH_RADOSGW_SELECT_PARQUET)
855 if(WITH_SYSTEM_ARROW)
856 find_package(Arrow 4 REQUIRED QUIET)
857 find_package(Parquet 4 REQUIRED QUIET)
858 else()
859 # find arrow's dependencies
860 if (WITH_SYSTEM_UTF8PROC)
861 find_package(utf8proc 2.2.0 REQUIRED)
862 else()
863 include(BuildUtf8proc)
864 build_utf8proc()
865 endif()
866 find_package(thrift 0.13 REQUIRED)
867
868 include(BuildArrow)
869 build_arrow()
870 endif()
871 endif()
872
873 add_subdirectory(libkmip)
874 add_subdirectory(rgw)
875 endif(WITH_RADOSGW)
876
877 install(FILES
878 sample.ceph.conf
879 DESTINATION ${CMAKE_INSTALL_DOCDIR})
880
881 # Now create a usable config.h
882 configure_file(
883 ${CMAKE_SOURCE_DIR}/src/include/config-h.in.cmake
884 ${CMAKE_BINARY_DIR}/include/acconfig.h
885 )
886
887 # Everything you need to spin up a cluster with vstart.sh
888 add_custom_target(vstart-base DEPENDS
889 ceph-osd
890 ceph-mon
891 ceph-authtool
892 ceph-conf
893 ceph-exporter
894 monmaptool
895 crushtool
896 rados)
897 if(NOT WIN32)
898 # WIN32 port does not build python bindings
899 # TODO: introduce an option for enabling python binding
900 add_dependencies(vstart-base
901 cython_rados)
902 endif()
903
904 if (WITH_MGR)
905 add_dependencies(vstart-base ceph-mgr)
906 add_dependencies(vstart-base ceph-exporter)
907 endif()
908
909 add_custom_target(vstart DEPENDS vstart-base)
910 if(WITH_RBD AND NOT WIN32)
911 add_dependencies(vstart cython_rbd)
912 endif()
913 if (WITH_CEPHFS)
914 add_dependencies(vstart ceph-mds cephfs cython_cephfs)
915 endif()
916 if(WITH_RADOSGW)
917 add_dependencies(vstart radosgwd radosgw-admin)
918 endif()
919
920 if(WITH_LTTNG)
921 add_dependencies(vstart tracepoint_libraries)
922 endif(WITH_LTTNG)
923
924 if(WITH_MGR AND WITH_MGR_DASHBOARD_FRONTEND AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64")
925 add_dependencies(vstart mgr-dashboard-frontend-build)
926 endif()
927
928 if(WITH_MGR)
929 add_dependencies(vstart ceph-volume-venv-setup)
930 endif()
931
932 # Everything you need to run CephFS tests
933 add_custom_target(cephfs_testing DEPENDS
934 vstart
935 rados
936 cython_modules
937 cephfs
938 cls_cephfs
939 ceph-fuse
940 ceph-dencoder
941 ceph-dencoder-modules
942 cephfs-journal-tool
943 cephfs-meta-injection
944 cephfs-data-scan
945 cephfs-table-tool)
946
947 if (IS_DIRECTORY "${PROJECT_SOURCE_DIR}/.git")
948 add_custom_target(
949 git-update
950 COMMAND git submodule sync
951 COMMAND git submodule update --force --init --recursive
952 WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
953 endif()
954
955 add_subdirectory(script)
956
957 # add doxygen target
958 find_package(Doxygen)
959 if(DOXYGEN_FOUND)
960 set(DOXYGEN_FILE_PATTERNS *.cc *.c *.cpp *.C *.cxx *.c++ *.CC *.H *.h *.hh *.hpp)
961 set(DOXYGEN_SOURCE_BROWSER YES)
962 set(DOXYGEN_WARN_IF_UNDOCUMENTED NO)
963 # enabling clang slows down doxygen significantly
964 set(DOXYGEN_CLANG_ASSISTED_PARSING NO)
965 set(DOXYGEN_CLANG_DATABASE_PATH "${PROJECT_BINARY_DIR}")
966 set(DOXYGEN_BUILTIN_STL_SUPPORT YES)
967 set(DOXYGEN_RECURSIVE YES)
968 set(DOXYGEN_QUIET YES)
969 set(DOXYGEN_GENERATE_LATEX NO)
970 set(DOXYGEN_GENERATE_XML NO)
971 set(DOXYGEN_GENERATE_HTML YES)
972 set(DOXYGEN_PROJECT_NAME Ceph)
973 set(DOXYGEN_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/build-doc/doxygen")
974 set(DOXYGEN_STRIP_FROM_PATH "src/")
975 set(DOXYGEN_STRIP_FROM_INC_PATH "src/include")
976 set(DOXYGEN_JAVADOC_AUTOBRIEF YES)
977 set(DOXYGEN_HAVE_DOT NO)
978 set(DOXYGEN_VERBATIM_HEADERS YES)
979 doxygen_add_docs(doxygen
980 auth
981 client
982 cls
983 common
984 compressor
985 crimson
986 crush
987 crypto
988 erasure-code
989 global
990 include
991 journal
992 json_spirit
993 key_value_store
994 kv
995 librados
996 libradosstriper
997 librbd
998 log
999 mds
1000 messages
1001 mgr
1002 mon
1003 mount
1004 msg
1005 objclass
1006 objsync
1007 os
1008 osd
1009 osdc
1010 perfglue
1011 rbd_fuse
1012 rbd_replay
1013 rgw
1014 COMMENT "Generate C++ documentation")
1015 endif()