diff --git a/CMakeLists.txt b/CMakeLists.txt index e5159b0f..fab76a99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,10 +30,15 @@ option(GLM_TEST_ENABLE_CXX_98 "Enable C++ 98" OFF) option(GLM_TEST_ENABLE_CXX_11 "Enable C++ 11" OFF) option(GLM_TEST_ENABLE_CXX_14 "Enable C++ 14" OFF) option(GLM_TEST_ENABLE_CXX_17 "Enable C++ 17" OFF) +option(GLM_TEST_ENABLE_CXX_20 "Enable C++ 20" OFF) set(CMAKE_CXX_STANDARD_REQUIRED ON) -if(GLM_TEST_ENABLE_CXX_17) +if(GLM_TEST_ENABLE_CXX_20) + set(CMAKE_CXX_STANDARD 20) + message(STATUS "GLM: Build with C++20 features") + +elseif(GLM_TEST_ENABLE_CXX_17) set(CMAKE_CXX_STANDARD 17) message(STATUS "GLM: Build with C++17 features") diff --git a/glm/detail/glm.cpp b/glm/detail/glm.cpp index f4224ac0..e9bbc700 100644 --- a/glm/detail/glm.cpp +++ b/glm/detail/glm.cpp @@ -1,6 +1,7 @@ /// @ref core /// @file glm/glm.cpp +#define GLM_FORCE_MESSAGES #define GLM_ENABLE_EXPERIMENTAL #include #include diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index 29401a19..8cba6daf 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -127,8 +127,9 @@ #define GLM_LANG_CXX11_FLAG (1 << 4) #define GLM_LANG_CXX14_FLAG (1 << 5) #define GLM_LANG_CXX17_FLAG (1 << 6) -#define GLM_LANG_CXXMS_FLAG (1 << 7) -#define GLM_LANG_CXXGNU_FLAG (1 << 8) +#define GLM_LANG_CXX2A_FLAG (1 << 7) +#define GLM_LANG_CXXMS_FLAG (1 << 8) +#define GLM_LANG_CXXGNU_FLAG (1 << 9) #define GLM_LANG_CXX98 GLM_LANG_CXX98_FLAG #define GLM_LANG_CXX03 (GLM_LANG_CXX98 | GLM_LANG_CXX03_FLAG) @@ -136,6 +137,7 @@ #define GLM_LANG_CXX11 (GLM_LANG_CXX0X | GLM_LANG_CXX11_FLAG) #define GLM_LANG_CXX14 (GLM_LANG_CXX11 | GLM_LANG_CXX14_FLAG) #define GLM_LANG_CXX17 (GLM_LANG_CXX14 | GLM_LANG_CXX17_FLAG) +#define GLM_LANG_CXX2A (GLM_LANG_CXX17 | GLM_LANG_CXX2A_FLAG) #define GLM_LANG_CXXMS GLM_LANG_CXXMS_FLAG #define GLM_LANG_CXXGNU GLM_LANG_CXXGNU_FLAG @@ -146,14 +148,23 @@ #endif #ifdef _MSVC_LANG -# if _MSVC_LANG == 201703 -# define GLM_FORCE_CXX17 -# elif _MSVC_LANG == 201402 +# if _MSVC_LANG == 201402 # define GLM_FORCE_CXX14 +# elif _MSVC_LANG == 201703 +# define GLM_FORCE_CXX17 +# elif _MSVC_LANG > 201703 +# define GLM_FORCE_CXX2A # endif #endif -#if defined(GLM_FORCE_CXX17) +#if defined(GLM_FORCE_CXX2A) +# if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_FORCE_CXX2A_DISPLAYED) +# 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_STL11_FORCED +#elif defined(GLM_FORCE_CXX17) # if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_MESSAGE_FORCE_CXX17_DISPLAYED) # define GLM_MESSAGE_FORCE_CXX17_DISPLAYED # if (__cplusplus >= 201703L) || ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC15_7)) || ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC80)) || ((GLM_COMPILER & GLM_COMPILER_CLANG) && (GLM_COMPILER >= GLM_COMPILER_CLANG50)) @@ -248,7 +259,6 @@ # endif #else # define GLM_HAS_CXX11_STL ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ - ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC48)) || \ ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12)) || \ ((GLM_PLATFORM != GLM_PLATFORM_WINDOWS) && (GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL15)))) #endif @@ -260,7 +270,6 @@ # define GLM_HAS_STATIC_ASSERT 1 #else # define GLM_HAS_STATIC_ASSERT ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ - ((GLM_COMPILER & GLM_COMPILER_GCC)) || \ ((GLM_COMPILER & GLM_COMPILER_CUDA)) || \ ((GLM_COMPILER & GLM_COMPILER_VC)))) #endif @@ -272,7 +281,6 @@ # define GLM_HAS_EXTENDED_INTEGER_TYPE (\ ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_VC)) || \ ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_CUDA)) || \ - ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC)) || \ ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_CLANG))) #endif @@ -283,7 +291,6 @@ # define GLM_HAS_INITIALIZER_LISTS 1 #else # define GLM_HAS_INITIALIZER_LISTS ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ - ((GLM_COMPILER & GLM_COMPILER_GCC)) || \ ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12)) || \ ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL14)) || \ ((GLM_COMPILER & GLM_COMPILER_CUDA) && (GLM_COMPILER >= GLM_COMPILER_CUDA75)))) @@ -297,8 +304,7 @@ #else # define GLM_HAS_UNRESTRICTED_UNIONS (GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ (GLM_COMPILER & GLM_COMPILER_VC) || \ - ((GLM_COMPILER & GLM_COMPILER_CUDA) && (GLM_COMPILER >= GLM_COMPILER_CUDA75)) || \ - ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC46))) + ((GLM_COMPILER & GLM_COMPILER_CUDA) && (GLM_COMPILER >= GLM_COMPILER_CUDA75))) #endif // N2346 @@ -310,7 +316,6 @@ # define GLM_HAS_DEFAULTED_FUNCTIONS 1 #else # define GLM_HAS_DEFAULTED_FUNCTIONS ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ - ((GLM_COMPILER & GLM_COMPILER_GCC)) || \ ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12)) || \ ((GLM_COMPILER & GLM_COMPILER_INTEL)) || \ (GLM_COMPILER & GLM_COMPILER_CUDA))) @@ -323,7 +328,6 @@ # define GLM_HAS_RVALUE_REFERENCES 1 #else # define GLM_HAS_RVALUE_REFERENCES ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ - ((GLM_COMPILER & GLM_COMPILER_GCC)) || \ ((GLM_COMPILER & GLM_COMPILER_VC)) || \ ((GLM_COMPILER & GLM_COMPILER_CUDA)))) #endif @@ -335,7 +339,6 @@ # define GLM_HAS_EXPLICIT_CONVERSION_OPERATORS 1 #else # define GLM_HAS_EXPLICIT_CONVERSION_OPERATORS ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ - ((GLM_COMPILER & GLM_COMPILER_GCC)) || \ ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL14)) || \ ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12)) || \ ((GLM_COMPILER & GLM_COMPILER_CUDA)))) @@ -349,7 +352,6 @@ #else # define GLM_HAS_TEMPLATE_ALIASES ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ ((GLM_COMPILER & GLM_COMPILER_INTEL)) || \ - ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC47)) || \ ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12)) || \ ((GLM_COMPILER & GLM_COMPILER_CUDA)))) #endif @@ -361,7 +363,6 @@ # define GLM_HAS_RANGE_FOR 1 #else # define GLM_HAS_RANGE_FOR ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ - ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC46)) || \ ((GLM_COMPILER & GLM_COMPILER_INTEL)) || \ ((GLM_COMPILER & GLM_COMPILER_VC)) || \ ((GLM_COMPILER & GLM_COMPILER_CUDA)))) @@ -374,7 +375,6 @@ # define GLM_HAS_ALIGNOF 1 #else # define GLM_HAS_ALIGNOF ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\ - ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC48)) || \ ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL15)) || \ ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC14)) || \ ((GLM_COMPILER & GLM_COMPILER_CUDA) && (GLM_COMPILER >= GLM_COMPILER_CUDA70)))) @@ -389,7 +389,6 @@ // GCC 4.6 support constexpr but there is a compiler bug causing a crash // Visual C++ has a bug #594 https://github.com/g-truc/glm/issues/594 # define GLM_HAS_CONSTEXPR_CXX11 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_ARCH == GLM_ARCH_PURE) && (\ - ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC48)) || \ ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL14)) || \ ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC14)))) #endif @@ -407,7 +406,6 @@ # define GLM_HAS_CONSTEXPR_CXX14 1 #else # define GLM_HAS_CONSTEXPR_CXX14 ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_ARCH == GLM_ARCH_PURE) && GLM_HAS_INITIALIZER_LISTS && (\ - ((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC50)) || \ ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL17)) || \ ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC15)))) #endif diff --git a/test/core/core_type_mat2x2.cpp b/test/core/core_type_mat2x2.cpp index 933ca543..059331ce 100644 --- a/test/core/core_type_mat2x2.cpp +++ b/test/core/core_type_mat2x2.cpp @@ -157,7 +157,7 @@ int test_size() int test_constexpr() { -#if GLM_HAS_CONSTEXPR_CXX11 +#if GLM_HAS_CONSTEXPR_CXX14 static_assert(glm::mat2x2::length() == 2, "GLM: Failed constexpr"); #endif diff --git a/test/core/core_type_mat2x3.cpp b/test/core/core_type_mat2x3.cpp index de98e007..8a35cd10 100644 --- a/test/core/core_type_mat2x3.cpp +++ b/test/core/core_type_mat2x3.cpp @@ -122,7 +122,7 @@ int test_size() int test_constexpr() { -#if GLM_HAS_CONSTEXPR_CXX11 +#if GLM_HAS_CONSTEXPR_CXX14 static_assert(glm::mat2x3::length() == 2, "GLM: Failed constexpr"); #endif diff --git a/test/core/core_type_mat2x4.cpp b/test/core/core_type_mat2x4.cpp index 50749d22..80575cf0 100644 --- a/test/core/core_type_mat2x4.cpp +++ b/test/core/core_type_mat2x4.cpp @@ -124,7 +124,7 @@ static int test_size() static int test_constexpr() { -#if GLM_HAS_CONSTEXPR_CXX11 +#if GLM_HAS_CONSTEXPR_CXX14 static_assert(glm::mat2x4::length() == 2, "GLM: Failed constexpr"); #endif diff --git a/test/core/core_type_mat3x2.cpp b/test/core/core_type_mat3x2.cpp index 14a5f1e7..873e1513 100644 --- a/test/core/core_type_mat3x2.cpp +++ b/test/core/core_type_mat3x2.cpp @@ -126,7 +126,7 @@ static int test_size() static int test_constexpr() { -#if GLM_HAS_CONSTEXPR_CXX11 +#if GLM_HAS_CONSTEXPR_CXX14 static_assert(glm::mat3x2::length() == 3, "GLM: Failed constexpr"); #endif diff --git a/test/core/core_type_mat3x3.cpp b/test/core/core_type_mat3x3.cpp index 609b9dbe..6fc33c9c 100644 --- a/test/core/core_type_mat3x3.cpp +++ b/test/core/core_type_mat3x3.cpp @@ -185,7 +185,7 @@ static int test_size() static int test_constexpr() { -#if GLM_HAS_CONSTEXPR_CXX11 +#if GLM_HAS_CONSTEXPR_CXX14 static_assert(glm::mat3x3::length() == 3, "GLM: Failed constexpr"); GLM_CONSTEXPR_CXX11 glm::mat3x3 const Z(0.0f); diff --git a/test/core/core_type_mat3x4.cpp b/test/core/core_type_mat3x4.cpp index 29accacc..85f22708 100644 --- a/test/core/core_type_mat3x4.cpp +++ b/test/core/core_type_mat3x4.cpp @@ -128,7 +128,7 @@ static int test_size() static int test_constexpr() { -#if GLM_HAS_CONSTEXPR_CXX11 +#if GLM_HAS_CONSTEXPR_CXX14 static_assert(glm::mat3x4::length() == 3, "GLM: Failed constexpr"); #endif diff --git a/test/core/core_type_mat4x2.cpp b/test/core/core_type_mat4x2.cpp index 915505d6..0fa91561 100644 --- a/test/core/core_type_mat4x2.cpp +++ b/test/core/core_type_mat4x2.cpp @@ -130,7 +130,7 @@ static int test_size() static int test_constexpr() { -#if GLM_HAS_CONSTEXPR_CXX11 +#if GLM_HAS_CONSTEXPR_CXX14 static_assert(glm::mat4x2::length() == 4, "GLM: Failed constexpr"); #endif diff --git a/test/core/core_type_mat4x3.cpp b/test/core/core_type_mat4x3.cpp index 1c8e47f6..0fa30368 100644 --- a/test/core/core_type_mat4x3.cpp +++ b/test/core/core_type_mat4x3.cpp @@ -130,7 +130,7 @@ static int test_size() static int test_constexpr() { -#if GLM_HAS_CONSTEXPR_CXX11 +#if GLM_HAS_CONSTEXPR_CXX14 static_assert(glm::mat4x3::length() == 4, "GLM: Failed constexpr"); #endif diff --git a/test/core/core_type_mat4x4.cpp b/test/core/core_type_mat4x4.cpp index 6d7d2438..89a4205c 100644 --- a/test/core/core_type_mat4x4.cpp +++ b/test/core/core_type_mat4x4.cpp @@ -323,7 +323,7 @@ static int test_constexpr() { glm::mat4 const I(1.0f); -#if GLM_HAS_CONSTEXPR_CXX11 +#if GLM_HAS_CONSTEXPR_CXX14 static_assert(glm::mat4::length() == 4, "GLM: Failed constexpr"); #endif