1 From e1c69c277ea6005cc358434679b83fa1cb752756 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Dan=20Vr=C3=A1til?= <dvratil@redhat.com>
3 Date: Tue, 23 Sep 2014 18:00:34 +0200
4 Subject: [PATCH 09/30] Test whether compiler supports all required C++11
5 features at configure time
7 To prevent ugly compilation errors when someone tries to compile Akonadi
8 with a compiler that does not support all C++11 features we use, we run
9 a try_compile check in CMakeLists.txt.
11 CMakeLists.txt | 18 ++++++++++++++++++
12 1 file changed, 18 insertions(+)
14 diff --git a/CMakeLists.txt b/CMakeLists.txt
15 index e081d23..2d790c9 100644
18 @@ -216,6 +216,24 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER MATCHES "icc" OR (CMAKE_CXX_COMP
19 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -std=iso9899:1990 -Wundef -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts -Wall -Wextra -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common")
20 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wnon-virtual-dtor -Wundef -Wcast-align -Wchar-subscripts -Wall -Wextra -Wpointer-arith -Wformat-security -fno-common")
22 + file(WRITE ${CMAKE_BINARY_DIR}/cxx11_check.cpp
23 + "enum Enum { Value = 1 };
25 + Class(int val) { (void)val; };
26 + // Delegating constructor
27 + Class(): Class(42) {};
28 + // New-style enumerator
29 + Class(Enum e = Enum::Value) { (void)e; };
33 + try_compile(CXX11_SUPPORTED
34 + ${CMAKE_BINARY_DIR}/cxx11_check
35 + ${CMAKE_BINARY_DIR}/cxx11_check.cpp)
36 + if (NOT CXX11_SUPPORTED)
37 + message(FATAL_ERROR "Compiler does not support all required C++11 features")
41 set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3 -fno-inline" CACHE STRING "Flags used by the C++ compiler during debugfull builds." FORCE)
42 set(CMAKE_C_FLAGS_DEBUGFULL "-g3 -fno-inline" CACHE STRING "Flags used by the C compiler during debugfull builds." FORCE)