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