From b56df594ae2a38c3f00f770a88f9414c564f5a0a Mon Sep 17 00:00:00 2001 From: degaart Date: Wed, 23 Dec 2015 09:25:18 +0300 Subject: [PATCH] Use CMAKE_CXX_STANDARD Use CMAKE_CXX_STANDARD to activate C++14 support in compilers --- cmake/CMakeLists.txt | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 64ff5f35..370c5a68 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -29,15 +29,23 @@ if(APPLE) set(CMAKE_OSX_DEPLOYMENT_TARGET 10.10) endif(APPLE) -if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y") - else() + +if(CMAKE_VERSION VERSION_LESS 3.1) + if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") + endif() + elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") endif() -elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") -elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC") +else() + set(CMAKE_CXX_STANDARD 14) + set(CMAKE_CXX_STANDARD_REQUIRED ON) +endif() + +if(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC") add_definitions(-DUNICODE -D_UNICODE) endif()