diff --git a/cmake/SetupStdFilesystem.cmake b/cmake/SetupStdFilesystem.cmake new file mode 100644 index 00000000..0ccbe950 --- /dev/null +++ b/cmake/SetupStdFilesystem.cmake @@ -0,0 +1,22 @@ + +# h5pp requires the filesystem header (and possibly stdc++fs library) +find_package(Filesystem COMPONENTS Final Experimental) +if (TARGET std::filesystem) + target_link_libraries(deps INTERFACE std::filesystem) + list(APPEND H5PP_TARGETS std::filesystem) +elseif(H5PP_PACKAGE_MANAGER MATCHES "cmake|fetch|conan") + message(STATUS "Your compiler lacks std::filesystem. A drop-in replacement 'ghc::filesystem' will be downloaded") + message(STATUS "Read more about ghc::filesystem here: /~https://github.com/gulrak/filesystem") + include(cmake/Get_ghcFilesystem.cmake) + if(TARGET ghcFilesystem::ghc_filesystem) + target_link_libraries(deps INTERFACE ghcFilesystem::ghc_filesystem) + list(APPEND H5PP_TARGETS ghcFilesystem::ghc_filesystem) + else() + message(WARNING "Your compiler lacks std::filesystem and installing the drop-in replacement 'ghc::filesystem' failed.") + message(FATAL_ERROR " header and/or library not found") + endif() +else() + message(STATUS "Your compiler lacks std::filesystem. Set H5PP_PACKAGE_MANAGER to 'cmake', 'fetch' or 'conan' to get the ghc::filesystem replacement") + message(STATUS "Read more about ghc::filesystem here: /~https://github.com/gulrak/filesystem") + message(FATAL_ERROR " header and/or library not found") +endif() \ No newline at end of file