From c036d66286d6048340ff82254570d3ab11bc16f8 Mon Sep 17 00:00:00 2001 From: Mark Jan van Kampen Date: Thu, 21 Oct 2021 12:24:12 +0200 Subject: [PATCH] Problem: newer cmake versions set CMAKE_C(XX)_FLAGS at a later stage not allowing a user to override the standard Solution: check for C(XX)_STANDARD/CMAKE_C(XX)_STANDARD as well Fixes #4284 --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 522fcb3c..2e3d601d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,14 +111,14 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin) endif() if (NOT MSVC) - if(NOT CMAKE_CXX_FLAGS MATCHES "-std=") + if(NOT CMAKE_CXX_FLAGS MATCHES "-std=" AND NOT CXX_STANDARD AND NOT CMAKE_CXX_STANDARD) # use C++11 by default if supported check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11) if(COMPILER_SUPPORTS_CXX11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") endif() endif() - if(NOT CMAKE_C_FLAGS MATCHES "-std=") + if(NOT CMAKE_C_FLAGS MATCHES "-std=" AND NOT C_STANDARD AND NOT CMAKE_C_STANDARD) check_c_compiler_flag("-std=c11" COMPILER_SUPPORTS_C11) if(COMPILER_SUPPORTS_C11) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")