diff --git a/CMakeLists.txt b/CMakeLists.txt index f14d12bf9d3..c98b2d6a3e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2158,19 +2158,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) # Do not enable compiler specific language extensions. 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 # Clang on windows copies this behavior and does not support these switches if( diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake index a5366e4c8e0..327c7bb655f 100644 --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@ -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)