From 6735fabda8723111d687cc6bab54e73fad666131 Mon Sep 17 00:00:00 2001 From: "Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)" Date: Thu, 15 Apr 2021 11:45:51 +0100 Subject: Maybe partially fix issue #76 where CMAKE_CXX_STANDARD wasn't affecting probes for . --- CMakeLists.txt | 18 ++++++++++++++---- 1 file 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() -- cgit v1.2.3