diff options
author | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2021-04-15 13:45:51 +0300 |
---|---|---|
committer | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2021-04-15 13:45:51 +0300 |
commit | 6735fabda8723111d687cc6bab54e73fad666131 (patch) | |
tree | 5439a37f52239a529c503b0d30e083ca3c24f572 | |
parent | db383d69b71ae5dab99e8e90699629c1a684f4ee (diff) |
Maybe partially fix issue #76 where CMAKE_CXX_STANDARD wasn't affecting probes for <filesystem>.
-rw-r--r-- | CMakeLists.txt | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index aa6e8d20..4293966f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,15 +156,18 @@ if(NOT MSVC OR CMAKE_VERSION VERSION_GREATER 3.59) cxx_variable_templates ) endif() +set(check_cxx_source_linkage_flags) # If on VS2019 16.3 or later, or on Apple, we require C++ 17 if((MSVC AND MSVC_VERSION VERSION_GREATER_EQUAL 1923) OR APPLE) all_compile_features(PUBLIC cxx_std_17 ) - if(MSVC) - set(check_cxx_source_linkage_flags /std:c++17) - else() - set(check_cxx_source_linkage_flags -std=c++17) + if(NOT CMAKE_CXX_STANDARD) + if(MSVC) + set(check_cxx_source_linkage_flags /std:c++17) + else() + set(check_cxx_source_linkage_flags -std=c++17) + endif() endif() endif() # Set the library dependencies this library has @@ -184,6 +187,13 @@ function(check_cxx_source_linkage prog var) if(MSVC AND CMAKE_GENERATOR MATCHES "Ninja") set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} /EHsc") endif() + if(CMAKE_CXX_STANDARD) + if(MSVC) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} /std:c++${CMAKE_CXX_STANDARD}") + else() + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++${CMAKE_CXX_STANDARD}") + endif() + endif() if(CMAKE_SYSTEM_PROCESSOR STREQUAL ${CMAKE_HOST_SYSTEM_PROCESSOR} AND NOT LLFIO_ASSUME_CROSS_COMPILING) check_cxx_source_runs("${prog}" ${var}) else() |