mirror of
https://github.com/ceph/ceph
synced 2024-12-13 06:57:21 +00:00
e6c7e0f521
see https://libcxx.llvm.org/docs/UsingLibcxx.html#using-libc-experimental-and-experimental, > Note that as of libc++ 7.0 using the <experimental/filesystem> > requires linking libc++fs instead of libc++experimental. do not build ceph_test_admin_socket_output if we are not able to find the library for std::experimental::filesystem . it is a workaround of https://reviews.freebsd.org/D10840 where FreeBSD 11.2 does not ship libc++experimental.a . Signed-off-by: Kefu Chai <kchai@redhat.com>
38 lines
1.1 KiB
CMake
38 lines
1.1 KiB
CMake
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()
|