From 8238a6cd5d2867e709e87a752e0a24c7c2bf28f0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 13 Oct 2013 01:26:16 +0200 Subject: Add some COMPILE_OPTIONS for specifying C++ dialect. These are compiler-specific, compiler version specific, extension specific and standard version specific. --- Modules/Compiler/Clang-CXX.cmake | 13 +++++++++++++ Modules/Compiler/GNU-CXX.cmake | 13 +++++++++++++ Tests/SystemInformation/SystemInformation.in | 4 ++++ 3 files changed, 30 insertions(+) diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index ab1b766..a1b3a10 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -9,3 +9,16 @@ cmake_policy(GET CMP0025 appleClangPolicy) if(NOT appleClangPolicy STREQUAL NEW) return() endif() + +if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1) + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") +endif() + +if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") +elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x") +endif() diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake index 33d6093..3ee8639 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -10,3 +10,16 @@ else() set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") endif() endif() + +if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.3) + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") +endif() + +if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") +elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.3) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x") +endif() diff --git a/Tests/SystemInformation/SystemInformation.in b/Tests/SystemInformation/SystemInformation.in index df3bf49..92b24e2 100644 --- a/Tests/SystemInformation/SystemInformation.in +++ b/Tests/SystemInformation/SystemInformation.in @@ -21,6 +21,10 @@ CMAKE_C_COMPILER_ID == "${CMAKE_C_COMPILER_ID}" CMAKE_C_COMPILER_VERSION == "${CMAKE_C_COMPILER_VERSION}" CMAKE_CXX_COMPILER_ID == "${CMAKE_CXX_COMPILER_ID}" CMAKE_CXX_COMPILER_VERSION == "${CMAKE_CXX_COMPILER_VERSION}" +CMAKE_CXX98_STANDARD_COMPILE_OPTION == "${CMAKE_CXX98_STANDARD_COMPILE_OPTION}" +CMAKE_CXX11_STANDARD_COMPILE_OPTION == "${CMAKE_CXX11_STANDARD_COMPILE_OPTION}" +CMAKE_CXX98_EXTENSION_COMPILE_OPTION == "${CMAKE_CXX98_EXTENSION_COMPILE_OPTION}" +CMAKE_CXX11_EXTENSION_COMPILE_OPTION == "${CMAKE_CXX11_EXTENSION_COMPILE_OPTION}" // C shared library flag CMAKE_SHARED_LIBRARY_C_FLAGS == "${CMAKE_SHARED_LIBRARY_C_FLAGS}" -- cgit v0.12