Browse Source

Using CORRADE_GCC*_COMPATIBILITY instead of MAGNUM_GCC*_COMPATIBILITY.

It's pointless to have Corrade with compatibility enabled and Magnum
without, because even if it somewhat compiles, it won't link together.
Moreover, explicitly setting compatibility in Magnum while Corrade has
it already enabled is only maitenance burden.
Vladimír Vondruš 14 years ago
parent
commit
5f8890d558
  1. 2
      CMakeLists.txt
  2. 15
      src/CMakeLists.txt
  3. 4
      src/Math/Matrix4.h
  4. 2
      src/MeshTools/Clean.h
  5. 2
      src/MeshTools/CompressIndices.h
  6. 16
      src/SizeTraits.h
  7. 2
      src/Test/SwizzleTest.cpp
  8. 2
      src/magnumCompatibility.h
  9. 2
      src/magnumConfigure.h.cmake

2
CMakeLists.txt

@ -5,8 +5,6 @@ project(Magnum)
include(CMakeDependentOption)
option(TARGET_GLES "Build for OpenGL ES 2 instead of desktop OpenGL" OFF)
option(GCC44_COMPATIBILITY "Enable compatibility mode for GCC 4.4 (might disable some features)" OFF)
option(GCC45_COMPATIBILITY "Enable compatibility mode for GCC 4.5 (might disable some features)" OFF)
# Parts of the library
option(WITH_EVERYTHING "Build everything (doesn't include contexts)" ON)

15
src/CMakeLists.txt

@ -5,21 +5,10 @@ if(TARGET_GLES)
set(MAGNUM_TARGET_GLES 1)
endif()
if(GCC44_COMPATIBILITY)
set(MAGNUM_GCC44_COMPATIBILITY 1)
set(GCC45_COMPATIBILITY 1)
endif()
if(GCC45_COMPATIBILITY)
set(MAGNUM_GCC45_COMPATIBILITY 1)
endif()
# -Wdouble-promotion is supported from GCC 4.6
# TODO: do this with check_c_compiler_flags()
if(NOT GCC45_COMPATIBILITY)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdouble-promotion")
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND NOT "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "4.6.0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdouble-promotion")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/magnumConfigure.h.cmake

4
src/Math/Matrix4.h

