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