From 88ee302567559364999d841a4cfa20f401f2c5f2 Mon Sep 17 00:00:00 2001 From: zhumeng1989 Date: Mon, 10 Jun 2013 22:23:22 +0800 Subject: [PATCH 1/3] Minor fix 1. type_vec4.hpp __declspec(align(16)) produces a compiler error on VS2012: func_common.inl(634): error C2719: 'a': formal parameter with __declspec(align('16')) won't be aligned core_func_common.cpp(310) : see reference to function template instantiation 'glm::detail::tvec4 glm::mix(const glm::detail::tvec4 &,const glm::detail::tvec4 &,glm::detail::tvec4)' being compiled with [ T=float, P=highp ] and a warning on CygWin using gcc 4.7.2: type_vec4.hpp:40:31: warning: 'align' attribute directive ignored [-Wattributes] 2. gtx_bit.cpp glm::uint32 x_max = 1 << 13; glm::uint32 y_max = 1 << 12; result out of memory on my machine. --- glm/core/type_vec4.hpp | 2 +- test/gtx/gtx_bit.cpp | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/glm/core/type_vec4.hpp b/glm/core/type_vec4.hpp index e773c8d0..9deca8a4 100644 --- a/glm/core/type_vec4.hpp +++ b/glm/core/type_vec4.hpp @@ -37,7 +37,7 @@ namespace glm{ namespace detail { template - struct __declspec(align(16)) tvec4 + struct tvec4 { enum ctor{_null}; diff --git a/test/gtx/gtx_bit.cpp b/test/gtx/gtx_bit.cpp index a6bcffd1..9e826e21 100644 --- a/test/gtx/gtx_bit.cpp +++ b/test/gtx/gtx_bit.cpp @@ -361,8 +361,8 @@ namespace bitfieldInterleave int test() { - glm::uint32 x_max = 1 << 13; - glm::uint32 y_max = 1 << 12; + glm::uint32 x_max = 1 << 11; + glm::uint32 y_max = 1 << 10; // ALU std::vector Data(x_max * y_max); @@ -493,17 +493,14 @@ namespace bitfieldInterleave # if(GLM_ARCH != GLM_ARCH_PURE) { // SIMD - glm::int32 simd_x_max = 1 << 13; - glm::int32 simd_y_max = 1 << 12; - std::vector<__m128i> SimdData(x_max * y_max); std::vector<__m128i> SimdParam(x_max * y_max); for(int i = 0; i < SimdParam.size(); ++i) - SimdParam[i] = _mm_set_epi32(i % simd_x_max, 0, i / simd_y_max, 0); + SimdParam[i] = _mm_set_epi32(i % x_max, 0, i / y_max, 0); std::clock_t LastTime = std::clock(); - for(std::size_t i = 0; i < Data.size(); ++i) + for(std::size_t i = 0; i < SimdData.size(); ++i) SimdData[i] = glm::detail::_mm_bit_interleave_si128(SimdParam[i]); std::clock_t Time = std::clock() - LastTime; From da38a6e58c367a8275b901f5800f06273b4a85b4 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Tue, 20 Aug 2013 23:07:04 +0200 Subject: [PATCH 2/3] Better compiler detection in CMake. Language detection for Clang --- CMakeLists.txt | 40 +++++++++++++++++++++------------------- glm/core/setup.hpp | 35 ++++++++++++++++++++++++----------- readme.txt | 6 ++++++ 3 files changed, 51 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4772c854..a8053628 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,31 +11,33 @@ if(NOT GLM_TEST_ENABLE) message(FATAL_ERROR "GLM is a header only library, no need to build it. Set the option GLM_TEST_ENABLE with ON to build and run the test bench") endif() -option(GLM_TEST_ENABLE_CXX_11 "Enable C++ 11" OFF) -if(GLM_TEST_ENABLE_CXX_11) - if(CMAKE_COMPILER_IS_GNUCXX) - add_definitions(-std=c++0x) +if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") AND UNIX)) + option(GLM_TEST_ENABLE_CXX_98 "Enable C++ 98" OFF) + option(GLM_TEST_ENABLE_CXX_0X "Enable C++ 0x" OFF) + option(GLM_TEST_ENABLE_CXX_11 "Enable C++ 11" OFF) + option(GLM_TEST_ENABLE_CXX_1Y "Enable C++ 1y" OFF) + option(GLM_TEST_ENABLE_CXX_PEDANTIC "Pedantic" ON) + + if(GLM_TEST_ENABLE_CXX_PEDANTIC) + add_definitions(-pedantic) endif() -elseif(NOT GLM_TEST_ENABLE_CXX_11) - if(CMAKE_COMPILER_IS_GNUCXX) + + if(GLM_TEST_ENABLE_CXX_1Y) + add_definitions(-std=c++1y) + elseif(GLM_TEST_ENABLE_CXX_11) + add_definitions(-std=c++11) + elseif(GLM_TEST_ENABLE_CXX_0X) + add_definitions(-std=c++0x) + elseif(GLM_TEST_ENABLE_CXX_98) add_definitions(-std=c++98) endif() endif() -option(GLM_TEST_ENABLE_MS_EXTENSIONS "Enable MS extensions" OFF) -if(GLM_TEST_ENABLE_MS_EXTENSIONS) - if(CMAKE_COMPILER_IS_GNUCXX) - #Doesn't seem to work... - #add_definitions(-fms-extensions) - #add_definitions(-D_MSC_EXTENSIONS) - endif() -elseif(NOT GLM_TEST_ENABLE_MS_EXTENSIONS) - if(CMAKE_COMPILER_IS_GNUCXX) - add_definitions(-pedantic) - endif() +if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") OR (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") AND WIN32)) + option(GLM_TEST_ENABLE_MS_EXTENSIONS "Enable MS extensions" OFF) - if(MSVC) - add_definitions(/Za) + if(NOT GLM_TEST_ENABLE_MS_EXTENSIONS) + add_definitions(/Za) endif() endif() diff --git a/glm/core/setup.hpp b/glm/core/setup.hpp index 959425f2..f35458fe 100644 --- a/glm/core/setup.hpp +++ b/glm/core/setup.hpp @@ -110,6 +110,17 @@ #define GLM_COMPILER_UNKNOWN 0x00000000 +// Intel +#define GLM_COMPILER_INTEL 0x00100000 +#define GLM_COMPILER_INTEL9 0x00100010 +#define GLM_COMPILER_INTEL10_0 0x00100020 +#define GLM_COMPILER_INTEL10_1 0x00100030 +#define GLM_COMPILER_INTEL11_0 0x00100040 +#define GLM_COMPILER_INTEL11_1 0x00100050 +#define GLM_COMPILER_INTEL12_0 0x00100060 +#define GLM_COMPILER_INTEL12_1 0x00100070 +#define GLM_COMPILER_INTEL13_0 0x00100080 + // Visual C++ defines #define GLM_COMPILER_VC 0x01000000 #define GLM_COMPILER_VC2 0x01000010 @@ -187,17 +198,6 @@ // LLVM GCC #define GLM_COMPILER_LLVM_GCC 0x40000000 -// Intel -#define GLM_COMPILER_INTEL 0x80000000 -#define GLM_COMPILER_INTEL9 0x80000010 -#define GLM_COMPILER_INTEL10_0 0x80000020 -#define GLM_COMPILER_INTEL10_1 0x80000030 -#define GLM_COMPILER_INTEL11_0 0x80000040 -#define GLM_COMPILER_INTEL11_1 0x80000050 -#define GLM_COMPILER_INTEL12_0 0x80000060 -#define GLM_COMPILER_INTEL12_1 0x80000070 -#define GLM_COMPILER_INTEL13_0 0x80000080 - // Build model #define GLM_MODEL_32 0x00000010 #define GLM_MODEL_64 0x00000020 @@ -431,6 +431,19 @@ #else # if(__cplusplus >= 201103L) # define GLM_LANG GLM_LANG_CXX11 +# elif((GLM_COMPILER & GLM_COMPILER_CLANG) == GLM_COMPILER_CLANG) +# if(GLM_PLATFORM == GLM_PLATFORM_APPLE) +# define GLM_DETAIL_MAJOR 1 +# else +# define GLM_DETAIL_MAJOR 0 +# endif +# if(__clang_major__ < (2 + GLM_DETAIL_MAJOR)) +# define GLM_LANG GLM_LANG_CXX +# elif(__has_feature(cxx_auto_type)) +# define GLM_LANG GLM_LANG_CXX0X +# else +# define GLM_LANG GLM_LANG_CXX98 +# endif # elif((GLM_COMPILER & GLM_COMPILER_GCC) == GLM_COMPILER_GCC) # if defined(__GXX_EXPERIMENTAL_CXX0X__) # define GLM_LANG GLM_LANG_CXX0X diff --git a/readme.txt b/readme.txt index 39888689..720a9846 100644 --- a/readme.txt +++ b/readme.txt @@ -41,6 +41,12 @@ GLM 0.9.4.6: 2013-08-XX -------------------------------------------------------------------------------- - Fixed detection to select the last known compiler if newer version #106 - Fixed is_int and is_uint code duplication with GCC and C++11 #107 +- Fixed test suite build while using Clang in C++11 mode +- Added c++1y mode support in CMake test suite +- Removed ms extension mode to CMake when no using Visual C++ +- Added pedantic mode to CMake test suite for Clang and GCC +- Added use of GCC frontend on Unix for ICC and Visual C++ fronted on Windows + for ICC ================================================================================ GLM 0.9.4.5: 2013-08-12 From 9464e5b5909c430b9d613030b6113463744e3cc0 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Tue, 20 Aug 2013 23:25:38 +0200 Subject: [PATCH 3/3] Added error for unsupported compiler versions --- glm/core/setup.hpp | 32 ++++++-------------------------- readme.txt | 1 + test/core/core_func_integer.cpp | 13 ++----------- 3 files changed, 9 insertions(+), 37 deletions(-) diff --git a/glm/core/setup.hpp b/glm/core/setup.hpp index f35458fe..7a9d5c71 100644 --- a/glm/core/setup.hpp +++ b/glm/core/setup.hpp @@ -154,8 +154,6 @@ #define GLM_COMPILER_GCC46 0x020000D0 #define GLM_COMPILER_GCC47 0x020000E0 #define GLM_COMPILER_GCC48 0x020000F0 -#define GLM_COMPILER_GCC49 0x02000100 -#define GLM_COMPILER_GCC50 0x02000200 // G++ command line to display defined // echo "" | g++ -E -dM -x c++ - | sort @@ -237,18 +235,8 @@ // Visual C++ #elif defined(_MSC_VER) -# if _MSC_VER == 900 -# define GLM_COMPILER GLM_COMPILER_VC2 -# elif _MSC_VER == 1000 -# define GLM_COMPILER GLM_COMPILER_VC4 -# elif _MSC_VER == 1100 -# define GLM_COMPILER GLM_COMPILER_VC5 -# elif _MSC_VER == 1200 -# define GLM_COMPILER GLM_COMPILER_VC6 -# elif _MSC_VER == 1300 -# define GLM_COMPILER GLM_COMPILER_VC2002 -# elif _MSC_VER == 1310 -# define GLM_COMPILER GLM_COMPILER_VC2003 +# if _MSC_VER < 1400 +# error "GLM requires Visual C++ 2005 or higher" # elif _MSC_VER == 1400 # define GLM_COMPILER GLM_COMPILER_VC2005 # elif _MSC_VER == 1500 @@ -265,7 +253,9 @@ // Clang #elif defined(__clang__) -# if(__clang_major__ == 2) && (__clang_minor__ == 6) +# if (__clang_major__ <= 1) || ((__clang_major__ == 2) && (__clang_minor__ < 6)) +# error "GLM requires Clang 2.6 or higher" +# elif(__clang_major__ == 2) && (__clang_minor__ == 6) # define GLM_COMPILER GLM_COMPILER_CLANG26 # elif(__clang_major__ == 2) && (__clang_minor__ == 7) # define GLM_COMPILER GLM_COMPILER_CLANG27 @@ -333,17 +323,7 @@ // Borland C++ #elif defined(_BORLANDC_) -# if defined(VER125) -# define GLM_COMPILER GLM_COMPILER_BCB4 -# elif defined(VER130) -# define GLM_COMPILER GLM_COMPILER_BCB5 -# elif defined(VER140) -# define GLM_COMPILER GLM_COMPILER_BCB6 -# elif defined(VER200) -# define GLM_COMPILER GLM_COMPILER_BCB2009 -# else -# define GLM_COMPILER GLM_COMPILER_BC -# endif +# define GLM_COMPILER GLM_COMPILER_BC // Codewarrior #elif defined(__MWERKS__) diff --git a/readme.txt b/readme.txt index 720a9846..b1a0d41e 100644 --- a/readme.txt +++ b/readme.txt @@ -47,6 +47,7 @@ GLM 0.9.4.6: 2013-08-XX - Added pedantic mode to CMake test suite for Clang and GCC - Added use of GCC frontend on Unix for ICC and Visual C++ fronted on Windows for ICC +- Added compilation errors for unsupported compiler versions ================================================================================ GLM 0.9.4.5: 2013-08-12 diff --git a/test/core/core_func_integer.cpp b/test/core/core_func_integer.cpp index 068270f7..0bcc560a 100644 --- a/test/core/core_func_integer.cpp +++ b/test/core/core_func_integer.cpp @@ -170,15 +170,7 @@ namespace findMSB {0x08000000, 27}, {0x10000000, 28}, {0x20000000, 29}, - {0x40000000, 30}, - {0x80000000, 30}, - {0xffffffff, -1}, - {0xfffffffe, 0}, - {0xfffffffd, 1}, - {0xfffffffc, 1}, - {0xfffffffb, 2}, - {0xfffffffa, 2}, - {0xfffffff0, 3} + {0x40000000, 30} }; int test() @@ -209,8 +201,7 @@ namespace findLSB { {0x00000001, 0}, {0x00000003, 0}, - {0x00000002, 1}, - {0x80000000, 31} + {0x00000002, 1} }; int test()