]> git.proxmox.com Git - ceph.git/blob - ceph/src/CMakeLists.txt
import ceph quincy 17.2.1
[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 endif()
600
601 set(librados_config_srcs
602 librados-config.cc)
603 add_executable(librados-config ${librados_config_srcs})
604 target_link_libraries(librados-config librados Boost::program_options)
605
606 install(TARGETS librados-config DESTINATION bin)
607
608 # virtualenv base directory for ceph-disk and ceph-detect-init
609 set(CEPH_BUILD_VIRTUALENV $ENV{TMPDIR})
610 if(NOT CEPH_BUILD_VIRTUALENV)
611 set(CEPH_BUILD_VIRTUALENV ${CMAKE_BINARY_DIR})
612 endif()
613
614 if(NOT WIN32)
615 add_subdirectory(pybind)
616 add_subdirectory(ceph-volume)
617 add_subdirectory(python-common)
618 add_subdirectory(cephadm)
619 endif(NOT WIN32)
620
621 # Monitor
622 add_subdirectory(mon)
623 set(ceph_mon_srcs
624 ceph_mon.cc)
625 add_executable(ceph-mon ${ceph_mon_srcs}
626 $<TARGET_OBJECTS:common_texttable_obj>)
627 add_dependencies(ceph-mon erasure_code_plugins)
628 target_link_libraries(ceph-mon mon os global-static ceph-common
629 ${EXTRALIBS}
630 ${CMAKE_DL_LIBS} ${GSSAPI_LIBRARIES})
631 install(TARGETS ceph-mon DESTINATION bin)
632
633 # OSD/ObjectStore
634
635 include(TestBigEndian)
636 test_big_endian(CEPH_BIG_ENDIAN)
637 if(NOT CEPH_BIG_ENDIAN)
638 set(CEPH_LITTLE_ENDIAN 1)
639 endif()
640
641 add_subdirectory(kv)
642 add_subdirectory(os)
643
644 if(NOT WIN32)
645 add_subdirectory(blk)
646 add_subdirectory(osd)
647
648 set(ceph_osd_srcs
649 # Link the Object Class API implementation directly as intermediary
650 # static library (like libosd.a) nullifies the effect of `-rdynamic`.
651 osd/objclass.cc
652 objclass/class_api.cc
653 ceph_osd.cc)
654
655 add_executable(ceph-osd ${ceph_osd_srcs})
656 add_dependencies(ceph-osd erasure_code_plugins)
657 target_link_libraries(ceph-osd osd os global-static common
658 ${BLKID_LIBRARIES})
659 if(WITH_FUSE)
660 target_link_libraries(ceph-osd FUSE::FUSE)
661 endif()
662 set_target_properties(ceph-osd PROPERTIES
663 POSITION_INDEPENDENT_CODE ${EXE_LINKER_USE_PIE}
664 INSTALL_RPATH "")
665 install(TARGETS ceph-osd DESTINATION bin)
666
667 endif(NOT WIN32)
668
669 if (WITH_CEPHFS)
670 add_subdirectory(mds)
671 set(ceph_mds_srcs
672 ceph_mds.cc)
673 add_executable(ceph-mds ${ceph_mds_srcs})
674 target_link_libraries(ceph-mds mds ${CMAKE_DL_LIBS} global-static ceph-common
675 Boost::thread)
676 install(TARGETS ceph-mds DESTINATION bin)
677 endif()
678
679 add_subdirectory(erasure-code)
680
681 # Support/Tools
682 if(WITH_TESTS)
683 option(WITH_SYSTEM_GTEST "require and build with system gtest and gmock" OFF)
684 if(WITH_SYSTEM_GTEST)
685 find_package(GTest REQUIRED)
686 find_package(GMock REQUIRED)
687 else()
688 set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
689 add_subdirectory(googletest)
690 add_library(GMock::GMock ALIAS gmock)
691 add_library(GMock::Main ALIAS gmock_main)
692 target_include_directories(gmock INTERFACE
693 $<TARGET_PROPERTY:gtest,INTERFACE_INCLUDE_DIRECTORIES>)
694 target_include_directories(gmock_main INTERFACE
695 $<TARGET_PROPERTY:gtest,INTERFACE_INCLUDE_DIRECTORIES>)
696 add_library(GTest::GTest ALIAS gtest)
697 add_library(GTest::Main ALIAS gtest_main)
698 endif()
699 endif(WITH_TESTS)
700
701 # dmClock (after gmock)
702 option(WITH_DMCLOCK_TESTS
703 "enable the build of dmclock-tests and dmclock-data-struct tests binaries"
704 OFF)
705 if(WITH_TESTS AND WITH_DMCLOCK_TESTS)
706 # note: add_test is not being called, so dmclock tests aren't part
707 # of ceph tests
708 set(dmclock_TEST ON CACHE BOOL "" FORCE)
709 endif()
710 add_subdirectory(dmclock)
711
712 add_subdirectory(compressor)
713
714 add_subdirectory(tools)
715
716 if(WITH_TESTS)
717 add_subdirectory(test)
718 endif()
719
720 add_subdirectory(crypto)
721
722 if(WITH_TESTS)
723 install(PROGRAMS
724 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-debugpack
725 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-coverage
726 DESTINATION bin)
727 endif()
728
729 install(PROGRAMS
730 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph
731 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-post-file
732 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-crash
733 ceph-run
734 ceph-clsinfo
735 DESTINATION bin)
736 install(PROGRAMS
737 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/init-ceph
738 DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/init.d
739 RENAME ceph)
740
741 install(FILES
742 ${CMAKE_SOURCE_DIR}/share/id_rsa_drop.ceph.com
743 ${CMAKE_SOURCE_DIR}/share/id_rsa_drop.ceph.com.pub
744 ${CMAKE_SOURCE_DIR}/share/known_hosts_drop.ceph.com
745 DESTINATION ${CMAKE_INSTALL_DATADIR}/ceph)
746
747 install(PROGRAMS
748 ceph_common.sh
749 ceph-osd-prestart.sh
750 DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/ceph)
751
752 install(PROGRAMS
753 ceph-create-keys
754 DESTINATION sbin)
755
756 add_subdirectory(bash_completion)
757 add_subdirectory(client)
758
759 if(WITH_LIBCEPHFS)
760 set(libcephfs_srcs libcephfs.cc)
761 add_library(cephfs ${CEPH_SHARED} ${libcephfs_srcs})
762 target_link_libraries(cephfs PRIVATE client ceph-common
763 ${CRYPTO_LIBS} ${EXTRALIBS})
764 if(ENABLE_SHARED)
765 set_target_properties(cephfs PROPERTIES
766 OUTPUT_NAME cephfs
767 VERSION 2.0.0
768 SOVERSION 2)
769 if(NOT APPLE)
770 foreach(name ceph-common client osdc)
771 set_property(TARGET cephfs APPEND_STRING PROPERTY
772 LINK_FLAGS " -Wl,--exclude-libs,lib${name}.a")
773 endforeach()
774 endif()
775 endif(ENABLE_SHARED)
776 install(TARGETS cephfs DESTINATION ${CMAKE_INSTALL_LIBDIR})
777 install(DIRECTORY
778 "include/cephfs"
779 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
780 set(ceph_syn_srcs
781 ceph_syn.cc
782 client/SyntheticClient.cc)
783 add_executable(ceph-syn ${ceph_syn_srcs})
784 target_link_libraries(ceph-syn client global-static ceph-common)
785 install(TARGETS ceph-syn DESTINATION bin)
786 if(LINUX)
787 add_subdirectory(mount)
788 endif()
789 endif(WITH_LIBCEPHFS)
790
791 if(WITH_LIBCEPHSQLITE)
792 set(cephsqlite_srcs libcephsqlite.cc SimpleRADOSStriper.cc)
793 add_library(cephsqlite ${CEPH_SHARED} ${cephsqlite_srcs})
794 target_link_libraries(cephsqlite PRIVATE cls_lock_client librados ceph-common SQLite3::SQLite3 ${EXTRALIBS})
795 set_target_properties(cephsqlite PROPERTIES
796 CXX_VISIBILITY_PRESET hidden
797 VISIBILITY_INLINES_HIDDEN ON)
798 if(NOT APPLE AND NOT WIN32)
799 set_property(TARGET cephsqlite APPEND_STRING PROPERTY
800 LINK_FLAGS " -Wl,--exclude-libs,ALL")
801 endif()
802 install(TARGETS cephsqlite DESTINATION ${CMAKE_INSTALL_LIBDIR})
803 endif(WITH_LIBCEPHSQLITE)
804
805 if(WITH_FUSE)
806 set(ceph_fuse_srcs
807 ceph_fuse.cc
808 client/fuse_ll.cc)
809 add_executable(ceph-fuse ${ceph_fuse_srcs})
810 target_link_libraries(ceph-fuse FUSE::FUSE
811 ${GSSAPI_LIBRARIES} client ceph-common global-static ${EXTRALIBS})
812 set_target_properties(ceph-fuse PROPERTIES
813 POSITION_INDEPENDENT_CODE ${EXE_LINKER_USE_PIE})
814 install(TARGETS ceph-fuse DESTINATION bin)
815 install(PROGRAMS mount.fuse.ceph DESTINATION ${CMAKE_INSTALL_SBINDIR})
816 endif(WITH_FUSE)
817
818 if(WITH_DOKAN)
819 add_subdirectory(dokan)
820 endif(WITH_DOKAN)
821
822 add_subdirectory(journal)
823
824 if(WITH_RBD)
825 if(WITH_KRBD)
826 add_library(krbd STATIC krbd.cc
827 $<TARGET_OBJECTS:parse_secret_objs>)
828 target_link_libraries(krbd keyutils::keyutils)
829 endif()
830 add_subdirectory(librbd)
831 if(WITH_FUSE)
832 add_subdirectory(rbd_fuse)
833 endif()
834
835 install(PROGRAMS
836 ceph-rbdnamer
837 rbd-replay-many
838 rbdmap
839 DESTINATION ${CMAKE_INSTALL_BINDIR})
840 add_subdirectory(rbd_replay)
841 endif(WITH_RBD)
842
843 set(SPAWN_BUILD_TESTS OFF CACHE INTERNAL "disable building of spawn unit tests")
844 set(SPAWN_INSTALL OFF CACHE INTERNAL "disable installation of spawn headers")
845 add_subdirectory(spawn)
846
847 # RadosGW
848 if(WITH_KVS)
849 add_subdirectory(key_value_store)
850 endif(WITH_KVS)
851
852 if(WITH_RADOSGW)
853 if(WITH_RADOSGW_SELECT_PARQUET)
854 if(WITH_SYSTEM_ARROW)
855 find_package(Arrow 4 REQUIRED QUIET)
856 find_package(Parquet 4 REQUIRED QUIET)
857 else()
858 # find arrow's dependencies
859 if (WITH_SYSTEM_UTF8PROC)
860 find_package(utf8proc 2.2.0 REQUIRED)
861 else()
862 include(BuildUtf8proc)
863 build_utf8proc()
864 endif()
865 find_package(thrift 0.13 REQUIRED)
866
867 include(BuildArrow)
868 build_arrow()
869 endif()
870 endif()
871
872 add_subdirectory(libkmip)
873 add_subdirectory(rgw)
874 endif(WITH_RADOSGW)
875
876 install(FILES
877 sample.ceph.conf
878 DESTINATION ${CMAKE_INSTALL_DOCDIR})
879
880 # Now create a usable config.h
881 configure_file(
882 ${CMAKE_SOURCE_DIR}/src/include/config-h.in.cmake
883 ${CMAKE_BINARY_DIR}/include/acconfig.h
884 )
885
886 # Everything you need to spin up a cluster with vstart.sh
887 add_custom_target(vstart-base DEPENDS
888 ceph-osd
889 ceph-mon
890 ceph-authtool
891 ceph-conf
892 monmaptool
893 crushtool
894 rados)
895 if(NOT WIN32)
896 # WIN32 port does not build python bindings
897 # TODO: introduce an option for enabling python binding
898 add_dependencies(vstart-base
899 cython_rados)
900 endif()
901
902 if (WITH_MGR)
903 add_dependencies(vstart-base ceph-mgr)
904 endif()
905
906 add_custom_target(vstart DEPENDS vstart-base)
907 if(WITH_RBD AND NOT WIN32)
908 add_dependencies(vstart cython_rbd)
909 endif()
910 if (WITH_CEPHFS)
911 add_dependencies(vstart ceph-mds cephfs cython_cephfs)
912 endif()
913 if(WITH_RADOSGW)
914 add_dependencies(vstart radosgwd radosgw-admin)
915 endif()
916
917 if(WITH_LTTNG)
918 add_dependencies(vstart tracepoint_libraries)
919 endif(WITH_LTTNG)
920
921 if(WITH_MGR AND WITH_MGR_DASHBOARD_FRONTEND AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64")
922 add_dependencies(vstart mgr-dashboard-frontend-build)
923 endif()
924
925 if(WITH_MGR)
926 add_dependencies(vstart ceph-volume-venv-setup)
927 endif()
928
929 # Everything you need to run CephFS tests
930 add_custom_target(cephfs_testing DEPENDS
931 vstart
932 rados
933 cython_modules
934 cephfs
935 cls_cephfs
936 ceph-fuse
937 ceph-dencoder
938 ceph-dencoder-modules
939 cephfs-journal-tool
940 cephfs-meta-injection
941 cephfs-data-scan
942 cephfs-table-tool)
943
944 if (IS_DIRECTORY "${PROJECT_SOURCE_DIR}/.git")
945 add_custom_target(
946 git-update
947 COMMAND git submodule sync
948 COMMAND git submodule update --force --init --recursive
949 WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
950 endif()
951
952 add_subdirectory(script)
953
954 # add doxygen target
955 find_package(Doxygen)
956 if(DOXYGEN_FOUND)
957 set(DOXYGEN_FILE_PATTERNS *.cc *.c *.cpp *.C *.cxx *.c++ *.CC *.H *.h *.hh *.hpp)
958 set(DOXYGEN_SOURCE_BROWSER YES)
959 set(DOXYGEN_WARN_IF_UNDOCUMENTED NO)
960 # enabling clang slows down doxygen significantly
961 set(DOXYGEN_CLANG_ASSISTED_PARSING NO)
962 set(DOXYGEN_CLANG_DATABASE_PATH "${PROJECT_BINARY_DIR}")
963 set(DOXYGEN_BUILTIN_STL_SUPPORT YES)
964 set(DOXYGEN_RECURSIVE YES)
965 set(DOXYGEN_QUIET YES)
966 set(DOXYGEN_GENERATE_LATEX NO)
967 set(DOXYGEN_GENERATE_XML NO)
968 set(DOXYGEN_GENERATE_HTML YES)
969 set(DOXYGEN_PROJECT_NAME Ceph)
970 set(DOXYGEN_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/build-doc/doxygen")
971 set(DOXYGEN_STRIP_FROM_PATH "src/")
972 set(DOXYGEN_STRIP_FROM_INC_PATH "src/include")
973 set(DOXYGEN_JAVADOC_AUTOBRIEF YES)
974 set(DOXYGEN_HAVE_DOT NO)
975 set(DOXYGEN_VERBATIM_HEADERS YES)
976 doxygen_add_docs(doxygen
977 auth
978 client
979 cls
980 common
981 compressor
982 crimson
983 crush
984 crypto
985 erasure-code
986 global
987 include
988 journal
989 json_spirit
990 key_value_store
991 kv
992 librados
993 libradosstriper
994 librbd
995 log
996 mds
997 messages
998 mgr
999 mon
1000 mount
1001 msg
1002 objclass
1003 objsync
1004 os
1005 osd
1006 osdc
1007 perfglue
1008 rbd_fuse
1009 rbd_replay
1010 rgw
1011 COMMENT "Generate C++ documentation")
1012 endif()