|
Rex Dieter |
8acc3d6 |
From e1c69c277ea6005cc358434679b83fa1cb752756 Mon Sep 17 00:00:00 2001
|
|
Rex Dieter |
8acc3d6 |
From: =?UTF-8?q?Dan=20Vr=C3=A1til?= <dvratil@redhat.com>
|
|
Rex Dieter |
8acc3d6 |
Date: Tue, 23 Sep 2014 18:00:34 +0200
|
|
Rex Dieter |
adf30af |
Subject: [PATCH 09/30] Test whether compiler supports all required C++11
|
|
Rex Dieter |
8acc3d6 |
features at configure time
|
|
Rex Dieter |
8acc3d6 |
|
|
Rex Dieter |
8acc3d6 |
To prevent ugly compilation errors when someone tries to compile Akonadi
|
|
Rex Dieter |
8acc3d6 |
with a compiler that does not support all C++11 features we use, we run
|
|
Rex Dieter |
8acc3d6 |
a try_compile check in CMakeLists.txt.
|
|
Rex Dieter |
8acc3d6 |
---
|
|
Rex Dieter |
8acc3d6 |
CMakeLists.txt | 18 ++++++++++++++++++
|
|
Rex Dieter |
8acc3d6 |
1 file changed, 18 insertions(+)
|
|
Rex Dieter |
8acc3d6 |
|
|
Rex Dieter |
8acc3d6 |
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
Rex Dieter |
8acc3d6 |
index e081d23..2d790c9 100644
|
|
Rex Dieter |
8acc3d6 |
--- a/CMakeLists.txt
|
|
Rex Dieter |
8acc3d6 |
+++ b/CMakeLists.txt
|
|
Rex Dieter |
8acc3d6 |
@@ -216,6 +216,24 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER MATCHES "icc" OR (CMAKE_CXX_COMP
|
|
Rex Dieter |
8acc3d6 |
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")
|
|
Rex Dieter |
8acc3d6 |
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")
|
|
Rex Dieter |
8acc3d6 |
|
|
Rex Dieter |
8acc3d6 |
+ file(WRITE ${CMAKE_BINARY_DIR}/cxx11_check.cpp
|
|
Rex Dieter |
8acc3d6 |
+ "enum Enum { Value = 1 };
|
|
Rex Dieter |
8acc3d6 |
+ struct Class {
|
|
Rex Dieter |
8acc3d6 |
+ Class(int val) { (void)val; };
|
|
Rex Dieter |
8acc3d6 |
+ // Delegating constructor
|
|
Rex Dieter |
8acc3d6 |
+ Class(): Class(42) {};
|
|
Rex Dieter |
8acc3d6 |
+ // New-style enumerator
|
|
Rex Dieter |
8acc3d6 |
+ Class(Enum e = Enum::Value) { (void)e; };
|
|
Rex Dieter |
8acc3d6 |
+ };
|
|
Rex Dieter |
8acc3d6 |
+ int main() {}
|
|
Rex Dieter |
8acc3d6 |
+ ")
|
|
Rex Dieter |
8acc3d6 |
+ try_compile(CXX11_SUPPORTED
|
|
Rex Dieter |
8acc3d6 |
+ ${CMAKE_BINARY_DIR}/cxx11_check
|
|
Rex Dieter |
8acc3d6 |
+ ${CMAKE_BINARY_DIR}/cxx11_check.cpp)
|
|
Rex Dieter |
8acc3d6 |
+ if (NOT CXX11_SUPPORTED)
|
|
Rex Dieter |
8acc3d6 |
+ message(FATAL_ERROR "Compiler does not support all required C++11 features")
|
|
Rex Dieter |
8acc3d6 |
+ endif()
|
|
Rex Dieter |
8acc3d6 |
+
|
|
Rex Dieter |
8acc3d6 |
# debugfull target
|
|
Rex Dieter |
8acc3d6 |
set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3 -fno-inline" CACHE STRING "Flags used by the C++ compiler during debugfull builds." FORCE)
|
|
Rex Dieter |
8acc3d6 |
set(CMAKE_C_FLAGS_DEBUGFULL "-g3 -fno-inline" CACHE STRING "Flags used by the C compiler during debugfull builds." FORCE)
|
|
Rex Dieter |
8acc3d6 |
--
|
|
Rex Dieter |
adf30af |
2.1.0
|
|
Rex Dieter |
8acc3d6 |
|