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