@ -130,7 +130,7 @@ template<class T> class Matrix4: public Matrix<4, T> {
/** @brief Rotation and scaling part of the matrix */
inline Matrix3<T> rotationScaling() const {
#ifndef MAGNUM_GCC45_COMPATIBILITY /* GCC 4.5 badly optimizes this */
#ifndef CORRADE_GCC45_COMPATIBILITY /* GCC 4.5 badly optimizes this */
return Matrix3<T>::from(
(*this)[0].xyz(),
(*this)[1].xyz(),
@ -146,7 +146,7 @@ template<class T> class Matrix4: public Matrix<4, T> {
/** @brief Rotation part of the matrix */
inline Matrix3<T> rotation() const {
return Matrix3<T>::from(
#ifndef MAGNUM_GCC45_COMPATIBILITY /* GCC 4.5 badly optimizes this */
#ifndef CORRADE_GCC45_COMPATIBILITY /* GCC 4.5 badly optimizes this */
(*this)[0].xyz().normalized(),
(*this)[1].xyz().normalized(),
(*this)[2].xyz().normalized());

2
src/MeshTools/Clean.h

@ -66,7 +66,7 @@ template<class Vertex, size_t vertexSize = Vertex::Size> class Clean {
and index of vertex in the face. */
std::unordered_map<Math::Vector<vertexSize, size_t>, HashedVertex, IndexHash> table;
#ifndef MAGNUM_GCC44_COMPATIBILITY
#ifndef CORRADE_GCC44_COMPATIBILITY
/* Reserve space for all vertices */
table.reserve(vertices.size());
#endif

2
src/MeshTools/CompressIndices.h

@ -38,7 +38,7 @@ class CompressIndices {
CompressIndices(const std::vector<unsigned int>& indices): indices(indices) {}
inline std::tuple<size_t, Type, char*> operator()() const {
#ifndef MAGNUM_GCC44_COMPATIBILITY
#ifndef CORRADE_GCC44_COMPATIBILITY
return SizeBasedCall<Compressor>(*std::max_element(indices.begin(), indices.end()))(indices);
#else
return SizeBasedCall<std::tuple<size_t, Type, char*>, Compressor>(*std::max_element(indices.begin(), indices.end()))(indices);

16
src/SizeTraits.h

@ -97,7 +97,7 @@ based on data size:
bar = SizeBasedCall<Foo>(dataSize)(arg1, arg2, ...);
@endcode
*/
#ifndef MAGNUM_GCC44_COMPATIBILITY
#ifndef CORRADE_GCC44_COMPATIBILITY
template<class Base> struct SizeBasedCall: public Base {
#else
template<class Return, class Base> struct SizeBasedCall: public Base {
@ -117,10 +117,10 @@ template<class Return, class Base> struct SizeBasedCall: public Base {
* is no suitable type for indexing given data size, prints message to
* error output and returns default-constructed value.
*/
#ifndef MAGNUM_GCC45_COMPATIBILITY
#ifndef CORRADE_GCC45_COMPATIBILITY
template<typename ...Args> auto operator()(Args&&... arguments) -> decltype(Base::template run<GLubyte>(std::forward<Args>(arguments)...)) {
#else
#ifdef MAGNUM_GCC44_COMPATIBILITY
#ifdef CORRADE_GCC44_COMPATIBILITY
template<typename Args> Return operator()(Args&& arguments) {
#else
template<typename Args> auto operator()(Args&& arguments) -> decltype(Base::template run<GLubyte>(std::forward<Args>(arguments))) {
@ -128,20 +128,20 @@ template<class Return, class Base> struct SizeBasedCall: public Base {
#endif
switch(Math::log(256, size)) {
case 0:
#ifndef MAGNUM_GCC45_COMPATIBILITY
#ifndef CORRADE_GCC45_COMPATIBILITY
return Base::template run<GLubyte>(std::forward<Args>(arguments)...);
#else
return Base::template run<GLubyte>(std::forward<Args>(arguments));
#endif
case 1:
#ifndef MAGNUM_GCC45_COMPATIBILITY
#ifndef CORRADE_GCC45_COMPATIBILITY
return Base::template run<GLushort>(std::forward<Args>(arguments)...);
#else
return Base::template run<GLushort>(std::forward<Args>(arguments));
#endif
case 2:
case 3:
#ifndef MAGNUM_GCC45_COMPATIBILITY
#ifndef CORRADE_GCC45_COMPATIBILITY
return Base::template run<GLuint>(std::forward<Args>(arguments)...);
#else
return Base::template run<GLuint>(std::forward<Args>(arguments));
@ -149,10 +149,10 @@ template<class Return, class Base> struct SizeBasedCall: public Base {
}
Error() << "SizeBasedCall: no type able to index" << size << "elements.";
#ifndef MAGNUM_GCC45_COMPATIBILITY
#ifndef CORRADE_GCC45_COMPATIBILITY
return decltype(Base::template run<GLubyte>(std::forward<Args>(arguments)...))();
#else
#ifdef MAGNUM_GCC44_COMPATIBILITY
#ifdef CORRADE_GCC44_COMPATIBILITY
return Return();
#else
return decltype(Base::template run<GLubyte>(std::forward<Args>(arguments)))();

2
src/Test/SwizzleTest.cpp

@ -52,7 +52,7 @@ void SwizzleTest::rgba() {
void SwizzleTest::fromSmall() {
/* Force compile-time evaluation for both */
constexpr Vector2 orig(1, 2);
#ifndef MAGNUM_GCC45_COMPATIBILITY
#ifndef CORRADE_GCC45_COMPATIBILITY
CORRADE_VERIFY((integral_constant<bool, swizzle(orig, "gxr").x() == 2>::value));
#endif
CORRADE_COMPARE((swizzle<'g', 'x', 'r'>(orig)), Vector3(2, 1, 1));

2
src/magnumCompatibility.h

@ -17,7 +17,7 @@
#include "magnumConfigure.h"
#ifdef MAGNUM_GCC45_COMPATIBILITY
#ifdef CORRADE_GCC45_COMPATIBILITY
#define constexpr
#define nullptr 0
#endif

2
src/magnumConfigure.h.cmake

@ -1,3 +1 @@
#cmakedefine MAGNUM_TARGET_GLES
#cmakedefine MAGNUM_GCC44_COMPATIBILITY
#cmakedefine MAGNUM_GCC45_COMPATIBILITY

Loading…
Cancel
Save