]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | cmake_minimum_required(VERSION 2.8.11) |
2 | ||
3 | project(ceph) | |
28e407b8 | 4 | set(VERSION 12.2.7) |
7c673cae FG |
5 | |
6 | if(POLICY CMP0046) | |
7 | # Tweak policies (this one disables "missing" dependency warning) | |
8 | cmake_policy(SET CMP0046 OLD) | |
9 | endif() | |
10 | # we use LINK_PRIVATE keyword instead of PRIVATE, but do not specify the LINK_PUBLIC | |
11 | # for target_link_libraries() command when PUBLIC should be used instead, it's just | |
12 | # for backward compatibility with cmake 2.8.11. | |
13 | if (POLICY CMP0022) | |
14 | cmake_policy(SET CMP0022 OLD) | |
15 | endif (POLICY CMP0022) | |
16 | if (POLICY CMP0023) | |
17 | cmake_policy(SET CMP0023 OLD) | |
18 | endif (POLICY CMP0023) | |
19 | if(POLICY CMP0056) | |
20 | cmake_policy(SET CMP0056 NEW) | |
21 | endif() | |
22 | if(POLICY CMP0065) | |
23 | cmake_policy(SET CMP0065 NEW) | |
24 | endif() | |
31f18b77 FG |
25 | if(POLICY CMP0051) |
26 | # cmake 3.1 and higher include generator expressions in SOURCES property. | |
27 | # in BuildBoost.cmake, get_target_property(<var> <target> SOURCES) is used | |
28 | # to retrieve the source files of a target. in that case, we are only | |
29 | # interested in the *source* files. and i don't want to bother stripping off | |
30 | # the TARGET_OBJECTS elements from the returned SOURCES. so let's stick with | |
31 | # the old behavior now. | |
32 | cmake_policy(SET CMP0051 OLD) | |
33 | endif() | |
7c673cae FG |
34 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/") |
35 | ||
36 | if(CMAKE_SYSTEM_NAME MATCHES "Linux") | |
37 | set(LINUX ON) | |
38 | FIND_PACKAGE(Threads) | |
39 | elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") | |
40 | set(FREEBSD ON) | |
41 | FIND_PACKAGE(Threads) | |
42 | elseif(APPLE) | |
43 | set(OperatingSystem "Mac OS X") | |
44 | else() | |
45 | message(STATUS "No systemtype selected for building") | |
46 | endif(CMAKE_SYSTEM_NAME MATCHES "Linux") | |
47 | ||
48 | option(WITH_CCACHE "Build with ccache.") | |
49 | if(WITH_CCACHE) | |
50 | find_program(CCACHE_FOUND ccache) | |
51 | if(CCACHE_FOUND) | |
52 | message(STATUS "Building with ccache: ${CCACHE_FOUND}, CCACHE_DIR=$ENV{CCACHE_DIR}") | |
53 | set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) | |
54 | # ccache does not accelerate link (ld), but let it handle it. by passing it | |
55 | # along with cc to python's distutils, we are able to workaround | |
56 | # https://bugs.python.org/issue8027. | |
57 | set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) | |
58 | else(CCACHE_FOUND) | |
59 | message(FATAL_ERROR "Can't find ccache. Is it installed?") | |
60 | endif(CCACHE_FOUND) | |
61 | endif(WITH_CCACHE) | |
62 | ||
63 | option(WITH_MANPAGE "Build man pages." ON) | |
64 | if(WITH_MANPAGE) | |
65 | find_program(SPHINX_BUILD | |
66 | sphinx-build) | |
67 | if(NOT SPHINX_BUILD) | |
68 | message(FATAL_ERROR "Can't find sphinx-build.") | |
69 | endif(NOT SPHINX_BUILD) | |
70 | endif(WITH_MANPAGE) | |
71 | ||
72 | include_directories( | |
73 | ${PROJECT_BINARY_DIR}/src/include | |
74 | ${PROJECT_SOURCE_DIR}/src) | |
75 | ||
76 | if(OFED_PREFIX) | |
77 | include_directories(${OFED_PREFIX}/include) | |
78 | link_directories(${OFED_PREFIX}/lib) | |
79 | endif() | |
80 | ||
81 | if(FREEBSD) | |
82 | include_directories(/usr/local/include) | |
83 | link_directories(/usr/local/lib) | |
84 | list(APPEND CMAKE_REQUIRED_INCLUDES /usr/local/include) | |
85 | endif(FREEBSD) | |
86 | ||
87 | #Check Includes | |
88 | include(CheckIncludeFiles) | |
89 | include(CheckIncludeFileCXX) | |
90 | include(CheckFunctionExists) | |
91 | ||
92 | #put all the libs and binaries in one place | |
93 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | |
94 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | |
95 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | |
96 | ||
97 | ||
98 | CHECK_FUNCTION_EXISTS(fallocate CEPH_HAVE_FALLOCATE) | |
99 | CHECK_FUNCTION_EXISTS(posix_fadvise HAVE_POSIX_FADVISE) | |
100 | CHECK_FUNCTION_EXISTS(posix_fallocate HAVE_POSIX_FALLOCATE) | |
101 | CHECK_FUNCTION_EXISTS(syncfs HAVE_SYS_SYNCFS) | |
102 | CHECK_FUNCTION_EXISTS(sync_file_range HAVE_SYNC_FILE_RANGE) | |
103 | CHECK_FUNCTION_EXISTS(pwritev HAVE_PWRITEV) | |
104 | CHECK_FUNCTION_EXISTS(splice CEPH_HAVE_SPLICE) | |
105 | CHECK_FUNCTION_EXISTS(getgrouplist HAVE_GETGROUPLIST) | |
106 | CHECK_FUNCTION_EXISTS(fdatasync HAVE_FDATASYNC) | |
107 | CHECK_FUNCTION_EXISTS(strerror_r HAVE_STRERROR_R) | |
108 | CHECK_FUNCTION_EXISTS(name_to_handle_at HAVE_NAME_TO_HANDLE_AT) | |
109 | CHECK_FUNCTION_EXISTS(pipe2 HAVE_PIPE2) | |
110 | set(CMAKE_REQUIRED_LIBRARIES pthread) | |
111 | CHECK_FUNCTION_EXISTS(pthread_spin_init HAVE_PTHREAD_SPINLOCK) | |
112 | CHECK_FUNCTION_EXISTS(pthread_set_name_np HAVE_PTHREAD_SET_NAME_NP) | |
113 | CHECK_FUNCTION_EXISTS(pthread_setname_np HAVE_PTHREAD_SETNAME_NP) | |
114 | CHECK_FUNCTION_EXISTS(pthread_getname_np HAVE_PTHREAD_GETNAME_NP) | |
b32b8144 | 115 | CHECK_FUNCTION_EXISTS(pthread_rwlockattr_setkind_np HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP) |
7c673cae | 116 | CHECK_FUNCTION_EXISTS(eventfd HAVE_EVENTFD) |
31f18b77 | 117 | CHECK_FUNCTION_EXISTS(getprogname HAVE_GETPROGNAME) |
7c673cae | 118 | |
7c673cae FG |
119 | CHECK_INCLUDE_FILES("linux/types.h" HAVE_LINUX_TYPES_H) |
120 | CHECK_INCLUDE_FILES("linux/version.h" HAVE_LINUX_VERSION_H) | |
7c673cae FG |
121 | CHECK_INCLUDE_FILES("arpa/nameser_compat.h" HAVE_ARPA_NAMESER_COMPAT_H) |
122 | CHECK_INCLUDE_FILES("sys/mount.h" HAVE_SYS_MOUNT_H) | |
123 | CHECK_INCLUDE_FILES("sys/param.h" HAVE_SYS_PARAM_H) | |
124 | CHECK_INCLUDE_FILES("sys/types.h" HAVE_SYS_TYPES_H) | |
125 | CHECK_INCLUDE_FILES("sys/vfs.h" HAVE_SYS_VFS_H) | |
126 | CHECK_INCLUDE_FILES("sys/prctl.h" HAVE_SYS_PRCTL_H) | |
127 | CHECK_INCLUDE_FILES("execinfo.h" HAVE_EXECINFO_H) | |
128 | if(LINUX) | |
129 | CHECK_INCLUDE_FILES("sched.h" HAVE_SCHED) | |
130 | endif(LINUX) | |
131 | CHECK_INCLUDE_FILES("valgrind/helgrind.h" HAVE_VALGRIND_HELGRIND_H) | |
132 | ||
133 | include(CheckTypeSize) | |
134 | set(CMAKE_EXTRA_INCLUDE_FILES "linux/types.h") | |
135 | CHECK_TYPE_SIZE(__be16 __BE16) | |
136 | CHECK_TYPE_SIZE(__be32 __BE32) | |
137 | CHECK_TYPE_SIZE(__be64 __BE64) | |
138 | CHECK_TYPE_SIZE(__le16 __LE16) | |
139 | CHECK_TYPE_SIZE(__le32 __LE32) | |
140 | CHECK_TYPE_SIZE(__le64 __LE64) | |
141 | CHECK_TYPE_SIZE(__u8 __U8) | |
142 | CHECK_TYPE_SIZE(__u16 __U16) | |
143 | CHECK_TYPE_SIZE(__u32 __U32) | |
144 | CHECK_TYPE_SIZE(__u64 __U64) | |
145 | CHECK_TYPE_SIZE(__s8 __S8) | |
146 | CHECK_TYPE_SIZE(__s16 __S16) | |
147 | CHECK_TYPE_SIZE(__s32 __S32) | |
148 | CHECK_TYPE_SIZE(__s64 __S64) | |
149 | unset(CMAKE_EXTRA_INCLUDE_FILES) | |
150 | ||
151 | include(CheckSymbolExists) | |
152 | CHECK_SYMBOL_EXISTS(res_nquery "resolv.h" HAVE_RES_NQUERY) | |
153 | CHECK_SYMBOL_EXISTS(F_SETPIPE_SZ "linux/fcntl.h" CEPH_HAVE_SETPIPE_SZ) | |
154 | CHECK_SYMBOL_EXISTS(__func__ "" HAVE_FUNC) | |
155 | CHECK_SYMBOL_EXISTS(__PRETTY_FUNCTION__ "" HAVE_PRETTY_FUNC) | |
156 | ||
157 | include(CheckCXXSourceCompiles) | |
158 | CHECK_CXX_SOURCE_COMPILES(" | |
159 | #include <string.h> | |
160 | int main() { char x = *strerror_r(0, &x, sizeof(x)); return 0; } | |
161 | " STRERROR_R_CHAR_P) | |
162 | ||
163 | include(CheckStructHasMember) | |
164 | CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtim.tv_nsec sys/stat.h | |
165 | HAVE_STAT_ST_MTIM_TV_NSEC LANGUAGE C) | |
166 | CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec sys/stat.h | |
167 | HAVE_STAT_ST_MTIMESPEC_TV_NSEC LANGUAGE C) | |
168 | ||
169 | set(CEPH_MAN_DIR "share/man" CACHE STRING "Install location for man pages (relative to prefix).") | |
170 | ||
171 | option(ENABLE_SHARED "build shared libraries" ON) | |
172 | if(ENABLE_SHARED) | |
173 | set(CEPH_SHARED SHARED) | |
174 | else(ENABLE_SHARED) | |
175 | set(CEPH_SHARED STATIC) | |
176 | endif(ENABLE_SHARED) | |
177 | set(CMAKE_POSITION_INDEPENDENT_CODE ${ENABLE_SHARED}) | |
178 | ||
179 | option(WITH_RDMA "Enable RDMA in async messenger" ON) | |
180 | if(WITH_RDMA) | |
181 | find_package(rdma REQUIRED) | |
182 | set(HAVE_RDMA ${RDMA_FOUND}) | |
183 | endif(WITH_RDMA) | |
184 | ||
185 | find_package(Backtrace) | |
186 | ||
187 | if(LINUX) | |
188 | find_package(udev REQUIRED) | |
189 | set(HAVE_UDEV ${UDEV_FOUND}) | |
190 | ||
191 | find_package(aio REQUIRED) | |
192 | set(HAVE_LIBAIO ${AIO_FOUND}) | |
193 | ||
194 | find_package(blkid REQUIRED) | |
195 | set(HAVE_BLKID ${BLKID_FOUND}) | |
196 | else() | |
197 | set(HAVE_UDEV OFF) | |
198 | message(STATUS "Not using udev") | |
199 | set(HAVE_LIBAIO OFF) | |
200 | message(STATUS "Not using AIO") | |
201 | set(HAVE_BLKID OFF) | |
202 | message(STATUS "Not using BLKID") | |
203 | endif(LINUX) | |
204 | ||
205 | option(WITH_OPENLDAP "OPENLDAP is here" ON) | |
206 | if(${WITH_OPENLDAP}) | |
207 | find_package(OpenLdap REQUIRED) | |
208 | set(HAVE_OPENLDAP ${OPENLDAP_FOUND}) | |
209 | endif(${WITH_OPENLDAP}) | |
210 | ||
211 | option(WITH_FUSE "Fuse is here" ON) | |
212 | if(${WITH_FUSE}) | |
213 | find_package(fuse) | |
214 | set(HAVE_LIBFUSE ${FUSE_FOUND}) | |
215 | endif(${WITH_FUSE}) | |
216 | ||
217 | option(WITH_XFS "XFS is here" ON) | |
224ce89b WB |
218 | if(WITH_XFS) |
219 | find_package(xfs) | |
220 | set(HAVE_LIBXFS ${XFS_FOUND}) | |
221 | endif() | |
222 | ||
223 | option(WITH_ZFS "enable LibZFS if found" OFF) | |
224 | if(WITH_ZFS) | |
225 | find_package(zfs) | |
226 | set(HAVE_LIBZFS ${ZFS_FOUND}) | |
227 | endif() | |
7c673cae FG |
228 | |
229 | option(WITH_SPDK "Enable SPDK" OFF) | |
230 | if(WITH_SPDK) | |
231 | find_package(dpdk REQUIRED) | |
232 | set(HAVE_SPDK TRUE) | |
233 | endif(WITH_SPDK) | |
234 | ||
31f18b77 FG |
235 | option(WITH_PMEM "Enable PMEM" OFF) |
236 | if(WITH_PMEM) | |
237 | find_package(pmem REQUIRED) | |
238 | set(HAVE_PMEM ${PMEM_FOUND}) | |
239 | endif(WITH_PMEM) | |
240 | ||
7c673cae FG |
241 | # needs mds and? XXX |
242 | option(WITH_LIBCEPHFS "libcephfs client library" ON) | |
243 | ||
244 | # key-value store | |
245 | option(WITH_KVS "Key value store is here" ON) | |
246 | ||
247 | # remote block storage | |
248 | option(WITH_RBD "Remote block storage is here" ON) | |
249 | ||
250 | # KERNEL remote block storage | |
251 | option(WITH_KRBD "Kernel Remote block storage is here" ON) | |
252 | ||
253 | if(WITH_KRBD AND WITHOUT_RBD) | |
254 | message(FATAL_ERROR "Cannot have WITH_KRBD with WITH_RBD.") | |
255 | endif() | |
256 | ||
257 | # embedded ceph daemon static library | |
258 | # NOTE: Ceph is mostly LGPL (see COPYING), which means that | |
259 | # static linking brings with it restrictions. Please be sure | |
260 | # to look at the LGPL license carefully before linking this library to | |
261 | # your code. See http://www.gnu.org/licenses/gpl-faq.html#LGPLStaticVsDynamic. | |
262 | option(WITH_EMBEDDED "build the embedded ceph daemon library" ON) | |
263 | ||
264 | option(WITH_LEVELDB "LevelDB is here" ON) | |
265 | if(WITH_LEVELDB) | |
266 | if(LEVELDB_PREFIX) | |
267 | include_directories(${LEVELDB_PREFIX}/include) | |
268 | link_directories(${LEVELDB_PREFIX}/lib) | |
269 | endif() | |
270 | find_package(leveldb REQUIRED) | |
271 | find_file(HAVE_LEVELDB_FILTER_POLICY leveldb/filter_policy.h PATHS ${LEVELDB_INCLUDE_DIR}) | |
272 | endif(WITH_LEVELDB) | |
273 | ||
7c673cae FG |
274 | find_package(snappy REQUIRED) |
275 | ||
31f18b77 FG |
276 | option(WITH_LZ4 "LZ4 compression support" OFF) |
277 | if(WITH_LZ4) | |
b5b8bbf5 | 278 | find_package(LZ4 1.7 REQUIRED) |
31f18b77 FG |
279 | set(HAVE_LZ4 ${LZ4_FOUND}) |
280 | endif(WITH_LZ4) | |
281 | ||
7c673cae FG |
282 | #if allocator is set on command line make sure it matches below strings |
283 | if(ALLOCATOR) | |
284 | if(${ALLOCATOR} MATCHES "tcmalloc(_minimal)?") | |
285 | find_package(gperftools REQUIRED) | |
286 | set(HAVE_LIBTCMALLOC ON) | |
287 | elseif(${ALLOCATOR} STREQUAL "jemalloc") | |
288 | find_package(JeMalloc REQUIRED) | |
289 | set(HAVE_LIBJEMALLOC ${JEMALLOC_FOUND}) | |
290 | set(HAVE_JEMALLOC 1) | |
291 | endif() | |
292 | else(ALLOCATOR) | |
293 | find_package(gperftools) | |
294 | set(HAVE_LIBTCMALLOC ${GPERFTOOLS_FOUND}) | |
295 | if(NOT GPERFTOOLS_FOUND) | |
296 | find_package(JeMalloc) | |
297 | set(HAVE_LIBJEMALLOC ${JEMALLOC_FOUND}) | |
298 | endif(NOT GPERFTOOLS_FOUND) | |
299 | if(GPERFTOOLS_FOUND) | |
300 | set(ALLOCATOR tcmalloc) | |
301 | elseif(JEMALLOC_FOUND) | |
302 | set(ALLOCATOR jemalloc) | |
303 | else() | |
304 | if(NOT FREEBSD) | |
305 | # FreeBSD already has jemalloc as its default allocator | |
306 | message(WARNING "tcmalloc and jemalloc not found, falling back to libc") | |
307 | endif() | |
308 | set(ALLOCATOR "libc") | |
309 | endif(GPERFTOOLS_FOUND) | |
310 | endif(ALLOCATOR) | |
311 | ||
312 | ||
313 | if(WITH_LIBCEPHFS OR WITH_KRBD) | |
314 | find_package(keyutils REQUIRED) | |
315 | endif() | |
316 | ||
317 | find_package(CURL REQUIRED) | |
318 | set(CMAKE_REQUIRED_INCLUDES ${CURL_INCLUDE_DIRS}) | |
319 | set(CMAKE_REQUIRED_LIBRARIES ${CURL_LIBRARIES}) | |
320 | CHECK_SYMBOL_EXISTS(curl_multi_wait curl/curl.h HAVE_CURL_MULTI_WAIT) | |
321 | ||
322 | # nss or cryptopp? | |
323 | option(WITH_NSS "Use NSS crypto and SSL implementations" ON) | |
324 | if (${WITH_NSS}) | |
325 | find_package(NSS REQUIRED) | |
326 | set(USE_NSS 1) | |
327 | find_package(NSPR REQUIRED) | |
328 | set(CRYPTO_LIBS ${NSS_LIBRARIES} ${NSPR_LIBRARIES}) | |
329 | else () | |
330 | find_package(cryptopp REQUIRED) | |
331 | set(CRYPTO_LIBS ${CRYPTOPP_LIBRARIES}) | |
332 | set(USE_CRYPTOPP 1) | |
333 | endif (${WITH_NSS}) | |
334 | ||
335 | option(WITH_SSL "SSL build selected" ON) | |
336 | if(USE_NSS) | |
337 | #nss | |
338 | set(SSL_LIBRARIES ${NSS_LIBRARIES}) | |
339 | message(STATUS "SSL with NSS selected (Libs: ${SSL_LIBRARIES})") | |
340 | else(USE_NSS) | |
341 | #openssl | |
342 | find_package(OpenSSL REQUIRED) | |
343 | set(USE_OPENSSL ON) | |
344 | set(SSL_LIBRARIES ${OPENSSL_LIBRARIES}) | |
345 | message(STATUS "SSL with OpenSSL selected (Libs: ${SSL_LIBRARIES})") | |
346 | endif(USE_NSS) | |
347 | ||
348 | option(WITH_XIO "Enable XIO messaging" OFF) | |
349 | if(WITH_XIO) | |
350 | find_package(xio REQUIRED) | |
351 | set(HAVE_XIO ${XIO_FOUND}) | |
352 | endif(WITH_XIO) | |
353 | ||
354 | option(WITH_DPDK "Enable DPDK messaging" OFF) | |
355 | if(WITH_DPDK) | |
356 | find_package(dpdk) | |
357 | set(HAVE_DPDK ${DPDK_FOUND}) | |
358 | endif(WITH_DPDK) | |
359 | ||
360 | option(WITH_BLKIN "Use blkin to emit LTTng tracepoints for Zipkin" OFF) | |
361 | if(WITH_BLKIN) | |
362 | set(BLKIN_LIBRARIES blkin lttng-ust) | |
363 | include_directories(src/blkin/blkin-lib) | |
364 | endif(WITH_BLKIN) | |
365 | ||
b32b8144 FG |
366 | option(WITH_BOOST_CONTEXT "Enable boost::asio stackful coroutines" ON) |
367 | if(WITH_BOOST_CONTEXT) | |
368 | set(HAVE_BOOST_CONTEXT ON) | |
369 | endif() | |
370 | ||
7c673cae FG |
371 | #option for RGW |
372 | option(WITH_RADOSGW "Rados Gateway is enabled" ON) | |
31f18b77 | 373 | option(WITH_RADOSGW_FCGI_FRONTEND "Rados Gateway's FCGI frontend is enabled" OFF) |
7c673cae FG |
374 | option(WITH_RADOSGW_BEAST_FRONTEND "Rados Gateway's Beast frontend is enabled" ON) |
375 | if(WITH_RADOSGW) | |
376 | find_package(EXPAT REQUIRED) | |
377 | if(WITH_RADOSGW_FCGI_FRONTEND) | |
378 | find_package(fcgi REQUIRED) | |
379 | endif() | |
b32b8144 FG |
380 | if(WITH_RADOSGW_BEAST_FRONTEND AND NOT WITH_BOOST_CONTEXT) |
381 | message(WARNING "disabling WITH_RADOSGW_BEAST_FRONTEND, which depends on WITH_BOOST_CONTEXT") | |
382 | set(WITH_RADOSGW_BEAST_FRONTEND OFF) | |
383 | endif() | |
7c673cae FG |
384 | endif(WITH_RADOSGW) |
385 | ||
386 | ||
387 | if (WITH_RADOSGW) | |
388 | if (NOT DEFINED OPENSSL_FOUND) | |
389 | message(STATUS "Looking for openssl anyways, because radosgw selected") | |
390 | find_package(OpenSSL) | |
391 | endif() | |
94b18763 FG |
392 | # https://curl.haxx.se/docs/install.html mentions the |
393 | # configure flags for various ssl backends | |
394 | execute_process( | |
395 | COMMAND | |
396 | "sh" "-c" | |
397 | "curl-config --configure | grep with-ssl" | |
398 | RESULT_VARIABLE NO_CURL_SSL_LINK | |
399 | ERROR_VARIABLE CURL_CONFIG_ERRORS | |
400 | ) | |
401 | if (CURL_CONFIG_ERRORS) | |
402 | message(WARNING "unable to run curl-config; rgw cannot make ssl requests to external systems reliably") | |
403 | endif() | |
404 | find_package(OpenSSL) | |
7c673cae | 405 | if (OPENSSL_FOUND) |
94b18763 FG |
406 | if (NOT NO_CURL_SSL_LINK) |
407 | message(STATUS "libcurl is linked with openssl: explicitly setting locks") | |
408 | set(WITH_CURL_OPENSSL ON) | |
409 | endif() # CURL_SSL_LINK | |
7c673cae FG |
410 | execute_process( |
411 | COMMAND | |
412 | "sh" "-c" | |
413 | "objdump -p ${OPENSSL_SSL_LIBRARY} | sed -n 's/^ SONAME *//p'" | |
414 | OUTPUT_VARIABLE LIBSSL_SONAME | |
415 | ERROR_VARIABLE OBJDUMP_ERRORS | |
416 | RESULT_VARIABLE OBJDUMP_RESULTS | |
417 | OUTPUT_STRIP_TRAILING_WHITESPACE) | |
418 | if (OBJDUMP_RESULTS) | |
419 | message(FATAL_ERROR "can't run objdump: ${OBJDUMP_RESULTS}") | |
420 | endif() | |
421 | if (NOT OBJDUMP_ERRORS STREQUAL "") | |
422 | message(WARNING "message from objdump: ${OBJDUMP_ERRORS}") | |
423 | endif() | |
424 | execute_process( | |
425 | COMMAND | |
426 | "sh" "-c" | |
427 | "objdump -p ${OPENSSL_CRYPTO_LIBRARY} | sed -n 's/^ SONAME *//p'" | |
428 | OUTPUT_VARIABLE LIBCRYPTO_SONAME | |
429 | ERROR_VARIABLE OBJDUMP_ERRORS | |
430 | RESULT_VARIABLE OBJDUMP_RESULTS | |
431 | OUTPUT_STRIP_TRAILING_WHITESPACE) | |
432 | if (OBJDUMP_RESULTS) | |
433 | message(FATAL_ERROR "can't run objdump: ${OBJDUMP_RESULTS}") | |
434 | endif() | |
435 | if (NOT OBJDUMP_ERRORS STREQUAL "") | |
436 | message(WARNING "message from objdump: ${OBJDUMP_ERRORS}") | |
437 | endif() | |
438 | message(STATUS "ssl soname: ${LIBSSL_SONAME}") | |
439 | message(STATUS "crypto soname: ${LIBCRYPTO_SONAME}") | |
440 | else() | |
441 | message(WARNING "ssl not found: rgw civetweb may fail to dlopen libssl libcrypto") | |
94b18763 | 442 | endif() # OPENSSL_FOUND |
7c673cae FG |
443 | endif (WITH_RADOSGW) |
444 | ||
445 | #option for CephFS | |
446 | option(WITH_CEPHFS "CephFS is enabled" ON) | |
447 | ||
448 | #option for Mgr | |
449 | option(WITH_MGR "ceph-mgr is enabled" ON) | |
450 | if(WITH_MGR) | |
451 | set(Python_ADDITIONAL_VERSIONS 2.7) | |
452 | find_package(PythonInterp 2.7 REQUIRED) | |
453 | find_package(PythonLibs 2.7 REQUIRED) | |
454 | # Boost dependency check deferred to Boost section | |
455 | endif(WITH_MGR) | |
456 | ||
457 | option(WITH_THREAD_SAFE_RES_QUERY "res_query is thread safe" OFF) | |
458 | if(WITH_THREAD_SAFE_RES_QUERY) | |
459 | set(HAVE_THREAD_SAFE_RES_QUERY 1 CACHE INTERNAL "Thread safe res_query supported.") | |
460 | endif(WITH_THREAD_SAFE_RES_QUERY) | |
461 | ||
462 | option(WITH_REENTRANT_STRSIGNAL "strsignal is reentrant" OFF) | |
463 | if(WITH_REENTRANT_STRSIGNAL) | |
464 | set(HAVE_REENTRANT_STRSIGNAL 1 CACHE INTERNAL "Reentrant strsignal is supported.") | |
465 | endif(WITH_REENTRANT_STRSIGNAL) | |
466 | ||
467 | set(HAVE_LIBROCKSDB 1) | |
468 | ||
469 | # -lz link into kv | |
470 | find_package(ZLIB REQUIRED) | |
471 | ||
472 | #option for EventTrace | |
473 | option(WITH_EVENTTRACE "Event tracing support" OFF) | |
474 | ||
475 | #option for LTTng | |
476 | option(WITH_LTTNG "LTTng tracing is enabled" ON) | |
477 | if(${WITH_LTTNG}) | |
478 | find_package(LTTngUST REQUIRED) | |
479 | find_program(LTTNG_GEN_TP | |
480 | lttng-gen-tp) | |
481 | if(NOT LTTNG_GEN_TP) | |
482 | message(FATAL_ERROR "Can't find lttng-gen-tp.") | |
483 | endif() | |
484 | endif(${WITH_LTTNG}) | |
485 | ||
31f18b77 FG |
486 | option(WITH_OSD_INSTRUMENT_FUNCTIONS OFF) |
487 | ||
7c673cae | 488 | #option for Babeltrace |
224ce89b WB |
489 | option(WITH_BABELTRACE "Babeltrace libraries are enabled" ON) |
490 | if(WITH_BABELTRACE) | |
491 | set(HAVE_BABELTRACE ON) | |
7c673cae | 492 | find_package(babeltrace REQUIRED) |
7c673cae FG |
493 | set(HAVE_BABELTRACE_BABELTRACE_H ${BABELTRACE_FOUND}) |
494 | set(HAVE_BABELTRACE_CTF_EVENTS_H ${BABELTRACE_FOUND}) | |
495 | set(HAVE_BABELTRACE_CTF_ITERATOR_H ${BABELTRACE_FOUND}) | |
224ce89b | 496 | endif(WITH_BABELTRACE) |
7c673cae FG |
497 | |
498 | option(DEBUG_GATHER "C_Gather debugging is enabled" ON) | |
7c673cae FG |
499 | option(ENABLE_COVERAGE "Coverage is enabled" OFF) |
500 | option(PG_DEBUG_REFS "PG Ref debugging is enabled" OFF) | |
501 | ||
502 | option(WITH_TESTS "enable the build of ceph-test package scripts/binaries" ON) | |
503 | ||
504 | option(WITH_FIO "Support for fio engines" OFF) | |
505 | if(WITH_FIO) | |
506 | find_package(fio REQUIRED) | |
507 | endif(WITH_FIO) | |
508 | ||
509 | if(LINUX) | |
510 | add_definitions(-D__linux__) | |
511 | endif(LINUX) | |
512 | ||
513 | # ASAN and friends | |
514 | option(WITH_ASAN "build with ASAN" OFF) | |
515 | option(WITH_ASAN_LEAK "explicitly enable ASAN leak detection" OFF) | |
516 | ||
517 | if(WITH_ASAN) | |
518 | set(ASAN_CFLAGS "-fsanitize=address -fno-omit-frame-pointer") | |
519 | if(WITH_ASAN_LEAK) | |
520 | set(ASAN_CFLAGS "${ASAN_CFLAGS} -fsanitize=leak") | |
521 | endif() | |
522 | set(ASAN_LFLAGS "${CMAKE_EXE_LINKER_FLAGS} ${ASAN_CFLAGS} -lasan") | |
523 | set(CMAKE_EXE_LINKER_FLAGS "${ASAN_LFLAGS}") | |
524 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ASAN_CFLAGS}") | |
525 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ASAN_CFLAGS}") | |
526 | if(HAVE_JEMALLOC) | |
527 | message(FATAL "ASAN does not work well with JeMalloc") | |
528 | endif() | |
529 | endif() | |
530 | ||
531 | option(WITH_TSAN "build with TSAN" OFF) | |
532 | if(WITH_TSAN) | |
533 | if (WITH_ASAN AND WITH_ASAN_LEAK) | |
534 | message(FATAL_ERROR "Cannot combine -fsanitize-leak w/-fsanitize-thread") | |
535 | endif() | |
536 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread -fno-omit-frame-pointer -pie -ltsan ") | |
537 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer -fPIC") | |
538 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread -fno-omit-frame-pointer -fPIC") | |
539 | if(HAVE_JEMALLOC) | |
540 | message(FATAL "TSAN does not work well with JeMalloc") | |
541 | endif() | |
542 | endif() | |
543 | ||
544 | option(WITH_UBSAN "build with UBSAN" OFF) | |
545 | if(WITH_UBSAN) | |
546 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined") | |
547 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined") | |
548 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined") | |
549 | if(HAVE_JEMALLOC) | |
550 | message(FATAL "UBSAN does not work well with JeMalloc") | |
551 | endif() | |
552 | endif() | |
553 | ||
554 | # Rocksdb | |
555 | option(WITH_SYSTEM_ROCKSDB "require and build with system rocksdb" OFF) | |
556 | if (WITH_SYSTEM_ROCKSDB) | |
557 | find_package(rocksdb REQUIRED) | |
558 | endif() | |
559 | ||
560 | # Boost | |
561 | option(WITH_SYSTEM_BOOST "require and build with system Boost" OFF) | |
562 | ||
31f18b77 | 563 | # Boost::thread depends on Boost::atomic, so list it explicitly. |
7c673cae | 564 | set(BOOST_COMPONENTS |
31f18b77 FG |
565 | atomic thread system regex random program_options date_time iostreams |
566 | filesystem) | |
567 | set(BOOST_HEADER_COMPONENTS container) | |
568 | ||
7c673cae FG |
569 | if(WITH_MGR) |
570 | list(APPEND BOOST_COMPONENTS python) | |
571 | endif() | |
b32b8144 FG |
572 | if(WITH_BOOST_CONTEXT) |
573 | list(APPEND BOOST_COMPONENTS context coroutine) | |
31f18b77 FG |
574 | endif() |
575 | ||
576 | set(Boost_USE_MULTITHREADED ON) | |
577 | # require minimally the bundled version | |
578 | if(WITH_SYSTEM_BOOST) | |
7c673cae FG |
579 | if(ENABLE_SHARED) |
580 | set(Boost_USE_STATIC_LIBS OFF) | |
581 | else() | |
582 | set(Boost_USE_STATIC_LIBS ON) | |
583 | endif() | |
b32b8144 | 584 | find_package(Boost 1.66 COMPONENTS ${BOOST_COMPONENTS} REQUIRED) |
7c673cae | 585 | else() |
7c673cae FG |
586 | set(BOOST_J 1 CACHE STRING |
587 | "max jobs for Boost build") # override w/-DBOOST_J=<n> | |
7c673cae | 588 | set(Boost_USE_STATIC_LIBS ON) |
31f18b77 | 589 | include(BuildBoost) |
b32b8144 | 590 | build_boost(1.66 |
31f18b77 FG |
591 | COMPONENTS ${BOOST_COMPONENTS} ${BOOST_HEADER_COMPONENTS}) |
592 | include_directories(BEFORE SYSTEM ${Boost_INCLUDE_DIRS}) | |
7c673cae | 593 | endif() |
7c673cae FG |
594 | set(Boost_USE_MULTITHREADED ON) |
595 | ||
7c673cae FG |
596 | include_directories(SYSTEM ${PROJECT_BINARY_DIR}/include) |
597 | ||
7c673cae FG |
598 | find_package(Threads REQUIRED) |
599 | ||
600 | option(WITH_SELINUX "build SELinux policy" OFF) | |
601 | if(WITH_SELINUX) | |
602 | find_file(SELINUX_MAKEFILE selinux/devel/Makefile | |
603 | PATH /usr/share) | |
604 | if(NOT SELINUX_MAKEFILE) | |
605 | message(FATAL_ERROR "Can't find selinux's Makefile") | |
606 | endif() | |
607 | add_subdirectory(selinux) | |
608 | endif(WITH_SELINUX) | |
609 | ||
610 | # enables testing and creates Make check command | |
611 | add_custom_target(tests | |
612 | COMMENT "Building tests") | |
613 | enable_testing() | |
614 | set(CMAKE_CTEST_COMMAND ctest) | |
615 | add_custom_target(check | |
616 | COMMAND ${CMAKE_CTEST_COMMAND} | |
617 | DEPENDS tests) | |
618 | ||
619 | add_subdirectory(src) | |
620 | ||
621 | add_subdirectory(doc) | |
622 | if(WITH_MANPAGE) | |
623 | add_subdirectory(man) | |
624 | endif(WITH_MANPAGE) | |
625 | ||
626 | option(WITH_SYSTEMD "install systemd target and service files" OFF) | |
627 | if(WITH_SYSTEMD) | |
628 | add_subdirectory(systemd) | |
629 | endif() | |
630 | ||
b32b8144 FG |
631 | if(LINUX) |
632 | add_subdirectory(etc/sysctl) | |
633 | endif() | |
634 | ||
7c673cae FG |
635 | include(CTags) |
636 | option(CTAG_EXCLUDES "Exclude files/directories when running ctag.") | |
637 | add_tags(ctags | |
638 | SRC_DIR src | |
639 | TAG_FILE tags | |
640 | EXCLUDE_OPTS ${CTAG_EXCLUDES} | |
31f18b77 | 641 | EXCLUDES "*.js" "*.css") |
7c673cae | 642 | add_custom_target(tags DEPENDS ctags) |