Fixed Visual C++ language detection

This commit is contained in:
Christophe Riccio 2018-07-14 16:22:17 +02:00
parent cb3436886e
commit 657ca108ed
2 changed files with 21 additions and 15 deletions

View File

@ -36,22 +36,27 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(GLM_TEST_ENABLE_CXX_20) if(GLM_TEST_ENABLE_CXX_20)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
add_definitions(-DGLM_FORCE_CXX2A)
message(STATUS "GLM: Build with C++20 features") message(STATUS "GLM: Build with C++20 features")
elseif(GLM_TEST_ENABLE_CXX_17) elseif(GLM_TEST_ENABLE_CXX_17)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
add_definitions(-DGLM_FORCE_CXX17)
message(STATUS "GLM: Build with C++17 features") message(STATUS "GLM: Build with C++17 features")
elseif(GLM_TEST_ENABLE_CXX_14) elseif(GLM_TEST_ENABLE_CXX_14)
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 14)
add_definitions(-DGLM_FORCE_CXX14)
message(STATUS "GLM: Build with C++14 features") message(STATUS "GLM: Build with C++14 features")
elseif(GLM_TEST_ENABLE_CXX_11) elseif(GLM_TEST_ENABLE_CXX_11)
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
add_definitions(-DGLM_FORCE_CXX11)
message(STATUS "GLM: Build with C++11 features") message(STATUS "GLM: Build with C++11 features")
elseif(GLM_TEST_ENABLE_CXX_98) elseif(GLM_TEST_ENABLE_CXX_98)
set(CMAKE_CXX_STANDARD 98) set(CMAKE_CXX_STANDARD 98)
add_definitions(-DGLM_FORCE_CXX98)
message(STATUS "GLM: Build with C++98 features") message(STATUS "GLM: Build with C++98 features")
endif() endif()
@ -61,12 +66,13 @@ if(GLM_TEST_ENABLE_LANG_EXTENSIONS)
set(CMAKE_CXX_EXTENSIONS ON) set(CMAKE_CXX_EXTENSIONS ON)
if((CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "GNU")) if((CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "GNU"))
add_compile_options(-fms-extensions) add_compile_options(-fms-extensions)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_options(/Za)
endif() endif()
message(STATUS "GLM: Build with C++ language extensions") message(STATUS "GLM: Build with C++ language extensions")
else() else()
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_options(/Za)
endif()
endif() endif()
option(GLM_TEST_ENABLE_FAST_MATH "Enable fast math optimizations" OFF) option(GLM_TEST_ENABLE_FAST_MATH "Enable fast math optimizations" OFF)

View File

@ -83,9 +83,9 @@
#define GLM_LANG_CXXGNU GLM_LANG_CXXGNU_FLAG #define GLM_LANG_CXXGNU GLM_LANG_CXXGNU_FLAG
#ifdef _MSC_EXTENSIONS #ifdef _MSC_EXTENSIONS
# define GLM_MSC_EXT GLM_LANG_CXXMS_FLAG # define GLM_LANG_EXT GLM_LANG_CXXMS_FLAG
#else #else
# define GLM_MSC_EXT 0 # define GLM_LANG_EXT 0
#endif #endif
#if defined(GLM_FORCE_CXX2A) #if defined(GLM_FORCE_CXX2A)
@ -93,7 +93,7 @@
# define GLM_MESSAGE_FORCE_CXX2A_DISPLAYED # define GLM_MESSAGE_FORCE_CXX2A_DISPLAYED
# pragma message("GLM: Force the use of C++2a only") # pragma message("GLM: Force the use of C++2a only")
# endif//GLM_MESSAGES # 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 # define GLM_LANG_STL11_FORCED
#elif defined(GLM_FORCE_CXX17) #elif defined(GLM_FORCE_CXX17)
# if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_MESSAGE_FORCE_CXX17_DISPLAYED) # 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") # pragma message("GLM: Force the use of C++17 on a compiler that doesn't have full C++17 support")
# endif # endif
# endif//GLM_MESSAGES # 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 # define GLM_LANG_STL11_FORCED
#elif defined(GLM_FORCE_CXX14) #elif defined(GLM_FORCE_CXX14)
# if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_MESSAGE_FORCE_CXX14_DISPLAYED) # 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") # pragma message("GLM: Force the use of C++14 on a compiler that doesn't have full C++14 support")
# endif # endif
# endif//GLM_MESSAGES # 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 # define GLM_LANG_STL11_FORCED
#elif defined(GLM_FORCE_CXX11) #elif defined(GLM_FORCE_CXX11)
# if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_MESSAGE_FORCE_CXX11_DISPLAYED) # 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") # pragma message("GLM: Force the use of C++11 on a compiler that doesn't have full C++11 support")
# endif # endif
# endif//GLM_MESSAGES # 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 # define GLM_LANG_STL11_FORCED
#elif defined(GLM_FORCE_CXX03) #elif defined(GLM_FORCE_CXX03)
# define GLM_LANG GLM_LANG_CXX03 # define GLM_LANG GLM_LANG_CXX03
@ -140,19 +140,19 @@
# endif # endif
# if __cplusplus > 201703L || GLM_LANG_PLATFORM > 201703L # 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 # 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 # 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 # 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__) # 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 # elif __cplusplus == 199711L
# define GLM_LANG (GLM_LANG_CXX98 | GLM_MSC_EXT) # define GLM_LANG (GLM_LANG_CXX98 | GLM_LANG_EXT)
# else # else
# define GLM_LANG (GLM_LANG_CXX | GLM_MSC_EXT) # define GLM_LANG (0 | GLM_LANG_EXT)
# endif # endif
#endif #endif