From 2a8f251f7bbdf7eb03779b25fbc0077bfeb134a6 Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Mon, 25 Nov 2024 09:24:03 +0100 Subject: [PATCH 1/2] build: Update `FindFilesystem.cmake` --- cmake/FindFilesystem.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmake/FindFilesystem.cmake b/cmake/FindFilesystem.cmake index 93cc9b9c8a3..d9ac79d13a9 100644 --- a/cmake/FindFilesystem.cmake +++ b/cmake/FindFilesystem.cmake @@ -103,6 +103,8 @@ if(TARGET std::filesystem) return() endif() +cmake_minimum_required(VERSION 3.10) + include(CMakePushCheckState) include(CheckIncludeFileCXX) @@ -124,6 +126,9 @@ cmake_push_check_state() set(CMAKE_REQUIRED_QUIET ${Filesystem_FIND_QUIETLY}) +# All of our tests required C++17 or later +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 "") From 4359637a29ba97f51002b10ad615c04dff19f3e3 Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Mon, 25 Nov 2024 09:39:05 +0100 Subject: [PATCH 2/2] restore original variable value --- cmake/FindFilesystem.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmake/FindFilesystem.cmake b/cmake/FindFilesystem.cmake index d9ac79d13a9..1d0eb52641a 100644 --- a/cmake/FindFilesystem.cmake +++ b/cmake/FindFilesystem.cmake @@ -127,6 +127,10 @@ 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 @@ -287,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()