diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -291,6 +291,40 @@ endif() endif() +check_cxx_source_compiles(" + #include + namespace fs = std::filesystem; + int main() { + (void)fs::current_path().root_name(); + return 0; + } +" HAVE_STD_FILESYSTEM) + +if(!HAVE_STD_FILESYSTEM) + link_libraries(stdc++fs) + check_cxx_source_compiles(" + #include + namespace fs = std::filesystem; + int main() { + (void)fs::current_path().root_name(); + return 0; + } + " REQUIRES_STDCXXFS) + if(!REQUIRES_STDCXXFS) + link_libraries(c++fs) + check_cxx_source_compiles(" + #include + namespace fs = std::filesystem; + int main() { + (void)fs::current_path().root_name(); + return 0; + } + " REQUIRES_CXXFS) + if(!REQUIRES_CXXFS) + message(FATAL_ERROR "cannot figure out how to use std::filesystem" ) + endif() + endif() +endif() # Make sure that all the global compiler and linker flags are set BEFORE # including the libraries so they apply as needed.