GLM requires long long support (C++98) and anonymous struct (C++11), disable the warnings within GLM. Strict compilers support check is performed. #524

This commit is contained in:
Christophe Riccio 2016-07-16 18:36:56 +02:00
parent b157b1f6e3
commit 848d68fe96
6 changed files with 89 additions and 15 deletions

View File

@ -63,27 +63,16 @@ if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}"
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++98")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
set(CMAKE_CXX_FLAGS "-std=c++98")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# GLM is using GCC 64 bits integer extension
add_definitions(-Wno-long-long)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_definitions(-Wno-c++11-long-long)
endif()
endif()
endif()
option(GLM_TEST_ENABLE_MS_EXTENSIONS "Enable MS extensions" OFF)
option(GLM_TEST_ENABLE_LANG_EXTENSIONS "Enable language extensions" OFF)
if(GLM_TEST_ENABLE_MS_EXTENSIONS)
if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU"))
add_definitions(-Wgnu-anonymous-struct)
add_definitions(-Wnested-anon-types)
endif()
else()
if(NOT GLM_TEST_ENABLE_LANG_EXTENSIONS)
if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") OR (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") AND WIN32))
add_definitions(/Za)
# elseif(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU"))
# add_definitions(-pedantic)
elseif(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU"))
add_definitions(-pedantic)
endif()
endif()

View File

@ -29,12 +29,29 @@ namespace detail
# if(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) // C99 detected, 64 bit types available
typedef int64_t sint64;
typedef uint64_t uint64;
# elif GLM_COMPILER & GLM_COMPILER_VC
typedef signed __int64 sint64;
typedef unsigned __int64 uint64;
# elif GLM_COMPILER & GLM_COMPILER_GCC
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wno-long-long"
__extension__ typedef signed long long sint64;
__extension__ typedef unsigned long long uint64;
# pragma GCC diagnostic pop
# elif GLM_COMPILER & GLM_COMPILER_CLANG
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wno-c++11-long-long"
typedef signed long long sint64;
typedef unsigned long long uint64;
# pragma clang diagnostic pop
# else//unknown compiler
typedef signed long long sint64;
typedef unsigned long long uint64;

View File

@ -28,6 +28,16 @@ namespace glm
// -- Data --
# if GLM_HAS_UNRESTRICTED_UNIONS
# if GLM_COMPILER & GLM_COMPILER_GCC
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpedantic"
# endif
# if GLM_COMPILER & GLM_COMPILER_CLANG
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wgnu-anonymous-struct"
# pragma clang diagnostic ignored "-Wnested-anon-types"
# endif
union
{
T x;
@ -46,6 +56,13 @@ namespace glm
_GLM_SWIZZLE1_4_MEMBERS(T, P, tvec4, s)
# endif//GLM_SWIZZLE*/
};
# if GLM_COMPILER & GLM_COMPILER_CLANG
# pragma clang diagnostic pop
# endif
# if GLM_COMPILER & GLM_COMPILER_GCC
# pragma GCC diagnostic pop
# endif
# else
union {T x, r, s;};
/*

View File

@ -27,6 +27,16 @@ namespace glm
// -- Data --
# if GLM_HAS_UNRESTRICTED_UNIONS
# if GLM_COMPILER & GLM_COMPILER_GCC
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpedantic"
# endif
# if GLM_COMPILER & GLM_COMPILER_CLANG
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wgnu-anonymous-struct"
# pragma clang diagnostic ignored "-Wnested-anon-types"
# endif
union
{
struct{ T x, y; };
@ -46,6 +56,13 @@ namespace glm
# endif//GLM_SWIZZLE
};
# if GLM_COMPILER & GLM_COMPILER_CLANG
# pragma clang diagnostic pop
# endif
# if GLM_COMPILER & GLM_COMPILER_GCC
# pragma GCC diagnostic pop
# endif
# else
union {T x, r, s;};
union {T y, g, t;};

View File

@ -27,6 +27,16 @@ namespace glm
// -- Data --
# if GLM_HAS_UNRESTRICTED_UNIONS
# if GLM_COMPILER & GLM_COMPILER_GCC
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpedantic"
# endif
# if GLM_COMPILER & GLM_COMPILER_CLANG
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wgnu-anonymous-struct"
# pragma clang diagnostic ignored "-Wnested-anon-types"
# endif
union
{
struct{ T x, y, z; };
@ -45,6 +55,13 @@ namespace glm
_GLM_SWIZZLE3_4_MEMBERS(T, P, glm::tvec4, s, t, p)
# endif//GLM_SWIZZLE
};
# if GLM_COMPILER & GLM_COMPILER_CLANG
# pragma clang diagnostic pop
# endif
# if GLM_COMPILER & GLM_COMPILER_GCC
# pragma GCC diagnostic pop
# endif
# else
union { T x, r, s; };
union { T y, g, t; };

View File

@ -28,6 +28,16 @@ namespace glm
// -- Data --
# if GLM_HAS_UNRESTRICTED_UNIONS
# if GLM_COMPILER & GLM_COMPILER_GCC
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpedantic"
# endif
# if GLM_COMPILER & GLM_COMPILER_CLANG
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wgnu-anonymous-struct"
# pragma clang diagnostic ignored "-Wnested-anon-types"
# endif
union
{
struct { T x, y, z, w;};
@ -48,6 +58,13 @@ namespace glm
_GLM_SWIZZLE4_4_MEMBERS(T, P, glm::tvec4, s, t, p, q)
# endif//GLM_SWIZZLE
};
# if GLM_COMPILER & GLM_COMPILER_CLANG
# pragma clang diagnostic pop
# endif
# if GLM_COMPILER & GLM_COMPILER_GCC
# pragma GCC diagnostic pop
# endif
# else
union { T x, r, s; };
union { T y, g, t; };