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