Disable --std=c++11 for ancient GCC versions

fixes #10744
This commit is contained in:
Gunnar Beutner 2015-11-30 08:16:39 +01:00
parent 6a83703549
commit 8269556f02
1 changed files with 22 additions and 5 deletions

View File

@ -200,14 +200,27 @@ if(HAVE_LIBEXECINFO)
set(HAVE_BACKTRACE_SYMBOLS TRUE)
endif()
set(_ICINGA2_CXX11 OFF)
if(UNIX)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++11" CXX_FLAG_CXX11)
check_cxx_compiler_flag("-std=c++0x" CXX_FLAG_CXX0X)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
exec_program(${CMAKE_CXX_COMPILER}
ARGS -dumpversion
OUTPUT_VARIABLE _ICINGA2_COMPILER_VERSION
)
if (${_ICINGA2_COMPILER_VERSION} VERSION_LESS "4.7.0")
message(STATUS "Your version of GCC is too old for building Icinga 2 in C++11 mode.")
set(CXX_FLAG_CXX11 OFF)
endif()
endif()
if(CXX_FLAG_CXX11)
set(_ICINGA2_CXX11 ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(CXX_FLAG_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
endif()
check_cxx_compiler_flag("-Wno-inconsistent-missing-override" CXX_FLAG_NO_OVERRIDE_WARNING)
@ -216,8 +229,12 @@ if(UNIX)
endif()
endif()
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("class Base { public: virtual void test(void) { } }; class Derived : public Base { virtual void test(void) override { } }; int main(){}" CXX_FEATURE_OVERRIDE)
set(CXX_FEATURE_OVERRIDE OFF)
if(_ICINGA2_CXX11)
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("class Base { public: virtual void test(void) { } }; class Derived : public Base { virtual void test(void) override { } }; int main(){}" CXX_FEATURE_OVERRIDE)
endif()
if(NOT CXX_FEATURE_OVERRIDE)
add_definitions("-Doverride=")