Skip to content

Commit

Permalink
Refactor the setup of std::filesystem to avoid code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidAce committed Jun 1, 2021
1 parent 3ecc4c7 commit 5b1783d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cmake/SetupStdFilesystem.cmake
Original file line number Diff line number Diff line change
@@ -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 "<filesystem> 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 "<filesystem> header and/or library not found")
endif()

0 comments on commit 5b1783d

Please sign in to comment.