diff options
author | Ray Molenkamp <github@lazydodo.com> | 2020-02-14 03:13:07 +0300 |
---|---|---|
committer | Ray Molenkamp <github@lazydodo.com> | 2020-02-14 03:13:07 +0300 |
commit | 75a5ea01c19563ae1ba427e9206f2eae637d6070 (patch) | |
tree | c611b4c77aaec2414dd2ca2f42dc539f4e57916a /build_files | |
parent | 4af74f453d4e41129626f7578c55ac9927f6d02a (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
Second landing of this patch, earlier commit was reverted due to some compiler configurations having slipped though testing
[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.cmake | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake index 653b3a9f508..cfa4f1c9bf7 100644 --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@ -144,6 +144,14 @@ 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 "${CMAKE_CXX_FLAGS} /permissive-") + # Two-phase name lookup does not place nicely with OpenMP yet, so disable for now + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:twoPhase-") +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") |