Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: bump up required cmake version to 2.8.12 #18285

Merged
merged 6 commits into from
Oct 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 16 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.11)
cmake_minimum_required(VERSION 2.8.12)

project(ceph CXX C ASM)
set(VERSION 12.1.2)
Expand All @@ -7,15 +7,6 @@ if(POLICY CMP0046)
# Tweak policies (this one disables "missing" dependency warning)
cmake_policy(SET CMP0046 OLD)
endif()
# we use LINK_PRIVATE keyword instead of PRIVATE, but do not specify the LINK_PUBLIC
# for target_link_libraries() command when PUBLIC should be used instead, it's just
# for backward compatibility with cmake 2.8.11.
if (POLICY CMP0022)
cmake_policy(SET CMP0022 OLD)
endif (POLICY CMP0022)
if (POLICY CMP0023)
cmake_policy(SET CMP0023 OLD)
endif (POLICY CMP0023)
if(POLICY CMP0056)
cmake_policy(SET CMP0056 NEW)
endif()
Expand Down Expand Up @@ -492,40 +483,40 @@ option(WITH_ASAN "build with ASAN" OFF)
option(WITH_ASAN_LEAK "explicitly enable ASAN leak detection" OFF)

if(WITH_ASAN)
set(ASAN_CFLAGS "-fsanitize=address -fno-omit-frame-pointer")
list(APPEND SANITIZE_FLAGS "address")
if(WITH_ASAN_LEAK)
set(ASAN_CFLAGS "${ASAN_CFLAGS} -fsanitize=leak")
list(APPEND SANITIZE_FLAGS "leak")
endif()
set(ASAN_LFLAGS "${CMAKE_EXE_LINKER_FLAGS} ${ASAN_CFLAGS} -lasan")
set(CMAKE_EXE_LINKER_FLAGS "${ASAN_LFLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ASAN_CFLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ASAN_CFLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lasan")
if(HAVE_JEMALLOC)
message(FATAL "ASAN does not work well with JeMalloc")
endif()
endif()

option(WITH_TSAN "build with TSAN" OFF)
if(WITH_TSAN)
if (WITH_ASAN AND WITH_ASAN_LEAK)
if(WITH_ASAN AND WITH_ASAN_LEAK)
message(FATAL_ERROR "Cannot combine -fsanitize-leak w/-fsanitize-thread")
endif()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread -fno-omit-frame-pointer -pie -ltsan ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer -fPIC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread -fno-omit-frame-pointer -fPIC")
if(HAVE_JEMALLOC)
elseif(HAVE_JEMALLOC)
message(FATAL "TSAN does not work well with JeMalloc")
endif()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie -ltsan")
list(APPEND SANITIZE_FLAGS "thread")
endif()

option(WITH_UBSAN "build with UBSAN" OFF)
if(WITH_UBSAN)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined")
if(HAVE_JEMALLOC)
message(FATAL "UBSAN does not work well with JeMalloc")
endif()
list(APPEND SANITIZE_FLAGS "undefined")
endif()

if(SANITIZE_FLAGS)
string(REPLACE ";" "," SANITIZE_FLAGS "${SANITIZE_FLAGS}")
set(SANITIZE_CFLAGS "-fsanitize=${SANITIZE_FLAGS} -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZE_CFLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZE_CFLAGS}")
endif()

