[cmake] Use FindFilesystem instead of own code
parent
5f050040fe
commit
481f81c664
|
@ -343,36 +343,17 @@ include_directories("${CMAKE_SOURCE_DIR}/src" ${CMAKE_BINARY_DIR})
|
|||
include(CheckSymbolExists)
|
||||
check_symbol_exists(wordexp wordexp.h HAVE_WORDEXP)
|
||||
check_include_files(byteswap.h HAVE_BYTESWAP_H)
|
||||
try_compile(HAVE_FILESYSTEM ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/checks/cxxfs.cpp")
|
||||
check_include_file_cxx(experimental/filesystem HAVE_EXPERIMENTAL_FILESYSTEM)
|
||||
|
||||
if((NOT HAVE_FILESYSTEM) AND HAVE_EXPERIMENTAL_FILESYSTEM)
|
||||
# Try compile without linking against any library
|
||||
try_compile(CXXFSLIB ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/checks/cxxfsexp.cpp")
|
||||
|
||||
if(CXXFSLIB)
|
||||
# Nothing to do, linking is not explicitly required
|
||||
find_package(Filesystem)
|
||||
if(Filesystem_FOUND)
|
||||
if(CXX_FILESYSTEM_IS_EXPERIMENTAL)
|
||||
set(HAVE_EXPERIMENTAL_FILESYSTEM ON)
|
||||
else()
|
||||
# Find the filesystem lib we need to link against
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
find_library(CLANG_FS_LIBRARY "c++fs")
|
||||
if(CLANG_FS_LIBRARY)
|
||||
set(FS_LIBRARY c++fs)
|
||||
else()
|
||||
set(FS_LIBRARY stdc++fs)
|
||||
endif()
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(FS_LIBRARY stdc++fs)
|
||||
endif()
|
||||
|
||||
try_compile(CXXFSLIB ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/checks/cxxfs.cpp" LINK_LIBRARIES "${FS_LIBRARY}")
|
||||
if(CXXFSLIB)
|
||||
link_libraries("${FS_LIBRARY}")
|
||||
else()
|
||||
set(HAVE_EXPERIMENTAL_FILESYSTEM OFF)
|
||||
message(WARNING "C++ experimental filesystem library is unusable!\nWill use own implementation.")
|
||||
endif()
|
||||
set(HAVE_FILESYSTEM ON)
|
||||
endif()
|
||||
link_libraries(std::filesystem)
|
||||
else()
|
||||
message(WARNING "C++ experimental filesystem library is unusable!\nWill use own implementation.")
|
||||
endif()
|
||||
|
||||
try_compile(HAVE_STRING_VIEW ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/checks/cxxsv.cpp")
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
#include <filesystem>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::error_code ec;
|
||||
throw std::filesystem::filesystem_error("test", ec);
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
#include <experimental/filesystem>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::error_code ec;
|
||||
throw std::experimental::filesystem::filesystem_error("test", ec);
|
||||
}
|
Loading…
Reference in New Issue