From 95c0e832bb579ff3bc1e3fb3b305e292c7b34f41 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Tue, 29 Sep 2026 07:11:53 +0200 Subject: [PATCH] Build: MSVC conforming preprocessor for CUDA sources (CCCL needs it) The Windows CUDA 13.3 build failed on rugnux/RigidBodyGPU.cu, the first of our own .cu files to include CCCL (, for the gather's stable radix sort): CCCL #errors when nvcc's host compiler cl.exe runs its traditional preprocessor. Pass -Xcompiler=/Zc:preprocessor to every CUDA compile under MSVC, via a COMPILE_LANGUAGE:CUDA add_compile_options next to the /EHsc one, so it reaches all CUDA targets including fetched ones. ffbidx already sets the same flag for its own CUB-using kernel, which is why the older CUDA targets built. C++ sources are left alone: none includes CCCL (cuda_runtime.h/cufft.h do not pull it in). Linux: all 243 generated flags.make files are byte-identical before and after. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01D1G8gJVAy6gp1K5Dz3NE5C --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f6f34abd4..1caea9809 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,8 +28,17 @@ SET(CMAKE_CXX_STANDARD_REQUIRED True) # Catch2 compiles itself with CATCH_CONFIG_DISABLE_EXCEPTIONS. Adding it here, before any # FetchContent, reaches every C++ target whatever CMAKE_CXX_FLAGS holds. CUDA gets it from its own # default CMAKE_CUDA_FLAGS, which nothing overrides. +# +# CUDA's CCCL headers (cub, thrust, libcu++) stop with an #error under MSVC's traditional +# preprocessor, which miscompiles their macros. nvcc preprocesses and compiles host code with cl.exe, +# so the standard-conforming preprocessor is switched on for .cu sources here, reaching every CUDA +# target, fetched ones included (VS 2019 16.5 or newer). ffbidx already sets the same for its own +# CUB-using kernel, which is why the other CUDA targets never needed it. C++ sources keep the +# default: none includes a CCCL header, and the switch would change the preprocessing of Qt, the +# Windows SDK and every fetched dependency with nothing to gain. IF (MSVC) ADD_COMPILE_OPTIONS($<$:/EHsc>) + ADD_COMPILE_OPTIONS($<$:-Xcompiler=/Zc:preprocessor>) ENDIF() SET(JFJOCH_WRITER_ONLY OFF CACHE BOOL "Compile HDF5 writer only")