From a0ac01c0095441124978ad1fa01a533911c30e79 Mon Sep 17 00:00:00 2001 From: khizmax Date: Tue, 7 Mar 2017 23:07:51 +0300 Subject: [PATCH] [cmake] Added ability to specify C++ std explicitly in -DCMAKE_CXX_FLAGS cmdline option --- CMakeLists.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e1f1f47a..e6bdf69b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,7 +98,16 @@ if(NOT CMAKE_BUILD_TYPE) endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -pedantic -fno-strict-aliasing") + string(REGEX MATCHALL "-std=[^ ]+" cxx_std_found ${CMAKE_CXX_FLAGS}) + if(cxx_std_found) + message("C++ std: ${cxx_std_found}") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + message("C++ std: -std=c++11 (default)") + endif() + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -fno-strict-aliasing") + if(CMAKE_TARGET_ARCHITECTURE STREQUAL "x86_64") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcx16") set(LIB_SUFFIX "64") -- 2.34.1