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