Added C++2a detection and fixed constexpr tests

This commit is contained in:
Groove 2018-07-11 21:59:25 +02:00
parent 1381e0b4c1
commit b76f938505
12 changed files with 34 additions and 30 deletions

View File

@ -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")

View File

@ -1,6 +1,7 @@
/// @ref core
/// @file glm/glm.cpp
#define GLM_FORCE_MESSAGES
#define GLM_ENABLE_EXPERIMENTAL
#include <glm/glm.hpp>
#include <glm/ext/vec1.hpp>

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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