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:
parent
61a88e525b
commit
5b522359ee
@ -2158,19 +2158,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|||||||
# Do not enable compiler specific language extensions.
|
# Do not enable compiler specific language extensions.
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
# 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.
|
|
||||||
# In addition, for ARM64 devices, we need to tell MSVC to use the new preprocessor
|
|
||||||
# This is because sse2neon requires it.
|
|
||||||
if(MSVC)
|
|
||||||
string(APPEND CMAKE_CXX_FLAGS " /Zc:__cplusplus")
|
|
||||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64")
|
|
||||||
string(APPEND CMAKE_CXX_FLAGS " /Zc:preprocessor")
|
|
||||||
string(APPEND CMAKE_C_FLAGS " /Zc:preprocessor")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Visual Studio has all standards it supports available by default
|
# Visual Studio has all standards it supports available by default
|
||||||
# Clang on windows copies this behavior and does not support these switches
|
# Clang on windows copies this behavior and does not support these switches
|
||||||
if(
|
if(
|
||||||
|
@ -170,10 +170,10 @@ remove_cc_flag(
|
|||||||
|
|
||||||
if(MSVC_CLANG) # Clangs version of cl doesn't support all flags
|
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 ")
|
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()
|
else()
|
||||||
string(APPEND CMAKE_CXX_FLAGS " /nologo /J /Gd /MP /EHsc /bigobj /Zc:inline")
|
string(APPEND CMAKE_CXX_FLAGS " /nologo /J /Gd /MP /EHsc /bigobj")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /nologo /J /Gd /MP /bigobj /Zc:inline")
|
string(APPEND CMAKE_C_FLAGS " /nologo /J /Gd /MP /bigobj")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# X64 ASAN is available and usable on MSVC 16.9 preview 4 and up)
|
# 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()
|
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)
|
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()
|
endif()
|
||||||
|
|
||||||
if(WITH_WINDOWS_SCCACHE AND CMAKE_VS_MSBUILD_COMMAND)
|
if(WITH_WINDOWS_SCCACHE AND CMAKE_VS_MSBUILD_COMMAND)
|
||||||
|
Loading…
Reference in New Issue
Block a user