mirror of
https://github.com/ceph/ceph
synced 2025-03-11 02:39:05 +00:00
Merge pull request #23300 from tchaikov/wip-cmake-cleanup
cmake: cleanups Reviewed-by: Willem Jan Withagen <wjw@digiware.nl> Reviewed-by: Casey Bodley <cbodley@redhat.com>
This commit is contained in:
commit
0912caefa9
@ -382,14 +382,11 @@ endif()
|
||||
option(WITH_DPDK "Enable DPDK messaging" OFF)
|
||||
if(WITH_DPDK)
|
||||
find_package(dpdk)
|
||||
set(HAVE_DPDK ${DPDK_FOUND})
|
||||
if(NOT TARGET dpdk-ext)
|
||||
find_package(dpdk)
|
||||
if(NOT DPDK_FOUND)
|
||||
include(BuildDPDK)
|
||||
build_dpdk()
|
||||
endif()
|
||||
if(NOT DPDK_FOUND AND NOT TARGET dpdk-ext)
|
||||
include(BuildDPDK)
|
||||
build_dpdk()
|
||||
endif()
|
||||
set(HAVE_DPDK TRUE)
|
||||
endif()
|
||||
|
||||
option(WITH_BLKIN "Use blkin to emit LTTng tracepoints for Zipkin" OFF)
|
||||
@ -655,18 +652,6 @@ include_directories(SYSTEM ${PROJECT_BINARY_DIR}/include)
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
execute_process(
|
||||
COMMAND ./librarytest.sh ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_FLAGS}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE CXX_STDLIB
|
||||
)
|
||||
|
||||
if(CXX_STDLIB STREQUAL "libstdc++" OR CXX_STDLIB STREQUAL "libc++")
|
||||
message(STATUS "We are using ${CXX_STDLIB}.")
|
||||
else()
|
||||
message(FATAL_ERROR
|
||||
"Unable to determine C++ standard library, got ${CXX_STDLIB}.")
|
||||
endif()
|
||||
|
||||
option(WITH_SELINUX "build SELinux policy" OFF)
|
||||
if(WITH_SELINUX)
|
||||
|
41
cmake/modules/CheckYasm.cmake
Normal file
41
cmake/modules/CheckYasm.cmake
Normal file
@ -0,0 +1,41 @@
|
||||
macro(check_yasm_support _object_format _good_result _better_result)
|
||||
execute_process(
|
||||
COMMAND yasm -f "${_object_format}" ${CMAKE_SOURCE_DIR}/src/common/crc32c_intel_fast_asm.s -o /dev/null
|
||||
RESULT_VARIABLE no_yasm
|
||||
OUTPUT_QUIET)
|
||||
if(NOT no_yasm)
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64")
|
||||
set(save_quiet ${CMAKE_REQUIRED_QUIET})
|
||||
set(CMAKE_REQUIRED_QUIET true)
|
||||
include(CheckCXXSourceCompiles)
|
||||
check_cxx_source_compiles("
|
||||
#if defined(__x86_64__) && defined(__ILP32__)
|
||||
#error x32
|
||||
#endif
|
||||
int main() {}
|
||||
" not_arch_x32)
|
||||
set(CMAKE_REQUIRED_QUIET ${save_quiet})
|
||||
if(not_arch_x32)
|
||||
set(${_good_result} TRUE)
|
||||
execute_process(COMMAND yasm -f ${object_format} -i
|
||||
${CMAKE_SOURCE_DIR}/src/isa-l/include/
|
||||
${CMAKE_SOURCE_DIR}/src/isa-l/erasure_code/gf_vect_dot_prod_avx2.asm
|
||||
-o /dev/null
|
||||
RESULT_VARIABLE rc
|
||||
OUTPUT_QUIET)
|
||||
if(NOT rc)
|
||||
set(${_better_result} TRUE)
|
||||
endif(NOT rc)
|
||||
endif(not_arch_x32)
|
||||
endif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64")
|
||||
endif(NOT no_yasm)
|
||||
if(no_yasm)
|
||||
message(STATUS "Could NOT find Yasm")
|
||||
elseif(NOT not_arch_x32)
|
||||
message(STATUS "Found Yasm: but x86_64 with x32 ABI is not supported")
|
||||
elseif(${_better_result})
|
||||
message(STATUS "Found Yasm: good -- capable of assembling x86_64")
|
||||
elseif(${_good_result})
|
||||
message(STATUS "Found Yasm: better -- capable of assembling AVX2")
|
||||
endif()
|
||||
endmacro()
|
37
cmake/modules/FindStdFilesystem.cmake
Normal file
37
cmake/modules/FindStdFilesystem.cmake
Normal file
@ -0,0 +1,37 @@
|
||||
set(_std_filesystem_test_src
|
||||
${CMAKE_CURRENT_LIST_DIR}/FindStdFilesystem_test.cc)
|
||||
|
||||
macro(try_std_filesystem_library _library _result)
|
||||
try_compile(_std_filesystem_compiles
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
SOURCES ${_std_filesystem_test_src}
|
||||
CMAKE_FLAGS -DCMAKE_CXX_FLAGS="-std=c++17"
|
||||
LINK_LIBRARIES ${_library})
|
||||
if(_std_filesystem_compiles)
|
||||
set(${_result} ${_library})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
if(NOT StdFilesystem_LIBRARY)
|
||||
try_std_filesystem_library("stdc++fs" StdFilesystem_LIBRARY)
|
||||
endif()
|
||||
if(NOT StdFilesystem_LIBRARY)
|
||||
try_std_filesystem_library("c++experimental" StdFilesystem_LIBRARY)
|
||||
endif()
|
||||
if(NOT StdFilesystem_LIBRARY)
|
||||
try_std_filesystem_library("c++fs" StdFilesystem_LIBRARY)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(StdFilesystem
|
||||
FOUND_VAR StdFilesystem_FOUND
|
||||
REQUIRED_VARS StdFilesystem_LIBRARY)
|
||||
|
||||
mark_as_advanced(StdFilesystem_LIBRARY)
|
||||
|
||||
if(StdFilesystem_FOUND AND NOT (TARGET StdFilesystem::filesystem))
|
||||
add_library(StdFilesystem::filesystem INTERFACE IMPORTED)
|
||||
set_target_properties(StdFilesystem::filesystem PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES ${StdFilesystem_LIBRARY})
|
||||
endif()
|
13
cmake/modules/FindStdFilesystem_test.cc
Normal file
13
cmake/modules/FindStdFilesystem_test.cc
Normal file
@ -0,0 +1,13 @@
|
||||
#if __has_include(<filesystem>)
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#elif __has_include(<experimental/filesystem>)
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#else
|
||||
#error std::filesystem not available!
|
||||
#endif
|
||||
|
||||
int main() {
|
||||
[[maybe_unused]] fs::path path("/");
|
||||
}
|
@ -5,23 +5,23 @@
|
||||
# KEYUTILS_INCLUDE_DIR - the keyutils include directories
|
||||
# KEYUTILS_LIBRARIES - link these to use keyutils
|
||||
|
||||
if(KEYUTILS_INCLUDE_DIR AND KEYUTILS_LIBRARIES)
|
||||
set(KEYUTILS_FIND_QUIETLY TRUE)
|
||||
endif(KEYUTILS_INCLUDE_DIR AND KEYUTILS_LIBRARIES)
|
||||
|
||||
# include dir
|
||||
find_path(KEYUTILS_INCLUDE_DIR keyutils.h PATHS
|
||||
/opt/local/include
|
||||
/usr/local/include
|
||||
)
|
||||
|
||||
# finally the library itself
|
||||
find_library(LIBKEYUTILS NAMES keyutils)
|
||||
set(KEYUTILS_LIBRARIES ${LIBKEYUTILS})
|
||||
find_library(KEYUTILS_LIBRARIES NAMES keyutils)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set KEYUTILS_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(keyutils DEFAULT_MSG KEYUTILS_LIBRARIES KEYUTILS_INCLUDE_DIR)
|
||||
find_package_handle_standard_args(keyutils
|
||||
DEFAULT_MSG KEYUTILS_LIBRARIES KEYUTILS_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(KEYUTILS_LIBRARIES KEYUTILS_INCLUDE_DIR)
|
||||
|
||||
if(KEYUTILS_FOUND AND NOT (TARGET keyutils::keyutils))
|
||||
add_library(keyutils::keyutils UNKNOWN IMPORTED)
|
||||
set_target_properties(keyutils::keyutils PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${KEYUTILS_INCLUDE_DIR}"
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "${KEYUTILS_LIBRARIES}")
|
||||
endif()
|
||||
|
@ -1,17 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
CXX=$1
|
||||
|
||||
shift
|
||||
|
||||
echo "#include <utility>
|
||||
#if defined(_LIBCPP_VERSION)
|
||||
#define MYRESULT libc++
|
||||
#elif defined(__GLIBCXX__)
|
||||
#define MYRESULT libstdc++
|
||||
#else
|
||||
#define MYRESULT unknown
|
||||
#endif
|
||||
|
||||
HelloFriendsTheAnsWerIs MYRESULT" | ${CXX} -E -xc++ $* - | \
|
||||
grep "HelloFriendsTheAnsWerIs" | cut -f 2 -d ' ' | tr -d '\n'
|
@ -20,8 +20,6 @@ set(pkgdatadir ${CMAKE_INSTALL_FULL_DATADIR})
|
||||
set(datadir ${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME})
|
||||
set(prefix ${CMAKE_INSTALL_PREFIX})
|
||||
|
||||
add_definitions("-DCEPH_LIBDIR=\"${CMAKE_INSTALL_FULL_LIBDIR}\"")
|
||||
add_definitions("-DCEPH_PKGLIBDIR=\"${CMAKE_INSTALL_FULL_PKGLIBDIR}\"")
|
||||
add_definitions("-DHAVE_CONFIG_H -D__CEPH__ -D_REENTRANT -D_THREAD_SAFE -D__STDC_FORMAT_MACROS")
|
||||
add_definitions("-D_FILE_OFFSET_BITS=64")
|
||||
if(LINUX)
|
||||
@ -103,48 +101,12 @@ if(HAVE_INTEL)
|
||||
set(object_format "elf64")
|
||||
endif()
|
||||
set(CMAKE_ASM_FLAGS "-f ${object_format}")
|
||||
include(CheckYasm)
|
||||
check_yasm_support(${object_format}
|
||||
HAVE_GOOD_YASM_ELF64
|
||||
HAVE_BETTER_YASM_ELF64)
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND yasm -f "${object_format}" ${CMAKE_SOURCE_DIR}/src/common/crc32c_intel_fast_asm.s -o /dev/null
|
||||
RESULT_VARIABLE no_yasm
|
||||
OUTPUT_QUIET)
|
||||
if(no_yasm)
|
||||
message(STATUS " we do not have a modern/working yasm")
|
||||
else(no_yasm)
|
||||
message(STATUS " we have a modern and working yasm")
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64")
|
||||
message(STATUS " we are x86_64")
|
||||
set(save_quiet ${CMAKE_REQUIRED_QUIET})
|
||||
set(CMAKE_REQUIRED_QUIET true)
|
||||
include(CheckCXXSourceCompiles)
|
||||
check_cxx_source_compiles("
|
||||
#if defined(__x86_64__) && defined(__ILP32__)
|
||||
#error x32
|
||||
#endif
|
||||
int main() {}
|
||||
" not_arch_x32)
|
||||
set(CMAKE_REQUIRED_QUIET ${save_quiet})
|
||||
if(not_arch_x32)
|
||||
message(STATUS " we are not x32")
|
||||
set(HAVE_GOOD_YASM_ELF64 1)
|
||||
execute_process(COMMAND yasm -f ${object_format} -i
|
||||
${CMAKE_SOURCE_DIR}/src/isa-l/include/
|
||||
${CMAKE_SOURCE_DIR}/src/isa-l/erasure_code/gf_vect_dot_prod_avx2.asm
|
||||
-o /dev/null
|
||||
RESULT_VARIABLE rc
|
||||
OUTPUT_QUIET)
|
||||
if(NOT rc)
|
||||
set(HAVE_BETTER_YASM_ELF64 1)
|
||||
message(STATUS " yasm can also build the isa-l stuff")
|
||||
endif(NOT rc)
|
||||
else(not_arch_x32)
|
||||
message(STATUS " we are x32; no yasm for you")
|
||||
endif(not_arch_x32)
|
||||
else(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64")
|
||||
message(STATUS " we are not x86_64 && !x32")
|
||||
endif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64")
|
||||
endif(no_yasm)
|
||||
|
||||
# require c++17
|
||||
if(CMAKE_VERSION VERSION_LESS "3.8")
|
||||
@ -659,18 +621,8 @@ if(WITH_LIBCEPHFS)
|
||||
client/SyntheticClient.cc)
|
||||
add_executable(ceph-syn ${ceph_syn_srcs})
|
||||
target_link_libraries(ceph-syn client global-static ceph-common)
|
||||
|
||||
set(mount_ceph_srcs
|
||||
mount/mount.ceph.c)
|
||||
add_executable(mount.ceph ${mount_ceph_srcs}
|
||||
$<TARGET_OBJECTS:parse_secret_objs>
|
||||
$<TARGET_OBJECTS:common_mountcephfs_objs>)
|
||||
set_target_properties(mount.ceph PROPERTIES
|
||||
INSTALL_RPATH "")
|
||||
target_link_libraries(mount.ceph ${KEYUTILS_LIBRARIES})
|
||||
|
||||
install(TARGETS ceph-syn DESTINATION bin)
|
||||
install(TARGETS mount.ceph DESTINATION ${CMAKE_INSTALL_SBINDIR})
|
||||
add_subdirectory(mount)
|
||||
endif(WITH_LIBCEPHFS)
|
||||
|
||||
if(WITH_FUSE)
|
||||
@ -693,7 +645,7 @@ if(WITH_RBD)
|
||||
if(WITH_KRBD)
|
||||
add_library(krbd STATIC krbd.cc
|
||||
$<TARGET_OBJECTS:parse_secret_objs>)
|
||||
target_link_libraries(krbd ${KEYUTILS_LIBRARIES})
|
||||
target_link_libraries(krbd keyutils::keyutils)
|
||||
endif()
|
||||
add_subdirectory(librbd)
|
||||
if(WITH_FUSE)
|
||||
|
9
src/mount/CMakeLists.txt
Normal file
9
src/mount/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
set(mount_ceph_srcs
|
||||
mount.ceph.c)
|
||||
add_executable(mount.ceph ${mount_ceph_srcs}
|
||||
$<TARGET_OBJECTS:parse_secret_objs>
|
||||
$<TARGET_OBJECTS:common_mountcephfs_objs>)
|
||||
set_target_properties(mount.ceph PROPERTIES
|
||||
INSTALL_RPATH "")
|
||||
target_link_libraries(mount.ceph keyutils::keyutils)
|
||||
install(TARGETS mount.ceph DESTINATION ${CMAKE_INSTALL_SBINDIR})
|
@ -517,23 +517,18 @@ endif(HAVE_BLKID)
|
||||
|
||||
# ceph_test_admin_socket_output
|
||||
|
||||
add_executable(ceph_test_admin_socket_output
|
||||
test_admin_socket_output.cc
|
||||
admin_socket_output.cc
|
||||
admin_socket_output_tests.cc
|
||||
)
|
||||
target_link_libraries(ceph_test_admin_socket_output
|
||||
ceph-common)
|
||||
if(CXX_STDLIB STREQUAL "libstdc++")
|
||||
find_package(StdFilesystem)
|
||||
if(StdFilesystem_FOUND)
|
||||
add_executable(ceph_test_admin_socket_output
|
||||
test_admin_socket_output.cc
|
||||
admin_socket_output.cc
|
||||
admin_socket_output_tests.cc)
|
||||
target_link_libraries(ceph_test_admin_socket_output
|
||||
-lstdc++fs)
|
||||
elseif(CXX_STDLIB STREQUAL "libc++")
|
||||
target_link_libraries(ceph_test_admin_socket_output
|
||||
-lc++experimental)
|
||||
ceph-common StdFilesystem::filesystem)
|
||||
install(TARGETS
|
||||
ceph_test_admin_socket_output
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
endif()
|
||||
install(TARGETS
|
||||
ceph_test_admin_socket_output
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
#make check starts here
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user