MSVC: Set proper flags for C++17 support.

MSVC already builds with the /std:c++17 flag but for
'reasons' [1] MSVC still gives the wrong value for the
__cplusplus define.

This change sets an additional cxx flag on supported
compilers to allow the compiler properly identify
C++17 support.

This resolves 2 warnings coming out of bullet about
the register keyword being deprecated.

[1] https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
This commit is contained in:
Ray molenkamp 2020-08-26 22:25:40 -06:00
parent bbf00a6231
commit 8b82693898
1 changed files with 6 additions and 0 deletions

View File

@ -1571,6 +1571,12 @@ endif()
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17")
# Make MSVC properly report the value of the __cplusplus preprocessor macro
# Available MSVC 15.7 (1914) and up, without this it reports 199711L regardless
# of the C++ standard chosen above
if(MSVC_VERSION GREATER 1913)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")
endif()
elseif(
CMAKE_COMPILER_IS_GNUCC OR
CMAKE_C_COMPILER_ID MATCHES "Clang" OR