From: khizmax Date: Tue, 7 Mar 2017 20:07:51 +0000 (+0300) Subject: [cmake] Added ability to specify C++ std explicitly in -DCMAKE_CXX_FLAGS cmdline... X-Git-Tag: v2.3.0~130 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a0ac01c0095441124978ad1fa01a533911c30e79;p=libcds.git [cmake] Added ability to specify C++ std explicitly in -DCMAKE_CXX_FLAGS cmdline option --- 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")