Fix build when not file system library required

This commit is contained in:
Martchus 2019-06-06 15:20:42 +02:00
parent c701fc25ee
commit d9b4ca5381
2 changed files with 5 additions and 4 deletions

View File

@ -157,7 +157,6 @@ else ()
endif ()
# configure required libraries for std::filestream
message(STATUS "calling use_filesystem()")
use_standard_filesystem()
# configure forcing UTF-8 code page under Windows

View File

@ -285,9 +285,11 @@ function (use_standard_filesystem)
set(REQUIRED_LIBRARY FAILED)
set(INDEX 0)
foreach (LIBRARY "" "stdc++fs" "c++fs")
set(CMAKE_REQUIRED_LIBRARIES ${DEFAULT_REQUIRED_LIBRARIES} -l${LIBRARY})
check_cxx_source_compiles("${TEST_PROGRAM}" COULD_COMPILE_${INDEX})
if (COULD_COMPILE_${INDEX})
if (NOT LIBRARY STREQUAL "")
set(CMAKE_REQUIRED_LIBRARIES ${DEFAULT_REQUIRED_LIBRARIES} -l${LIBRARY})
endif ()
check_cxx_source_compiles("${TEST_PROGRAM}" COULD_COMPILE_TEST_PROGRAM_${INDEX})
if (COULD_COMPILE_TEST_PROGRAM_${INDEX})
set(REQUIRED_LIBRARY "${LIBRARY}")
break()
endif ()