Skip to content

Commit

Permalink
Merge pull request #350 from baconpaul/cmake-347
Browse files Browse the repository at this point in the history
Add a CMake option to select no std::filesystem
  • Loading branch information
ColinH authored Jul 7, 2023
2 parents b4f456a + 7dcbe66 commit 8933730
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ target_include_directories(pegtl INTERFACE
target_compile_features(pegtl INTERFACE cxx_std_17)

option(PEGTL_USE_BOOST_FILESYSTEM "Override the auto-detection of std::filesystem and use Boost.Filesystem" OFF)
option(PEGTL_USE_FILESYSTEM "Use available implementation of std::filesystem (std::, std::experiemntal, or Boost)" ON)

# Try compiling a test program with std::filesystem or one of its alternatives
function(check_filesystem_impl FILESYSTEM_HEADER FILESYSTEM_NAMESPACE OPTIONAL_LIBS OUT_RESULT)
Expand Down Expand Up @@ -82,7 +83,10 @@ function(check_filesystem_impl FILESYSTEM_HEADER FILESYSTEM_NAMESPACE OPTIONAL_L
set(${OUT_RESULT} ${TEST_RESULT} PARENT_SCOPE)
endfunction()

if(PEGTL_USE_BOOST_FILESYSTEM)
if (NOT PEGTL_USE_FILESYSTEM)
target_compile_definitions(${PROJECT_NAME} INTERFACE TAO_PEGTL_NO_FILESYSTEM)
message(STATUS "Skipping std::filesystem (or variant) in PEGTL; File operations will not work or compile.")
elseif (PEGTL_USE_BOOST_FILESYSTEM)
# Force the use of Boost.Filesystem: #include <boost/filesystem.hpp> // boost::filesystem
find_package(Boost REQUIRED COMPONENTS filesystem)
target_link_libraries(${PROJECT_NAME} INTERFACE Boost::filesystem)
Expand Down

0 comments on commit 8933730

Please sign in to comment.