[Bf-blender-cvs] [8b826938985] master: MSVC: Set proper flags for C++17 support.

Ray Molenkamp noreply at git.blender.org
Thu Aug 27 06:25:45 CEST 2020


Commit: 8b8269389858b54052149a576f1a562e18540862
Author: Ray Molenkamp
Date:   Wed Aug 26 22:25:40 2020 -0600
Branches: master
https://developer.blender.org/rB8b8269389858b54052149a576f1a562e18540862

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/

===================================================================

M	CMakeLists.txt

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1ac88e81547..87557b6e905 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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



More information about the Bf-blender-cvs mailing list