[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)
|
include(CheckSymbolExists)
|
||||||
check_symbol_exists(wordexp wordexp.h HAVE_WORDEXP)
|
check_symbol_exists(wordexp wordexp.h HAVE_WORDEXP)
|
||||||
check_include_files(byteswap.h HAVE_BYTESWAP_H)
|
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)
|
find_package(Filesystem)
|
||||||
# Try compile without linking against any library
|
if(Filesystem_FOUND)
|
||||||
try_compile(CXXFSLIB ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/checks/cxxfsexp.cpp")
|
if(CXX_FILESYSTEM_IS_EXPERIMENTAL)
|
||||||
|
set(HAVE_EXPERIMENTAL_FILESYSTEM ON)
|
||||||
if(CXXFSLIB)
|
|
||||||
# Nothing to do, linking is not explicitly required
|
|
||||||
else()
|
else()
|
||||||
# Find the filesystem lib we need to link against
|
set(HAVE_FILESYSTEM ON)
|
||||||
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()
|
|
||||||
endif()
|
endif()
|
||||||
|
link_libraries(std::filesystem)
|
||||||
|
else()
|
||||||
|
message(WARNING "C++ experimental filesystem library is unusable!\nWill use own implementation.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
try_compile(HAVE_STRING_VIEW ${CMAKE_BINARY_DIR} "${CMAKE_SOURCE_DIR}/checks/cxxsv.cpp")
|
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