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