Skip to content

Commit

Permalink
build: Update FindFilesystem.cmake (#3905)
Browse files Browse the repository at this point in the history
Vector-of-bool's `FindFilesystem.cmake` was updated at some point to include and explicit `CMAKE_CXX_STANDARD=17`. We've observed occasionally that on macOS, the find module would fail because it would default to C++14, where `std::filesystem` is not available (and I guess the experimental implementation has since been removed).

This PR updates the `FindFilesystem.cmake` to include this.

Fixes #3900
  • Loading branch information
paulgessinger authored Nov 25, 2024
1 parent b0f6bde commit 4656a8d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmake/FindFilesystem.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ if(TARGET std::filesystem)
return()
endif()

cmake_minimum_required(VERSION 3.10)

include(CMakePushCheckState)
include(CheckIncludeFileCXX)

Expand All @@ -124,6 +126,13 @@ cmake_push_check_state()

set(CMAKE_REQUIRED_QUIET ${Filesystem_FIND_QUIETLY})

# All of our tests required C++17 or later
if(DEFINED CMAKE_CXX_STANDARD)
set(_prior_cmake_cxx_standard ${CMAKE_CXX_STANDARD})
endif()

set(CMAKE_CXX_STANDARD 17)

# Normalize and check the component list we were given
set(want_components ${Filesystem_FIND_COMPONENTS})
if(Filesystem_FIND_COMPONENTS STREQUAL "")
Expand Down Expand Up @@ -282,6 +291,12 @@ set(Filesystem_FOUND
FORCE
)

if(DEFINED _prior_cmake_cxx_standard)
set(CMAKE_CXX_STANDARD ${_prior_cmake_cxx_standard})
else()
unset(CMAKE_CXX_STANDARD)
endif()

if(Filesystem_FIND_REQUIRED AND NOT Filesystem_FOUND)
message(FATAL_ERROR "Cannot run simple program using std::filesystem")
endif()

0 comments on commit 4656a8d

Please sign in to comment.