From ee62d39e6f4621c0f137bed91d77318cb3b38bfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 5 Jul 2012 21:02:50 +0200 Subject: [PATCH] Initial work for GCC 4.5 compatibility. GCC 4.5 doesn't know constexpr keyword and nullptr. As all constexpr functions are here inline, it can be done with a simple macro. --- CMakeLists.txt | 1 + src/CMakeLists.txt | 4 ++++ src/Math/Math.h | 1 + src/Math/MathTypeTraits.h | 2 ++ src/magnumCompatibility.h | 25 +++++++++++++++++++++++++ src/magnumConfigure.h.cmake | 1 + 6 files changed, 34 insertions(+) create mode 100644 src/magnumCompatibility.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 014b64876..83e06fefc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 2.8.8) project(Magnum) option(TARGET_GLES "Build for OpenGL ES 2 instead of desktop OpenGL" OFF) +option(GCC45_COMPATIBILITY "Enable compatibility mode for GCC 4.5 (might disable some features)" OFF) option(BUILD_TESTS "Build unit tests (requires Qt4)." OFF) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c88df8331..287697878 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,6 +4,10 @@ if(TARGET_GLES) set(MAGNUM_TARGET_GLES 1) endif() +if(GCC45_COMPATIBILITY) + set(MAGNUM_GCC45_COMPATIBILITY 1) +endif() + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/magnumConfigure.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/magnumConfigure.h) diff --git a/src/Math/Math.h b/src/Math/Math.h index e6e7e24b5..3a2ebf049 100644 --- a/src/Math/Math.h +++ b/src/Math/Math.h @@ -17,6 +17,7 @@ #include +#include "magnumCompatibility.h" #include "magnumVisibility.h" /** @file diff --git a/src/Math/MathTypeTraits.h b/src/Math/MathTypeTraits.h index c1a989f8a..c41634ce5 100644 --- a/src/Math/MathTypeTraits.h +++ b/src/Math/MathTypeTraits.h @@ -21,6 +21,8 @@ #include +#include "magnumCompatibility.h" + /** @brief Precision when testing floats for equality */ #ifndef FLOAT_EQUALITY_PRECISION #define FLOAT_EQUALITY_PRECISION 1.0e-6 diff --git a/src/magnumCompatibility.h b/src/magnumCompatibility.h new file mode 100644 index 000000000..311430e9e --- /dev/null +++ b/src/magnumCompatibility.h @@ -0,0 +1,25 @@ +#ifndef magnumCompatibility_h +#define magnumCompatibility_h +/* + Copyright © 2010, 2011, 2012 Vladimír Vondruš + + This file is part of Magnum. + + Magnum is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + Magnum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details. +*/ + +#include "magnumConfigure.h" + +#ifdef MAGNUM_GCC45_COMPATIBILITY +#define constexpr +#define nullptr 0 +#endif + +#endif diff --git a/src/magnumConfigure.h.cmake b/src/magnumConfigure.h.cmake index 9e8a3c7e8..7204ad4b7 100644 --- a/src/magnumConfigure.h.cmake +++ b/src/magnumConfigure.h.cmake @@ -1 +1,2 @@ #cmakedefine MAGNUM_TARGET_GLES +#cmakedefine MAGNUM_GCC45_COMPATIBILITY