From 98a3f7d6408f35641141ed445579d0a63e53bc61 Mon Sep 17 00:00:00 2001 From: Felix Nieuwenhuizen Date: Thu, 3 Dec 2020 20:45:46 +0100 Subject: [PATCH] allow override of CMAKE_CXX_STANDARD --- runtime/Cpp/CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/runtime/Cpp/CMakeLists.txt b/runtime/Cpp/CMakeLists.txt index 32b34bfee..e549f113f 100644 --- a/runtime/Cpp/CMakeLists.txt +++ b/runtime/Cpp/CMakeLists.txt @@ -76,8 +76,13 @@ endif() # Initialize CXXFLAGS. if("${CMAKE_VERSION}" VERSION_GREATER 3.1.0) - set(CMAKE_CXX_STANDARD 11) + if(NOT DEFINED CMAKE_CXX_STANDARD) + # only set CMAKE_CXX_STANDARD if not already set + # this allows the standard to be set by the caller, for example with -DCMAKE_CXX_STANDARD:STRING=17 + set(CMAKE_CXX_STANDARD 11) + endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11")