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 (<cub/cub.cuh>, 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) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D1G8gJVAy6gp1K5Dz3NE5C
This commit is contained in:
1 parent
528af5e155
commit
95c0e832bb
1 file changed
+9
@@ -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($<$<COMPILE_LANGUAGE:CXX>:/EHsc>)
|
||||
ADD_COMPILE_OPTIONS($<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=/Zc:preprocessor>)
|
||||
ENDIF()
|
||||
|
||||
SET(JFJOCH_WRITER_ONLY OFF CACHE BOOL "Compile HDF5 writer only")
|
||||
|
||||
Reference in new issue
Block a user