Browse Source

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

Christophe Riccio 9 years ago
parent
commit
848d68fe96
6 changed files with 89 additions and 15 deletions
  1. 4 15
      CMakeLists.txt
  2. 17 0
      glm/detail/type_int.hpp
  3. 17 0
      glm/detail/type_vec1.hpp
  4. 17 0
      glm/detail/type_vec2.hpp
  5. 17 0
      glm/detail/type_vec3.hpp
  6. 17 0
      glm/detail/type_vec4.hpp

+ 4 - 15
CMakeLists.txt

@@ -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_LANGUAGE_STANDARD "c++98")
 		set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
 		set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
 		set(CMAKE_CXX_FLAGS "-std=c++98")
 		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()
 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))
 	if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") OR (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") AND WIN32))
 		add_definitions(/Za)
 		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()
 endif()
 endif()
 
 

+ 17 - 0
glm/detail/type_int.hpp

@@ -29,12 +29,29 @@ namespace detail
 #		if(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) // C99 detected, 64 bit types available
 #		if(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) // C99 detected, 64 bit types available
 			typedef int64_t					sint64;
 			typedef int64_t					sint64;
 			typedef uint64_t				uint64;
 			typedef uint64_t				uint64;
+	
 #		elif GLM_COMPILER & GLM_COMPILER_VC
 #		elif GLM_COMPILER & GLM_COMPILER_VC
 			typedef signed __int64			sint64;
 			typedef signed __int64			sint64;
 			typedef unsigned __int64		uint64;
 			typedef unsigned __int64		uint64;
+	
 #		elif GLM_COMPILER & GLM_COMPILER_GCC
 #		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 signed long long		sint64;
 			__extension__ typedef unsigned long long	uint64;
 			__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
 #		else//unknown compiler
 			typedef signed long	long		sint64;
 			typedef signed long	long		sint64;
 			typedef unsigned long long		uint64;
 			typedef unsigned long long		uint64;

+ 17 - 0
glm/detail/type_vec1.hpp

@@ -28,6 +28,16 @@ namespace glm
 		// -- Data --
 		// -- Data --
 
 
 #		if GLM_HAS_UNRESTRICTED_UNIONS
 #		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
 			union
 			{
 			{
 				T x;
 				T x;
@@ -46,6 +56,13 @@ namespace glm
 					_GLM_SWIZZLE1_4_MEMBERS(T, P, tvec4, s)
 					_GLM_SWIZZLE1_4_MEMBERS(T, P, tvec4, s)
 #				endif//GLM_SWIZZLE*/
 #				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
 #		else
 			union {T x, r, s;};
 			union {T x, r, s;};
 /*
 /*

+ 17 - 0
glm/detail/type_vec2.hpp

@@ -27,6 +27,16 @@ namespace glm
 		// -- Data --
 		// -- Data --
 
 
 #		if GLM_HAS_UNRESTRICTED_UNIONS
 #		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
 			union
 			{
 			{
 				struct{ T x, y; };
 				struct{ T x, y; };
@@ -46,6 +56,13 @@ namespace glm
 #				endif//GLM_SWIZZLE
 #				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
 #		else
 			union {T x, r, s;};
 			union {T x, r, s;};
 			union {T y, g, t;};
 			union {T y, g, t;};

+ 17 - 0
glm/detail/type_vec3.hpp

@@ -27,6 +27,16 @@ namespace glm
 		// -- Data --
 		// -- Data --
 
 
 #		if GLM_HAS_UNRESTRICTED_UNIONS
 #		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
 			union
 			{
 			{
 				struct{ T x, y, z; };
 				struct{ T x, y, z; };
@@ -45,6 +55,13 @@ namespace glm
 					_GLM_SWIZZLE3_4_MEMBERS(T, P, glm::tvec4, s, t, p)
 					_GLM_SWIZZLE3_4_MEMBERS(T, P, glm::tvec4, s, t, p)
 #				endif//GLM_SWIZZLE
 #				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
 #		else
 			union { T x, r, s; };
 			union { T x, r, s; };
 			union { T y, g, t; };
 			union { T y, g, t; };

+ 17 - 0
glm/detail/type_vec4.hpp

@@ -28,6 +28,16 @@ namespace glm
 		// -- Data --
 		// -- Data --
 
 
 #		if GLM_HAS_UNRESTRICTED_UNIONS
 #		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
 			union
 			{
 			{
 				struct { T x, y, z, w;};
 				struct { T x, y, z, w;};
@@ -48,6 +58,13 @@ namespace glm
 					_GLM_SWIZZLE4_4_MEMBERS(T, P, glm::tvec4, s, t, p, q)
 					_GLM_SWIZZLE4_4_MEMBERS(T, P, glm::tvec4, s, t, p, q)
 #				endif//GLM_SWIZZLE
 #				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
 #		else
 			union { T x, r, s; };
 			union { T x, r, s; };
 			union { T y, g, t; };
 			union { T y, g, t; };