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