Cleanup: Centralize MSVC conformance related cmake items

Move the MSVC conformance flags to a win32-specific central location.

Pull Request: https://projects.blender.org/blender/blender/pulls/119235
This commit is contained in:
Jesse Yurkovich
2024-03-09 23:42:20 +01:00
committed by Jesse Yurkovich
parent 61a88e525b
commit 5b522359ee
2 changed files with 21 additions and 18 deletions
@@ -170,10 +170,10 @@ remove_cc_flag(
if(MSVC_CLANG) # Clangs version of cl doesn't support all flags
string(APPEND CMAKE_CXX_FLAGS " ${CXX_WARN_FLAGS} /nologo /J /Gd /EHsc -Wno-unused-command-line-argument -Wno-microsoft-enum-forward-reference ")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /nologo /J /Gd -Wno-unused-command-line-argument -Wno-microsoft-enum-forward-reference")
string(APPEND CMAKE_C_FLAGS " /nologo /J /Gd -Wno-unused-command-line-argument -Wno-microsoft-enum-forward-reference")
else()
string(APPEND CMAKE_CXX_FLAGS " /nologo /J /Gd /MP /EHsc /bigobj /Zc:inline")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /nologo /J /Gd /MP /bigobj /Zc:inline")
string(APPEND CMAKE_CXX_FLAGS " /nologo /J /Gd /MP /EHsc /bigobj")
string(APPEND CMAKE_C_FLAGS " /nologo /J /Gd /MP /bigobj")
endif()
# X64 ASAN is available and usable on MSVC 16.9 preview 4 and up)
@@ -191,9 +191,25 @@ if(WITH_COMPILER_ASAN AND MSVC AND NOT MSVC_CLANG)
endif()
# C++ standards conformace (/permissive-) is available on msvc 15.5 (1912) and up
# C++ standards conformace
# /permissive- : Available from MSVC 15.5 (1912) and up. Enables standards-confirming compiler
# behavior. Required until the project is marked as c++20.
# /Zc:__cplusplus : Available from MSVC 15.7 (1914) and up. Ensures correct value of the __cplusplus
# preprocessor macro.
# /Zc:inline : Enforces C++11 requirement that all functions declared 'inline' must have a
# definition available in the same translation unit if they're used.
# /Zc:preprocessor: Available from MSVC 16.5 (1925) and up. Enables standards-conforming
# preprocessor.
if(NOT MSVC_CLANG)
string(APPEND CMAKE_CXX_FLAGS " /permissive-")
string(APPEND CMAKE_CXX_FLAGS " /permissive- /Zc:__cplusplus /Zc:inline")
string(APPEND CMAKE_C_FLAGS " /Zc:inline")
# For ARM64 devices, we need to tell MSVC to use the new preprocessor
# This is because sse2neon requires it.
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64")
string(APPEND CMAKE_CXX_FLAGS " /Zc:preprocessor")
string(APPEND CMAKE_C_FLAGS " /Zc:preprocessor")
endif()
endif()
if(WITH_WINDOWS_SCCACHE AND CMAKE_VS_MSBUILD_COMMAND)