From 657ca108ed2d14b73e19c3bbc474a0f742a03964 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sat, 14 Jul 2018 16:22:17 +0200 Subject: [PATCH] Fixed Visual C++ language detection --- CMakeLists.txt | 10 ++++++++-- glm/detail/setup.hpp | 26 +++++++++++++------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 73b6f410..dcbbc16f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,22 +36,27 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) if(GLM_TEST_ENABLE_CXX_20) set(CMAKE_CXX_STANDARD 20) + add_definitions(-DGLM_FORCE_CXX2A) message(STATUS "GLM: Build with C++20 features") elseif(GLM_TEST_ENABLE_CXX_17) set(CMAKE_CXX_STANDARD 17) + add_definitions(-DGLM_FORCE_CXX17) message(STATUS "GLM: Build with C++17 features") elseif(GLM_TEST_ENABLE_CXX_14) set(CMAKE_CXX_STANDARD 14) + add_definitions(-DGLM_FORCE_CXX14) message(STATUS "GLM: Build with C++14 features") elseif(GLM_TEST_ENABLE_CXX_11) set(CMAKE_CXX_STANDARD 11) + add_definitions(-DGLM_FORCE_CXX11) message(STATUS "GLM: Build with C++11 features") elseif(GLM_TEST_ENABLE_CXX_98) set(CMAKE_CXX_STANDARD 98) + add_definitions(-DGLM_FORCE_CXX98) message(STATUS "GLM: Build with C++98 features") endif() @@ -61,12 +66,13 @@ if(GLM_TEST_ENABLE_LANG_EXTENSIONS) set(CMAKE_CXX_EXTENSIONS ON) if((CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "GNU")) add_compile_options(-fms-extensions) - elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - add_compile_options(/Za) endif() message(STATUS "GLM: Build with C++ language extensions") else() set(CMAKE_CXX_EXTENSIONS OFF) + if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + add_compile_options(/Za) + endif() endif() option(GLM_TEST_ENABLE_FAST_MATH "Enable fast math optimizations" OFF) diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index d157fea7..f140ce7c 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -83,9 +83,9 @@ #define GLM_LANG_CXXGNU GLM_LANG_CXXGNU_FLAG #ifdef _MSC_EXTENSIONS -# define GLM_MSC_EXT GLM_LANG_CXXMS_FLAG +# define GLM_LANG_EXT GLM_LANG_CXXMS_FLAG #else -# define GLM_MSC_EXT 0 +# define GLM_LANG_EXT 0 #endif #if defined(GLM_FORCE_CXX2A) @@ -93,7 +93,7 @@ # define GLM_MESSAGE_FORCE_CXX2A_DISPLAYED # pragma message("GLM: Force the use of C++2a only") # endif//GLM_MESSAGES -# define GLM_LANG (GLM_LANG_CXX2A | GLM_MSC_EXT) +# define GLM_LANG (GLM_LANG_CXX2A | GLM_LANG_EXT) # define GLM_LANG_STL11_FORCED #elif defined(GLM_FORCE_CXX17) # if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_MESSAGE_FORCE_CXX17_DISPLAYED) @@ -104,7 +104,7 @@ # pragma message("GLM: Force the use of C++17 on a compiler that doesn't have full C++17 support") # endif # endif//GLM_MESSAGES -# define GLM_LANG (GLM_LANG_CXX17 | GLM_MSC_EXT) +# define GLM_LANG (GLM_LANG_CXX17 | GLM_LANG_EXT) # define GLM_LANG_STL11_FORCED #elif defined(GLM_FORCE_CXX14) # if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_MESSAGE_FORCE_CXX14_DISPLAYED) @@ -115,7 +115,7 @@ # pragma message("GLM: Force the use of C++14 on a compiler that doesn't have full C++14 support") # endif # endif//GLM_MESSAGES -# define GLM_LANG (GLM_LANG_CXX14 | GLM_MSC_EXT) +# define GLM_LANG (GLM_LANG_CXX14 | GLM_LANG_EXT) # define GLM_LANG_STL11_FORCED #elif defined(GLM_FORCE_CXX11) # if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_MESSAGE_FORCE_CXX11_DISPLAYED) @@ -126,7 +126,7 @@ # pragma message("GLM: Force the use of C++11 on a compiler that doesn't have full C++11 support") # endif # endif//GLM_MESSAGES -# define GLM_LANG (GLM_LANG_CXX11 | GLM_MSC_EXT) +# define GLM_LANG (GLM_LANG_CXX11 | GLM_LANG_EXT) # define GLM_LANG_STL11_FORCED #elif defined(GLM_FORCE_CXX03) # define GLM_LANG GLM_LANG_CXX03 @@ -140,19 +140,19 @@ # endif # if __cplusplus > 201703L || GLM_LANG_PLATFORM > 201703L -# define GLM_LANG (GLM_LANG_CXX2A | GLM_MSC_EXT) +# define GLM_LANG (GLM_LANG_CXX2A | GLM_LANG_EXT) # elif __cplusplus == 201703L || GLM_LANG_PLATFORM == 201703L -# define GLM_LANG (GLM_LANG_CXX17 | GLM_MSC_EXT) +# define GLM_LANG (GLM_LANG_CXX17 | GLM_LANG_EXT) # elif __cplusplus == 201402L || GLM_LANG_PLATFORM == 201402L -# define GLM_LANG (GLM_LANG_CXX14 | GLM_MSC_EXT) +# define GLM_LANG (GLM_LANG_CXX14 | GLM_LANG_EXT) # elif __cplusplus == 201103L || GLM_LANG_PLATFORM == 201103L -# define GLM_LANG (GLM_LANG_CXX11 | GLM_MSC_EXT) +# define GLM_LANG (GLM_LANG_CXX11 | GLM_LANG_EXT) # elif defined(__INTEL_CXX11_MODE__) || defined(_MSC_VER) || defined(__GXX_EXPERIMENTAL_CXX0X__) -# define GLM_LANG (GLM_LANG_CXX0X | GLM_MSC_EXT) +# define GLM_LANG (GLM_LANG_CXX0X | GLM_LANG_EXT) # elif __cplusplus == 199711L -# define GLM_LANG (GLM_LANG_CXX98 | GLM_MSC_EXT) +# define GLM_LANG (GLM_LANG_CXX98 | GLM_LANG_EXT) # else -# define GLM_LANG (GLM_LANG_CXX | GLM_MSC_EXT) +# define GLM_LANG (0 | GLM_LANG_EXT) # endif #endif