diff options
author | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2020-03-24 19:22:16 +0300 |
---|---|---|
committer | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2020-03-24 19:22:16 +0300 |
commit | cf024bed02d9455292eb771bd7e7240e05ff48b0 (patch) | |
tree | 05b0be9110c5a42a46824eb1bbdb1b23bdd9d4f8 /CMakeLists.txt | |
parent | d1961d3029b65ff9d7abfeb01fe288c23ca92470 (diff) |
Fix compiler probes not forcing on C++ 17.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 73de0cdc..c3010e7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,9 +164,10 @@ if((MSVC AND MSVC_VERSION VERSION_GREATER_EQUAL 1923) OR APPLE) all_compile_features(PUBLIC cxx_std_17 ) - if(NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED) - # Also set globally so compiler probes work - set(CMAKE_CXX_STANDARD_REQUIRED 17) + if(MSVC) + set(check_cxx_source_linkage_flags /std:c++17) + else() + set(check_cxx_source_linkage_flags -std=c++17) endif() endif() # Set the library dependencies this library has @@ -175,13 +176,15 @@ all_link_libraries(PUBLIC quickcpplib::hl outcome::hl Threads::Threads $<$<PLATF # Set the system dependencies this library has include(CheckCXXSourceCompiles) include(CheckCXXSourceRuns) -macro(check_cxx_source_linkage prog var) +function(check_cxx_source_linkage prog var) + set(CMAKE_REQUIRED_FLAGS ${check_cxx_source_linkage_flags}) if(CMAKE_SYSTEM_PROCESSOR STREQUAL ${CMAKE_HOST_SYSTEM_PROCESSOR}) check_cxx_source_runs("${prog}" ${var}) else() check_cxx_source_compiles("${prog}" ${var}) endif() -endmacro() + set(${var} "${${var}}" PARENT_SCOPE) +endfunction() # Do we have native <filesystem> that just works without any extra effort? # We have to check if it runs, as binaries may link, but fail to run due to missing symbols check_cxx_source_linkage(" |