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