# Rocksdb
Expand Down
8 changes: 5 additions & 3 deletions cmake/modules/Findgperftools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ if(Tcmalloc_INCLUDE_DIR AND EXISTS "${Tcmalloc_INCLUDE_DIR}/gperftools/tcmalloc.
foreach(ver "MAJOR" "MINOR" "PATCH")
file(STRINGS "${Tcmalloc_INCLUDE_DIR}/gperftools/tcmalloc.h" TC_VER_${ver}_LINE
REGEX "^#define[ \t]+TC_VERSION_${ver}[ \t]+[^ \t]+$")
string(REGEX REPLACE "^#define[ \t]+TC_VERSION_${ver}[ \t]+(\".)?([0-9]+)\"?$"
string(REGEX REPLACE "^#define[ \t]+TC_VERSION_${ver}[ \t]+(\".)?([0-9]*)\"?$"
"\\2" TCMALLOC_VERSION_${ver} "${TC_VER_${ver}_LINE}")
unset(TC_VER_${ver}_LINE)
endforeach()
set(TCMALLOC_VERSION_STRING
"${TCMALLOC_VERSION_MAJOR}.${TCMALLOC_VERSION_MINOR}.${TCMALLOC_VERSION_PATCH}")
set(TCMALLOC_VERSION_STRING "${TCMALLOC_VERSION_MAJOR}.${TCMALLOC_VERSION_MINOR}")
if(NOT TCMALLOC_VERSION_PATCH STREQUAL "")
set(TCMALLOC_VERSION_STRING "${TCMALLOC_VERSION_STRING}.${TCMALLOC_VERSION_PATCH}")
endif()
endif()

foreach(component tcmalloc tcmalloc_minimal profiler)
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ add_subdirectory(client)
if(WITH_LIBCEPHFS)
set(libcephfs_srcs libcephfs.cc)
add_library(cephfs ${CEPH_SHARED} ${libcephfs_srcs})
target_link_libraries(cephfs LINK_PRIVATE client ceph-common
target_link_libraries(cephfs PRIVATE client ceph-common
${CRYPTO_LIBS} ${EXTRALIBS})
if(ENABLE_SHARED)
set_target_properties(cephfs PROPERTIES
Expand Down
2 changes: 1 addition & 1 deletion src/java/native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set_target_properties(cephfs_jni PROPERTIES
SOVERSION 1)
add_dependencies(cephfs_jni jni-header)
include_directories(${JNI_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(cephfs_jni LINK_PRIVATE cephfs ceph-common
target_link_libraries(cephfs_jni PRIVATE cephfs ceph-common
${EXTRALIBS} ${JNI_LIBRARIES})
install(TARGETS cephfs_jni
DESTINATION ${CMAKE_INSTALL_LIBDIR})
9 changes: 3 additions & 6 deletions src/librados/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@ if(ENABLE_SHARED)
$<TARGET_OBJECTS:librados_api_obj>
$<TARGET_OBJECTS:librados_objs>
$<TARGET_OBJECTS:common_buffer_obj>)
# LINK_PRIVATE instead of PRIVATE is used to backward compatibility with cmake 2.8.11
target_link_libraries(librados LINK_PRIVATE osdc ceph-common cls_lock_client
target_link_libraries(librados PRIVATE osdc ceph-common cls_lock_client
${BLKID_LIBRARIES} ${CRYPTO_LIBS} ${EXTRALIBS})
set_target_properties(librados PROPERTIES
OUTPUT_NAME rados
VERSION 2.0.0
SOVERSION 2
# use COMPILE_FLAGS for the backward compatibility with cmake 2.8.11, should have been:
# CXX_VISIBILITY_PRESET hidden
# VISIBILITY_INLINES_HIDDEN ON
COMPILE_FLAGS "-fvisibility=hidden -fvisibility-inlines-hidden")
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON)
if(NOT APPLE)
set_property(TARGET librados APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--exclude-libs,ALL")
Expand Down
7 changes: 4 additions & 3 deletions src/librbd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ endif()
add_library(librbd ${CEPH_SHARED}
librbd.cc)

target_link_libraries(librbd LINK_PRIVATE
target_link_libraries(librbd PRIVATE
rbd_internal
rbd_types
journal
Expand All @@ -128,15 +128,16 @@ target_link_libraries(librbd LINK_PRIVATE
${CMAKE_DL_LIBS}
${EXTRALIBS})
if(HAVE_UDEV)
target_link_libraries(librbd LINK_PRIVATE
target_link_libraries(librbd PRIVATE
udev)
endif()
if(ENABLE_SHARED)
set_target_properties(librbd PROPERTIES
OUTPUT_NAME rbd
VERSION 1.12.0
SOVERSION 1
COMPILE_FLAGS "-fvisibility=hidden -fvisibility-inlines-hidden")
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON)
if(NOT APPLE)
set_property(TARGET librbd APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--exclude-libs,ALL")
Expand Down
2 changes: 1 addition & 1 deletion src/os/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ if(WITH_SPDK)
foreach(lib nvme log env_dpdk util)
add_library(spdk_${lib} STATIC IMPORTED)
add_dependencies(spdk_${lib} build_spdk)
target_link_libraries(os LINK_PRIVATE spdk_${lib})
target_link_libraries(os PRIVATE spdk_${lib})
set_target_properties(spdk_${lib} PROPERTIES
IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/src/spdk/build/lib/libspdk_${lib}.a"
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/src/spdk/include")
Expand Down
2 changes: 1 addition & 1 deletion src/rbd_replay/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set(librbd_replay_srcs
rbd_loc.cc
Replayer.cc)
add_library(rbd_replay STATIC ${librbd_replay_srcs})
target_link_libraries(rbd_replay LINK_PRIVATE librbd librados global)
target_link_libraries(rbd_replay PRIVATE librbd librados global)

add_executable(rbd-replay
rbd-replay.cc)
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ set(librgw_srcs
librgw.cc
rgw_file.cc)
add_library(rgw SHARED ${librgw_srcs})
target_link_libraries(rgw LINK_PRIVATE
target_link_libraries(rgw PRIVATE
rgw_a
librados
cls_rgw_client
Expand Down