From b459659dc482d021b192ef2e9e1d15aa19d83cdf Mon Sep 17 00:00:00 2001 From: Morgan Funtowicz Date: Mon, 3 Aug 2026 08:12:37 +0200 Subject: [PATCH 1/2] fix: missing compilation flag on recent msvc version --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 352f1bfb2..5054673df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -338,12 +338,12 @@ if(WIN32) endif() if(MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast /Zc:preprocessor") + # /arch:AVX2 is only valid for x86/x64 targets, not ARM64 string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" _msvc_arch) if(_msvc_arch MATCHES "x86|x64|amd64") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2 /fp:fast") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2") endif() endif() From d799cfd0ae5190d38624d6bc0a74b74599fcadcb Mon Sep 17 00:00:00 2001 From: Morgan Funtowicz Date: Wed, 12 Aug 2026 10:14:24 +0200 Subject: [PATCH 2/2] Gate /Zc:preprocessor to cl.exe only CMake's MSVC variable is also true for MSVC-emulating compilers (clang-cl, and Intel icx used by the XPU backend on Windows), which ship an already-conformant preprocessor and warn on the flag: icx: warning: argument unused during compilation: '-Zc:preprocessor' Restrict the switch to CMAKE_CXX_COMPILER_ID == MSVC. --- CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5054673df..950f8d213 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -338,7 +338,13 @@ if(WIN32) endif() if(MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast /Zc:preprocessor") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast") + + # Only real cl.exe needs (and accepts) the conformant preprocessor switch; + # clang-cl / icx are already conformant and warn on it. + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:preprocessor") + endif() # /arch:AVX2 is only valid for x86/x64 targets, not ARM64 string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" _msvc_arch)