mirror of
https://github.com/ceph/ceph
synced 2024-12-29 15:03:33 +00:00
bbb69fe793
since we dropped the support of xenial, we now have the luxury of using newer CMake! and by using CMake 3.10.2, we can prevent libfmt from assuming that we are using C++11, and hence set `CMAKE_CXX_STANDARD` to 11, which will literally append `-std=gnu++11` to `CMAKE_CXX_FLAGS`. the last `-std` option passed to `g++` takes precendence. since we've switched over to C++17, and we are using C++17 features. so, using cmake older than 3.8 breaks the build. because it is CMake 3.8 which stared support `CMAKE_CXX_STANDARD` 17. - for bionic: https://packages.ubuntu.com/bionic/cmake : 3.10.2 - for CentOS7: https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/c/ : 3.13.5 so in this change, * bump up the required version to v3.10.2 * cleanups to wipe out the workaround for lower CMake versions * use `PROJECT_VERSION` defined by `project()` command instead of `VERSION` explicitly defined. Signed-off-by: Kefu Chai <kchai@redhat.com>
44 lines
1.3 KiB
CMake
44 lines
1.3 KiB
CMake
set(_std_filesystem_test_src
|
|
${CMAKE_CURRENT_LIST_DIR}/FindStdFilesystem_test.cc)
|
|
|
|
macro(try_std_filesystem_library _library _result)
|
|
set(_std_filesystem_try_compile_arg
|
|
CXX_STANDARD 17)
|
|
try_compile(_std_filesystem_compiles
|
|
${CMAKE_CURRENT_BINARY_DIR}
|
|
SOURCES ${_std_filesystem_test_src}
|
|
LINK_LIBRARIES ${_library}
|
|
${_std_filesystem_try_compile_arg})
|
|
unset(_std_filesystem_try_compile_arg)
|
|
if(_std_filesystem_compiles)
|
|
set(${_result} ${_library})
|
|
endif()
|
|
unset(_std_filesystem_compiles)
|
|
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()
|
|
|
|
unset(_std_filesystem_test_src)
|
|
|
|
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()
|