]> git.proxmox.com Git - ceph.git/blob - ceph/CMakeLists.txt
bbd63a6a006b6f9b62618a0e536b1a700e6ed6b4
[ceph.git] / ceph / CMakeLists.txt
1 cmake_minimum_required(VERSION 3.16)
2
3 project(ceph
4 VERSION 19.2.0
5 LANGUAGES CXX C ASM)
6
7 foreach(policy CMP0127 CMP0135)
8 if(POLICY ${policy})
9 cmake_policy(SET ${policy} NEW)
10 endif()
11 endforeach()
12
13 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")
14
15 if(NOT CMAKE_BUILD_TYPE)
16 if (EXISTS "${CMAKE_SOURCE_DIR}/.git")
17 message(WARNING "CMAKE_BUILD_TYPE not specified, assuming CMAKE_BUILD_TYPE=Debug because .git exists.")
18 set(default_build_type "Debug")
19 set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
20 STRING "Default BUILD_TYPE is Debug, other options are: RelWithDebInfo, Release, and MinSizeRel." FORCE)
21 else()
22 message(WARNING "CMAKE_BUILD_TYPE not specified, leaving unset because .git does NOT exist.")
23 endif()
24 endif()
25
26 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
27 set(LINUX ON)
28 FIND_PACKAGE(Threads)
29 elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
30 set(FREEBSD ON)
31 FIND_PACKAGE(Threads)
32 endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
33
34 if(WIN32)
35 # The Windows headers (e.g. coming from mingw or the Windows SDK) check
36 # the targeted Windows version. The availability of certain functions and
37 # structures will depend on it.
38 set(WIN32_WINNT "0x0A00" CACHE STRING "Targeted Windows version.")
39 add_definitions(
40 -D_WIN32_WINNT=${WIN32_WINNT}
41 -DFMT_USE_TZSET=0
42 )
43 # In order to avoid known winpthread issues, we're using the Boost
44 # shared mutex implementation. This isn't required with llvm/libc++.
45 # https://github.com/msys2/MINGW-packages/issues/3319
46 if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
47 add_definitions(
48 -DBOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
49 -DBOOST_THREAD_V2_SHARED_MUTEX
50 )
51 endif()
52 set(Boost_THREADAPI "win32")
53 endif()
54
55 if(MINGW)
56 string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl,-allow-multiple-definition")
57 string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,-allow-multiple-definition")
58
59 # By default, cmake generates import libs for executables. The issue is that
60 # for rados and rbd, the executable import lib overrides the library import lib.
61 # For example, for rados.exe, it will end up generating a librados.dll.a import lib.
62 # We're providing custom rules to disable import libs for executables.
63 set(CMAKE_C_LINK_EXECUTABLE
64 "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>")
65 set(CMAKE_CXX_LINK_EXECUTABLE
66 "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>")
67
68 link_directories(${MINGW_LINK_DIRECTORIES})
69 endif()
70
71 option(WITH_CCACHE "Build with ccache.")
72 if(WITH_CCACHE)
73 if(CMAKE_C_COMPILER_LAUNCHER OR CMAKE_CXX_COMPILER_LAUNCHER)
74 message(WARNING "Compiler launcher already set. stop configuring ccache")
75 else()
76 find_program(CCACHE_EXECUTABLE ccache)
77 if(NOT CCACHE_EXECUTABLE)
78 message(FATAL_ERROR "Can't find ccache. Is it installed?")
79 endif()
80 message(STATUS "Building with ccache: ${CCACHE_EXECUTABLE}, CCACHE_DIR=$ENV{CCACHE_DIR}")
81 set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE})
82 set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE})
83 endif()
84 endif(WITH_CCACHE)
85
86 option(WITH_MANPAGE "Build man pages." ON)
87 if(WITH_MANPAGE)
88 find_program(SPHINX_BUILD
89 NAMES sphinx-build sphinx-build-3)
90 if(NOT SPHINX_BUILD)
91 message(FATAL_ERROR "Can't find sphinx-build.")
92 endif(NOT SPHINX_BUILD)
93 endif(WITH_MANPAGE)
94
95 include_directories(
96 ${PROJECT_BINARY_DIR}/src/include
97 ${PROJECT_SOURCE_DIR}/src)
98
99 if(WIN32)
100 include_directories(
101 ${PROJECT_SOURCE_DIR}/src/include/win32)
102 # Boost complains if winsock2.h (or windows.h) is included before asio.hpp.
103 add_compile_options("SHELL:-include winsock_wrapper.h")
104 # Boost is also defining some of the errno values, we'll have
105 # to avoid mismatches.
106 add_compile_options("SHELL:-include win32_errno.h")
107 endif()
108
109 if(FREEBSD)
110 include_directories(SYSTEM /usr/local/include)
111 link_directories(/usr/local/lib)
112 list(APPEND CMAKE_REQUIRED_INCLUDES /usr/local/include)
113 endif(FREEBSD)
114
115
116 #put all the libs and binaries in one place
117 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
118 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
119 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
120
121 include(GNUInstallDirs)
122 include(CephChecks)
123 if(CMAKE_GENERATOR MATCHES Ninja)
124 include(LimitJobs)
125 endif()
126
127 set(CEPH_MAN_DIR "share/man" CACHE STRING "Install location for man pages (relative to prefix).")
128
129 option(ENABLE_SHARED "build shared libraries" ON)
130 if(ENABLE_SHARED)
131 set(CEPH_SHARED SHARED)
132 else(ENABLE_SHARED)
133 set(CEPH_SHARED STATIC)
134 endif(ENABLE_SHARED)
135 set(CMAKE_POSITION_INDEPENDENT_CODE ${ENABLE_SHARED})
136
137 option(WITH_STATIC_LIBSTDCXX "Link against libstdc++ statically" OFF)
138 if(WITH_STATIC_LIBSTDCXX)
139 if(NOT CMAKE_COMPILER_IS_GNUCXX)
140 message(FATAL_ERROR "Please use GCC to enable WITH_STATIC_LIBSTDCXX")
141 endif()
142 set(static_linker_flags "-static-libstdc++ -static-libgcc")
143 string(APPEND CMAKE_SHARED_LINKER_FLAGS " ${static_linker_flags}")
144 string(APPEND CMAKE_EXE_LINKER_FLAGS " ${static_linker_flags}")
145 unset(static_linker_flags)
146 set(GPERFTOOLS_USE_STATIC_LIBS TRUE)
147 endif()
148 include(CheckCxxAtomic)
149 if(NOT HAVE_CXX11_ATOMIC)
150 string(APPEND CMAKE_CXX_STANDARD_LIBRARIES
151 " ${LIBATOMIC_LINK_FLAGS}")
152 endif()
153
154 option(WITH_RDMA "Enable RDMA in async messenger" ON)
155 if(WITH_RDMA)
156 find_package(verbs REQUIRED)
157 set(HAVE_VERBS ${VERBS_FOUND})
158 find_package(rdmacm REQUIRED)
159 set(HAVE_RDMACM ${RDMACM_FOUND})
160 set(HAVE_RDMA TRUE)
161 endif()
162
163 find_package(Backtrace)
164
165 option(WITH_RBD "Enable RADOS Block Device related targets" ON)
166
167 if(LINUX)
168 find_package(udev REQUIRED)
169 set(HAVE_UDEV ${UDEV_FOUND})
170 find_package(blkid REQUIRED)
171 set(HAVE_BLKID ${BLKID_FOUND})
172 find_package(keyutils REQUIRED)
173 set(HAVE_KEYUTILS ${KEYUTILS_FOUND})
174 elseif(FREEBSD)
175 set(HAVE_UDEV OFF)
176 set(HAVE_LIBAIO OFF)
177 set(HAVE_LIBDML OFF)
178 set(HAVE_BLKID OFF)
179 set(HAVE_KEYUTILS OFF)
180 else()
181 set(HAVE_UDEV OFF)
182 set(HAVE_BLKID OFF)
183 endif(LINUX)
184
185 option(WITH_OPENLDAP "OPENLDAP is here" ON)
186 if(WITH_OPENLDAP)
187 find_package(OpenLDAP REQUIRED)
188 set(HAVE_OPENLDAP ${OpenLDAP_FOUND})
189 endif()
190
191 option(WITH_GSSAPI "GSSAPI/KRB5 is here" OFF)
192 if(WITH_GSSAPI)
193 find_package(GSSApi REQUIRED)
194 set(HAVE_GSSAPI ${GSSApi_FOUND})
195 endif()
196
197 option(WITH_FUSE "Fuse is here" ON)
198 if(WITH_FUSE)
199 find_package(FUSE REQUIRED)
200 set(HAVE_LIBFUSE ${FUSE_FOUND})
201 endif()
202
203 option(WITH_DOKAN "Dokan is here" OFF)
204
205 option(WITH_XFS "XFS is here" ON)
206 if(WITH_XFS)
207 find_package(xfs)
208 set(HAVE_LIBXFS ${XFS_FOUND})
209 endif()
210
211 option(WITH_ZFS "enable LibZFS if found" OFF)
212 if(WITH_ZFS)
213 find_package(zfs)
214 set(HAVE_LIBZFS ${ZFS_FOUND})
215 endif()
216
217 option(WITH_BLUESTORE "Bluestore OSD backend" ON)
218 if(WITH_BLUESTORE)
219 if(LINUX)
220 find_package(aio)
221 set(HAVE_LIBAIO ${AIO_FOUND})
222 elseif(FREEBSD)
223 # POSIX AIO is integrated into FreeBSD kernel, and exposed by libc.
224 set(HAVE_POSIXAIO ON)
225 endif()
226 endif()
227
228 # libcryptsetup is only available on linux
229 if(WITH_RBD AND LINUX)
230 find_package(libcryptsetup 2.0.5 REQUIRED)
231 set(HAVE_LIBCRYPTSETUP ${LIBCRYPTSETUP_FOUND})
232 endif()
233
234 include(CMakeDependentOption)
235
236 CMAKE_DEPENDENT_OPTION(WITH_LIBURING "Enable io_uring bluestore backend" ON
237 "WITH_BLUESTORE;HAVE_LIBAIO" OFF)
238 set(HAVE_LIBURING ${WITH_LIBURING})
239
240 CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_LIBURING "Require and build with system liburing" OFF
241 "HAVE_LIBAIO;WITH_BLUESTORE" OFF)
242
243 if(WITH_LIBURING)
244 if(WITH_SYSTEM_LIBURING)
245 find_package(uring REQUIRED)
246 else()
247 include(Builduring)
248 build_uring()
249 endif()
250 # enable uring in boost::asio
251 add_compile_definitions("BOOST_ASIO_HAS_IO_URING")
252 endif()
253
254 CMAKE_DEPENDENT_OPTION(WITH_BLUESTORE_PMEM "Enable PMDK libraries" OFF
255 "WITH_BLUESTORE" OFF)
256 if(WITH_BLUESTORE_PMEM)
257 find_package(dml)
258 set(HAVE_LIBDML ${DML_FOUND})
259 endif()
260
261 CMAKE_DEPENDENT_OPTION(WITH_RBD_MIRROR "Enable build for rbd-mirror daemon executable" OFF
262 "WITH_RBD" OFF)
263
264 CMAKE_DEPENDENT_OPTION(WITH_RBD_MIGRATION_FORMAT_QCOW_V1
265 "Enable librbd QCOW v1 migration format support" ON
266 "WITH_RBD" OFF)
267
268 CMAKE_DEPENDENT_OPTION(WITH_RBD_RWL "Enable librbd persistent write back cache" OFF
269 "WITH_RBD" OFF)
270
271 CMAKE_DEPENDENT_OPTION(WITH_RBD_SSD_CACHE "Enable librbd persistent write back cache for SSDs" OFF
272 "WITH_RBD" OFF)
273
274 CMAKE_DEPENDENT_OPTION(WITH_SYSTEM_PMDK "Require and build with system PMDK" OFF
275 "WITH_RBD_RWL OR WITH_BLUESTORE_PMEM" OFF)
276
277 CMAKE_DEPENDENT_OPTION(WITH_RBD_UBBD "Enable ubbd support for rbd device utility" OFF
278 "WITH_RBD" OFF)
279
280 if(WITH_RBD_UBBD)
281 include(BuildUBBD)
282 build_ubbd()
283 endif()
284
285 if(WITH_BLUESTORE_PMEM)
286 set(HAVE_BLUESTORE_PMEM ON)
287 endif()
288
289 CMAKE_DEPENDENT_OPTION(WITH_SPDK "Enable SPDK" OFF
290 "CMAKE_SYSTEM_PROCESSOR MATCHES i386|i686|amd64|x86_64|AMD64|aarch64" OFF)
291 if(WITH_SPDK)
292 if(NOT WITH_BLUESTORE)
293 message(SEND_ERROR "Please enable WITH_BLUESTORE for using SPDK")
294 endif()
295 include(BuildSPDK)
296 build_spdk()
297 set(HAVE_SPDK TRUE)
298 endif(WITH_SPDK)
299
300 if(WITH_BLUESTORE)
301 if(NOT AIO_FOUND AND NOT HAVE_POSIXAIO AND NOT WITH_SPDK AND NOT WITH_BLUESTORE_PMEM)
302 message(SEND_ERROR "WITH_BLUESTORE is ON, "
303 "but none of the bluestore backends is enabled. "
304 "Please install libaio, or enable WITH_SPDK or WITH_BLUESTORE_PMEM (experimental)")
305 endif()
306 endif()
307
308 option(WITH_BLUEFS "libbluefs library" OFF)
309
310 CMAKE_DEPENDENT_OPTION(WITH_QATLIB "Enable QAT with qatlib" ON
311 "CMAKE_SYSTEM_PROCESSOR MATCHES amd64|x86_64|AMD64" OFF)
312 option(WITH_SYSTEM_QATLIB "Use system packages for qatlib" OFF)
313 option(WITH_QATDRV "Enable QAT with out-of-tree driver" OFF)
314 CMAKE_DEPENDENT_OPTION(WITH_QATZIP "Enable QATzip" ON
315 "CMAKE_SYSTEM_PROCESSOR MATCHES amd64|x86_64|AMD64" OFF)
316 option(WITH_SYSTEM_QATZIP "Use system packages for QATzip" OFF)
317
318 if(WITH_QATDRV)
319 find_package(QatDrv REQUIRED COMPONENTS qat_s usdm_drv_s)
320 set(HAVE_QAT TRUE)
321 elseif(WITH_QATLIB)
322 if(NOT WITH_SYSTEM_QAT)
323 include(BuildQAT)
324 build_qat()
325 endif()
326 find_package(QAT REQUIRED)
327 if(NOT WITH_SYSTEM_QAT)
328 add_dependencies(QAT::qat qatlib_ext)
329 add_dependencies(QAT::usdm qatlib_ext)
330 endif()
331 set(HAVE_QAT TRUE)
332 endif()
333
334 if(WITH_QATZIP)
335 if(NOT HAVE_QAT)
336 message(FATAL_ERROR "WITH_QATZIP requires WITH_QATLIB or WITH_QATDRV")
337 endif()
338 if(NOT WITH_SYSTEM_QATZIP)
339 include(BuildQATzip)
340 build_qatzip()
341 # qatzip build depends on qatlib
342 add_dependencies(qatzip_ext QAT::qat)
343 endif()
344 find_package(QATzip REQUIRED)
345 if(NOT WITH_SYSTEM_QATZIP)
346 add_dependencies(QAT::zip qatzip_ext)
347 endif()
348 set(HAVE_QATZIP TRUE)
349 endif(WITH_QATZIP)
350
351 # needs mds and? XXX
352 option(WITH_LIBCEPHFS "libcephfs client library" ON)
353
354 option(WITH_LIBCEPHSQLITE "libcephsqlite client library" ON)
355 if(WITH_LIBCEPHSQLITE)
356 find_package(SQLite3 REQUIRED)
357 endif()
358
359 # key-value store
360 option(WITH_KVS "Key value store is here" OFF)
361
362 option(WITH_KRBD "Enable Linux krbd support of 'rbd' utility" ON)
363
364 if(WITH_KRBD AND NOT WITH_RBD)
365 message(FATAL_ERROR "Cannot have WITH_KRBD without WITH_RBD.")
366 endif()
367 if(LINUX)
368 if(WITH_LIBCEPHFS OR WITH_KRBD)
369 # keyutils is only used when talking to the Linux Kernel key store
370 find_package(keyutils REQUIRED)
371 set(HAVE_KEYUTILS ${KEYUTILS_FOUND})
372 endif()
373 endif()
374
375 find_package(snappy REQUIRED)
376
377 option(WITH_BROTLI "Brotli compression support" OFF)
378 if(WITH_BROTLI)
379 set(HAVE_BROTLI TRUE)
380 endif()
381
382 option(WITH_LZ4 "LZ4 compression support" ON)
383 if(WITH_LZ4)
384 find_package(LZ4 1.7 REQUIRED)
385 set(HAVE_LZ4 ${LZ4_FOUND})
386 endif(WITH_LZ4)
387
388 CMAKE_DEPENDENT_OPTION(WITH_CEPH_DEBUG_MUTEX "Use debug ceph::mutex with lockdep" ON
389 "CMAKE_BUILD_TYPE STREQUAL Debug" OFF)
390
391 #if allocator is set on command line make sure it matches below strings
392 set(ALLOCATOR "" CACHE STRING
393 "specify memory allocator to use. currently tcmalloc, tcmalloc_minimal, \
394 jemalloc, and libc is supported. if not specified, will try to find tcmalloc, \
395 and then jemalloc. If neither of then is found. use the one in libc.")
396 if(ALLOCATOR)
397 if(${ALLOCATOR} MATCHES "tcmalloc(_minimal)?")
398 find_package(gperftools 2.6.2 REQUIRED)
399 set(ALLOC_LIBS gperftools::${ALLOCATOR})
400 set(HAVE_LIBTCMALLOC ON)
401 elseif(${ALLOCATOR} STREQUAL "jemalloc")
402 find_package(JeMalloc REQUIRED)
403 set(ALLOC_LIBS JeMalloc::JeMalloc)
404 set(HAVE_JEMALLOC 1)
405 elseif(NOT ALLOCATOR STREQUAL "libc")
406 message(FATAL_ERROR "Unsupported allocator selected: ${ALLOCATOR}")
407 endif()
408 else(ALLOCATOR)
409 find_package(gperftools 2.6.2)
410 set(HAVE_LIBTCMALLOC ${gperftools_FOUND})
411 if(NOT gperftools_FOUND)
412 find_package(JeMalloc)
413 endif()
414 if(gperftools_FOUND)
415 set(ALLOCATOR tcmalloc)
416 set(ALLOC_LIBS gperftools::tcmalloc)
417 elseif(JeMalloc_FOUND)
418 set(ALLOCATOR jemalloc)
419 set(ALLOC_LIBS JeMalloc::JeMalloc)
420 else()
421 if(NOT FREEBSD)
422 # FreeBSD already has jemalloc as its default allocator
423 message(WARNING "tcmalloc and jemalloc not found, falling back to libc")
424 endif()
425 set(ALLOCATOR "libc")
426 endif(gperftools_FOUND)
427 endif(ALLOCATOR)
428 if(NOT ALLOCATOR STREQUAL "libc")
429 add_compile_options(
430 $<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-malloc>
431 $<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-calloc>
432 $<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-realloc>
433 $<$<COMPILE_LANGUAGE:CXX>:-fno-builtin-free>)
434 endif()
435 message(STATUS "allocator selected: ${ALLOCATOR}")
436
437 # Mingw generates incorrect entry points when using "-pie".
438 if(WIN32 OR (HAVE_LIBTCMALLOC AND WITH_STATIC_LIBSTDCXX))
439 set(EXE_LINKER_USE_PIE FALSE)
440 else()
441 set(EXE_LINKER_USE_PIE ${ENABLE_SHARED})
442 endif()
443
444 if(NOT WIN32)
445 # require libcurl with good curl_multi_wait(), see https://tracker.ceph.com/issues/15915
446 find_package(CURL 7.32 REQUIRED)
447 endif()
448
449 find_package(OpenSSL REQUIRED)
450 set(CRYPTO_LIBS OpenSSL::Crypto)
451
452 option(WITH_DPDK "Enable DPDK messaging" OFF)
453 if(WITH_DPDK)
454 find_package(dpdk)
455 if(NOT DPDK_FOUND)
456 include(BuildDPDK)
457 build_dpdk(${CMAKE_BINARY_DIR}/src/dpdk)
458 endif()
459 set(HAVE_DPDK TRUE)
460 endif()
461
462 option(WITH_BLKIN "Use blkin to emit LTTng tracepoints for Zipkin" OFF)
463 if(WITH_BLKIN)
464 find_package(LTTngUST REQUIRED)
465 set(BLKIN_LIBRARIES blkin ${LTTNGUST_LIBRARIES} lttng-ust-fork)
466 include_directories(SYSTEM src/blkin/blkin-lib)
467 endif(WITH_BLKIN)
468
469 option(WITH_JAEGER "Enable jaegertracing and it's dependent libraries" ON)
470 if(WITH_JAEGER)
471 set(HAVE_JAEGER TRUE)
472 endif()
473
474 #option for RGW
475 option(WITH_RADOSGW "RADOS Gateway is enabled" ON)
476 option(WITH_RADOSGW_BEAST_OPENSSL "RADOS Gateway's Beast frontend uses OpenSSL" ON)
477 option(WITH_RADOSGW_AMQP_ENDPOINT "RADOS Gateway's pubsub support for AMQP push endpoint" ON)
478 option(WITH_RADOSGW_KAFKA_ENDPOINT "RADOS Gateway's pubsub support for Kafka push endpoint" ON)
479 option(WITH_RADOSGW_LUA_PACKAGES "RADOS Gateway's support for dynamically adding lua packagess" ON)
480 option(WITH_RADOSGW_DBSTORE "DBStore backend for RADOS Gateway" ON)
481 option(WITH_RADOSGW_MOTR "CORTX-Motr backend for RADOS Gateway" OFF)
482 option(WITH_RADOSGW_DAOS "DAOS backend for RADOS Gateway" OFF)
483 option(WITH_RADOSGW_D4N "D4N wrapper for RADOS Gateway" ON)
484 option(WITH_RADOSGW_POSIX "POSIX backend for Rados Gateway" ON)
485 option(WITH_RADOSGW_SELECT_PARQUET "Support for s3 select on parquet objects" ON)
486 option(WITH_RADOSGW_ARROW_FLIGHT "Build arrow flight when not using system-provided arrow" OFF)
487 option(WITH_RADOSGW_BACKTRACE_LOGGING "Enable backtraces in rgw logs" OFF)
488
489 option(WITH_SYSTEM_ARROW "Use system-provided arrow" OFF)
490 option(WITH_SYSTEM_UTF8PROC "Use system-provided utf8proc" OFF)
491
492 if(WITH_RADOSGW)
493 find_package(EXPAT REQUIRED)
494 find_package(OATH REQUIRED)
495
496 # https://curl.haxx.se/docs/install.html mentions the
497 # configure flags for various ssl backends
498 execute_process(
499 COMMAND
500 "sh" "-c"
501 "curl-config --configure | grep with-ssl"
502 RESULT_VARIABLE NO_CURL_SSL_LINK
503 ERROR_VARIABLE CURL_CONFIG_ERRORS
504 )
505 if (CURL_CONFIG_ERRORS)
506 message(WARNING "unable to run curl-config; rgw cannot make ssl requests to external systems reliably")
507 endif()
508
509 if (NOT NO_CURL_SSL_LINK)
510 message(STATUS "libcurl is linked with openssl: explicitly setting locks")
511 set(WITH_CURL_OPENSSL ON)
512 endif() # CURL_SSL_LINK
513 execute_process(
514 COMMAND
515 "sh" "-c"
516 "objdump -p ${OPENSSL_SSL_LIBRARY} | sed -n 's/^ SONAME *//p'"
517 OUTPUT_VARIABLE LIBSSL_SONAME
518 ERROR_VARIABLE OBJDUMP_ERRORS
519 RESULT_VARIABLE OBJDUMP_RESULTS
520 OUTPUT_STRIP_TRAILING_WHITESPACE)
521 if (OBJDUMP_RESULTS)
522 message(FATAL_ERROR "can't run objdump: ${OBJDUMP_RESULTS}")
523 endif()
524 if (NOT OBJDUMP_ERRORS STREQUAL "")
525 message(WARNING "message from objdump: ${OBJDUMP_ERRORS}")
526 endif()
527 execute_process(
528 COMMAND
529 "sh" "-c"
530 "objdump -p ${OPENSSL_CRYPTO_LIBRARY} | sed -n 's/^ SONAME *//p'"
531 OUTPUT_VARIABLE LIBCRYPTO_SONAME
532 ERROR_VARIABLE OBJDUMP_ERRORS
533 RESULT_VARIABLE OBJDUMP_RESULTS
534 OUTPUT_STRIP_TRAILING_WHITESPACE)
535 if (OBJDUMP_RESULTS)
536 message(FATAL_ERROR "can't run objdump: ${OBJDUMP_RESULTS}")
537 endif()
538 if (NOT OBJDUMP_ERRORS STREQUAL "")
539 message(WARNING "message from objdump: ${OBJDUMP_ERRORS}")
540 endif()
541 message(STATUS "ssl soname: ${LIBSSL_SONAME}")
542 message(STATUS "crypto soname: ${LIBCRYPTO_SONAME}")
543 endif (WITH_RADOSGW)
544
545 #option for CephFS
546 option(WITH_CEPHFS "CephFS is enabled" ON)
547
548 if(NOT WIN32)
549 # Please specify 3.[0-7] if you want to build with a certain version of python3.
550 set(WITH_PYTHON3 "3" CACHE STRING "build with specified python3 version")
551 find_package(Python3 ${WITH_PYTHON3} EXACT REQUIRED
552 COMPONENTS Interpreter Development)
553
554 option(WITH_MGR "ceph-mgr is enabled" ON)
555 if(WITH_MGR)
556 set(MGR_PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
557 set(MGR_PYTHON_LIBRARIES ${Python3_LIBRARIES})
558 set(MGR_PYTHON_VERSION_MAJOR ${Python3_VERSION_MAJOR})
559 set(MGR_PYTHON_VERSION_MINOR ${Python3_VERSION_MINOR})
560 # Boost dependency check deferred to Boost section
561 endif(WITH_MGR)
562 endif(NOT WIN32)
563
564 option(WITH_THREAD_SAFE_RES_QUERY "res_query is thread safe" OFF)
565 if(WITH_THREAD_SAFE_RES_QUERY)
566 set(HAVE_THREAD_SAFE_RES_QUERY 1 CACHE INTERNAL "Thread safe res_query supported.")
567 endif()
568
569 option(WITH_REENTRANT_STRSIGNAL "strsignal is reentrant" OFF)
570 if(WITH_REENTRANT_STRSIGNAL)
571 set(HAVE_REENTRANT_STRSIGNAL 1 CACHE INTERNAL "Reentrant strsignal is supported.")
572 endif()
573
574 # -lz link into kv
575 find_package(ZLIB REQUIRED)
576
577 #option for EventTrace
578 CMAKE_DEPENDENT_OPTION(
579 WITH_EVENTTRACE "Event tracing support, requires WITH_LTTNG"
580 OFF "USE_LTTNG" OFF)
581
582 #option for LTTng
583 option(WITH_LTTNG "LTTng tracing is enabled" ON)
584 if(${WITH_LTTNG})
585 find_package(LTTngUST REQUIRED)
586 find_program(LTTNG_GEN_TP
587 lttng-gen-tp)
588 if(NOT LTTNG_GEN_TP)
589 message(FATAL_ERROR "Can't find lttng-gen-tp.")
590 endif()
591 endif(${WITH_LTTNG})
592
593 option(WITH_OSD_INSTRUMENT_FUNCTIONS OFF)
594
595 #option for Babeltrace
596 option(WITH_BABELTRACE "Babeltrace libraries are enabled" ON)
597 if(WITH_BABELTRACE)
598 set(HAVE_BABELTRACE ON)
599 find_package(babeltrace REQUIRED)
600 set(HAVE_BABELTRACE_BABELTRACE_H ${BABELTRACE_FOUND})
601 set(HAVE_BABELTRACE_CTF_EVENTS_H ${BABELTRACE_FOUND})
602 set(HAVE_BABELTRACE_CTF_ITERATOR_H ${BABELTRACE_FOUND})
603 endif(WITH_BABELTRACE)
604
605 option(DEBUG_GATHER "C_Gather debugging is enabled" ON)
606 option(ENABLE_COVERAGE "Coverage is enabled" OFF)
607 option(PG_DEBUG_REFS "PG Ref debugging is enabled" OFF)
608
609 option(WITH_TESTS "enable the build of ceph-test package scripts/binaries" ON)
610 set(UNIT_TESTS_BUILT ${WITH_TESTS})
611 set(CEPH_TEST_TIMEOUT 7200 CACHE STRING
612 "Maximum time before a CTest gets killed" )
613
614 # fio
615 option(WITH_FIO "build with fio plugin enabled" OFF)
616 if(WITH_FIO)
617 include(BuildFIO)
618 build_fio()
619 endif()
620
621 if(LINUX)
622 add_definitions(-D__linux__)
623 endif(LINUX)
624
625 # ASAN and friends
626 option(WITH_ASAN "build with ASAN" OFF)
627 if(WITH_ASAN)
628 list(APPEND sanitizers "address")
629 endif()
630
631 option(WITH_ASAN_LEAK "explicitly enable ASAN leak detection" OFF)
632 if(WITH_ASAN_LEAK)
633 list(APPEND sanitizers "leak")
634 endif()
635
636 option(WITH_TSAN "build with TSAN" OFF)
637 if(WITH_TSAN)
638 list(APPEND sanitizers "thread")
639 endif()
640
641 option(WITH_UBSAN "build with UBSAN" OFF)
642 if(WITH_UBSAN)
643 list(APPEND sanitizers "undefined_behavior")
644 endif()
645
646 if(sanitizers)
647 find_package(Sanitizers REQUIRED ${sanitizers})
648 add_compile_options(${Sanitizers_COMPILE_OPTIONS})
649 string(REPLACE ";" " " sanitiers_compile_flags "${Sanitizers_COMPILE_OPTIONS}")
650 string(APPEND CMAKE_EXE_LINKER_FLAGS " ${sanitiers_compile_flags}")
651 string(APPEND CMAKE_SHARED_LINKER_FLAGS " ${sanitiers_compile_flags}")
652 endif()
653
654 # Rocksdb
655 option(WITH_SYSTEM_ROCKSDB "require and build with system rocksdb" OFF)
656 if (WITH_SYSTEM_ROCKSDB)
657 find_package(RocksDB 5.14 REQUIRED)
658 endif()
659
660 option(WITH_SEASTAR "Build seastar components")
661 set(HAVE_SEASTAR ${WITH_SEASTAR})
662
663 # Boost
664 option(WITH_SYSTEM_BOOST "require and build with system Boost" OFF)
665
666 # Boost::thread depends on Boost::atomic, so list it explicitly.
667 set(BOOST_COMPONENTS
668 atomic chrono thread system regex random program_options date_time
669 iostreams context coroutine)
670 set(BOOST_HEADER_COMPONENTS container)
671
672 if(WITH_MGR)
673 list(APPEND BOOST_COMPONENTS
674 python${MGR_PYTHON_VERSION_MAJOR}${MGR_PYTHON_VERSION_MINOR})
675 endif()
676 if(WITH_SEASTAR)
677 list(APPEND BOOST_COMPONENTS timer)
678 endif()
679
680 if(WITH_RADOSGW AND WITH_RADOSGW_LUA_PACKAGES)
681 list(APPEND BOOST_COMPONENTS filesystem)
682 endif()
683
684 set(Boost_USE_MULTITHREADED ON)
685
686 CMAKE_DEPENDENT_OPTION(WITH_BOOST_VALGRIND "Boost support for valgrind" OFF
687 "NOT WITH_SYSTEM_BOOST" OFF)
688 # require minimally the bundled version
689 if(WITH_SYSTEM_BOOST)
690 if(ENABLE_SHARED)
691 set(Boost_USE_STATIC_LIBS OFF)
692 else()
693 set(Boost_USE_STATIC_LIBS ON)
694 endif()
695 if(BOOST_ROOT AND CMAKE_LIBRARY_ARCHITECTURE)
696 set(BOOST_LIBRARYDIR "${BOOST_ROOT}/lib/${CMAKE_LIBRARY_ARCHITECTURE}")
697 endif()
698 find_package(Boost 1.82 COMPONENTS ${BOOST_COMPONENTS} REQUIRED)
699 if(NOT ENABLE_SHARED)
700 set_property(TARGET Boost::iostreams APPEND PROPERTY
701 INTERFACE_LINK_LIBRARIES ZLIB::ZLIB)
702 endif()
703 else()
704 include(ProcessorCount)
705 ProcessorCount(DEFAULT_BOOST_J)
706 if(DEFAULT_BOOST_J EQUAL 0)
707 set(DEFAULT_BOOST_J 1)
708 endif()
709 set(BOOST_J ${DEFAULT_BOOST_J} CACHE STRING "max jobs for Boost build") # override w/-DBOOST_J=<n>
710 set(Boost_USE_STATIC_LIBS ON)
711 include(BuildBoost)
712 build_boost(1.82
713 COMPONENTS ${BOOST_COMPONENTS} ${BOOST_HEADER_COMPONENTS})
714 endif()
715 include_directories(BEFORE SYSTEM ${Boost_INCLUDE_DIRS})
716
717 if(Boost_VERSION VERSION_LESS 1.84)
718 # This is a workaround for https://github.com/boostorg/phoenix/issues/111
719 add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-DBOOST_PHOENIX_STL_TUPLE_H_>)
720 endif()
721
722 # dashboard angular2 frontend
723 option(WITH_MGR_DASHBOARD_FRONTEND "Build the mgr/dashboard frontend using `npm`" ON)
724 option(WITH_SYSTEM_NPM "Assume that dashboard build tools already installed through packages" OFF)
725 if(WITH_SYSTEM_NPM)
726 find_program(NPM_EXECUTABLE npm)
727 if(NOT NPM_EXECUTABLE)
728 message(FATAL_ERROR "Can't find npm.")
729 endif()
730 endif()
731 set(DASHBOARD_FRONTEND_LANGS "ALL" CACHE STRING
732 "List of comma separated ceph-dashboard frontend languages to build. \
733 Use value `ALL` to build all languages")
734 CMAKE_DEPENDENT_OPTION(WITH_MGR_ROOK_CLIENT "Enable the mgr's Rook support" ON
735 "WITH_MGR" OFF)
736
737 include_directories(SYSTEM ${PROJECT_BINARY_DIR}/include)
738
739 find_package(Threads REQUIRED)
740 find_package(StdFilesystem REQUIRED)
741
742 option(WITH_SELINUX "build SELinux policy" OFF)
743 if(WITH_SELINUX)
744 find_file(SELINUX_MAKEFILE selinux/devel/Makefile
745 PATH /usr/share)
746 if(NOT SELINUX_MAKEFILE)
747 message(FATAL_ERROR "Can't find selinux's Makefile")
748 endif()
749 add_subdirectory(selinux)
750 endif(WITH_SELINUX)
751
752 # enables testing and creates Make check command
753 add_custom_target(tests
754 COMMENT "Building tests")
755 enable_testing()
756 set(CMAKE_CTEST_COMMAND ctest)
757 add_custom_target(check
758 COMMAND ${CMAKE_CTEST_COMMAND}
759 DEPENDS tests)
760
761 option(WITH_SYSTEMD "build with systemd support" ON)
762
763 add_subdirectory(src)
764
765 add_subdirectory(qa)
766 add_subdirectory(doc)
767 if(WITH_MANPAGE)
768 add_subdirectory(man)
769 endif(WITH_MANPAGE)
770
771 if(WITH_SYSTEMD)
772 add_subdirectory(systemd)
773 endif()
774
775 if(LINUX)
776 add_subdirectory(etc/sysctl)
777 endif()
778
779 option(WITH_GRAFANA "install grafana dashboards" OFF)
780 add_subdirectory(monitoring/ceph-mixin)
781
782 include(CTags)
783 option(CTAG_EXCLUDES "Exclude files/directories when running ctag.")
784 add_tags(ctags
785 SRC_DIR src
786 TAG_FILE tags
787 EXCLUDE_OPTS ${CTAG_EXCLUDES}
788 EXCLUDES "*.js" "*.css" ".tox" "python-common/build")
789 add_custom_target(tags DEPENDS ctags)