Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Molenkamp <github@lazydodo.com>2020-02-12 22:49:34 +0300
committerRay Molenkamp <github@lazydodo.com>2020-02-12 22:49:34 +0300
commit9fe469c110940af5d2525158305d5d365bd15276 (patch)
tree3944557e2117fbe67c1ee5bfcd793bc5d3b9a96c /build_files
parentdd9dfadaac9b17d0a5f41545925668717b662b08 (diff)
Cleanup/MSVC: Enable C++ conformance mode on compiler versions that support it.
MSVC has a conformance mode (/permissive-) where the C++ standard is more strictly enforced. This mode is available on MSVC 15.5+ [1] This patch enables this mode on compilers that support it and cleans up the few violations it threw up in the process. - Mantaflow was using M_PI without requesting them using the _USE_MATH_DEFINES define to opt in to non default behaviour. - Collada did not include the right header for std::cerr, this seemingly was fixed for other platforms already but put inside a platform guard. - Ghost had some scoping issues regarding uninitialized variables and goto behaviour [1] https://docs.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance Differential Revision: https://developer.blender.org/D6824 Reviewed By: brecht
Diffstat (limited to 'build_files')
-rw-r--r--build_files/cmake/platform/platform_win32.cmake13
1 files changed, 13 insertions, 0 deletions
diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake
index 653b3a9f508..5eccc6c66be 100644
--- a/build_files/cmake/platform/platform_win32.cmake
+++ b/build_files/cmake/platform/platform_win32.cmake
@@ -144,6 +144,19 @@ else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /nologo /J /Gd /MP /bigobj")
endif()
+# C++ standards conformace (/permissive-) is available on msvc 15.5 (1912) and up
+if(MSVC_VERSION GREATER 1911 AND NOT MSVC_CLANG)
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /permissive-")
+ # MSVC 2017 emits a whole lot of warnings (C4199) about two-phase lookup
+ # in combination with OpenMP, however my current MSVC2019 (16.4) does not.
+ # From the documentation it is not entirely clear when this got solved,
+ # so for any compiler versions >= 15.5 and < 16.4 opt in to the old non-conforming behavior.
+ if(MSVC_VERSION LESS 1924)
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Zc:twoPhase-")
+ endif()
+endif()
+
+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd /ZI")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MDd /ZI")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")