1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
# Check if std::filesystem needs -lstdc++fs
include(CheckCXXSourceCompiles)
set(
check_std_filesystem_source_code
[=[
#include <filesystem>
int main(void)
{
return std::filesystem::is_regular_file(\"/\") ? 0 : 1;
}
]=])
check_cxx_source_compiles("${check_std_filesystem_source_code}" std_filesystem_without_libfs)
if(NOT std_filesystem_without_libfs)
set(CMAKE_REQUIRED_LIBRARIES stdc++fs)
check_cxx_source_compiles("${check_std_filesystem_source_code}" std_filesystem_with_libfs)
set(CMAKE_REQUIRED_LIBRARIES)
if(NOT std_filesystem_with_libfs)
message(FATAL_ERROR "Toolchain doesn't support std::filesystem with nor without -lstdc++fs")
else()
target_link_libraries(standard_settings INTERFACE stdc++fs)
endif()
endif()
|