From 1661ebb537bd6b1dc6664dd078df6fbe84fc6c6a Mon Sep 17 00:00:00 2001 From: hagen Date: Mon, 22 Sep 2014 22:36:06 +0000 Subject: [PATCH 1/4] * cmake : detect support of c++11 via compiler flags --- build/CMakeLists.txt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index f41e5d5c..1073a6dd 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -58,8 +58,20 @@ endif () # compiler flags customization (by vendor) add_definitions ( "-Wall -Wextra" ) -if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + +# check for c++11 support +include(CheckCXXCompilerFlag) +CHECK_CXX_COMPILER_FLAG("-std=c++11" CXX11_SUPPORTED) +CHECK_CXX_COMPILER_FLAG("-std=c++0x" CXX0X_SUPPORTED) +if (CXX11_SUPPORTED) add_definitions( "-std=c++11" ) +elseif (CXX0X_SUPPORTED) # gcc 4.6 + add_definitions( "-std=c++0x" ) +else () + message(SEND_ERROR "C++11 standart not seems to be supported by compiler. Too old version?") +endif () + +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if (WITH_HARDENING) add_definitions( "-D_FORTIFY_SOURCE=2" ) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat -Wformat-security -Werror=format-security" ) @@ -67,7 +79,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -pie" ) endif () elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - add_definitions( "-std=c++11" ) + # more tweaks endif () # compiler flags customization (by system) From 352667742149e6b62889561fb16131d2a2fd81fd Mon Sep 17 00:00:00 2001 From: hagen Date: Mon, 22 Sep 2014 22:36:29 +0000 Subject: [PATCH 2/4] * cmake : show compiler version in summary --- build/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index 1073a6dd..0b959b59 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -117,6 +117,7 @@ include_directories( ${Boost_INCLUDE_DIRS} ${CRYPTO++_INCLUDE_DIR}) message(STATUS "---------------------------------------") message(STATUS "Build type : ${CMAKE_BUILD_TYPE}") message(STATUS "Compiler vendor : ${CMAKE_CXX_COMPILER_ID}") +message(STATUS "Compiler version : ${CMAKE_CXX_COMPILER_VERSION}") message(STATUS "Compiler path : ${CMAKE_CXX_COMPILER}") message(STATUS "Install prefix: : ${CMAKE_INSTALL_PREFIX}") message(STATUS "Options:") From bbe146e8d454a6d5b9fc29a8f7c5f48b5d0d8d49 Mon Sep 17 00:00:00 2001 From: hagen Date: Mon, 22 Sep 2014 22:40:11 +0000 Subject: [PATCH 3/4] * debian/control : enforce minimal version of compiler and cmake --- debian/control | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 0808cb74..98312c87 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,8 @@ Source: i2pd Section: net Priority: extra Maintainer: hagen -Build-Depends: debhelper (>= 8.0.0), cmake, dpkg-dev (>= 1.16.1~), +Build-Depends: debhelper (>= 8.0.0), dpkg-dev (>= 1.16.1~), + cmake (>= 2.8), gcc (>= 4.6) | clang (>= 3.3), libboost-regex-dev, libboost-system-dev (>= 1.46), libboost-date-time-dev, From 5a55e14f982fcc842ad562c3eacff5e1bb5adcd5 Mon Sep 17 00:00:00 2001 From: hagen Date: Tue, 23 Sep 2014 01:44:09 +0000 Subject: [PATCH 4/4] * Makefile.linux : detect gcc version --- Makefile.linux | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile.linux b/Makefile.linux index d6149a54..a4b63847 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -1,5 +1,16 @@ CC = g++ -CFLAGS = -g -Wall -std=c++0x +CFLAGS = -g -Wall +CXXVER := $(shell ${CC} -dumpversion) +ifeq ($(shell expr match ${CXXVER} "4\.[0-5]"),3) + $(error Compiler too old) +endif + +ifeq (${CXXVER},"4.6") + CFLAGS += -std=c++0x +else + CFLAGS += -std=c++11 +endif + include filelist.mk INCFLAGS = LDFLAGS = -lcryptopp -lboost_system -lboost_date_time -lboost_filesystem -lboost_regex -lboost_program_options -lpthread