Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Update FindFilesystem.cmake #3905

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
paulgessinger marked this conversation as resolved.
Show resolved Hide resolved

# 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()
Loading