Bug 5701423: Add MSVC-specific flag /Zc:preprocessor as CCCL change the warning of this flag to error

This commit is contained in:
Shawn Zeng 2026-01-07 15:32:34 +08:00
parent 70fcdd353f
commit 17113ea87e
3 changed files with 9 additions and 4 deletions

View File

@ -1,5 +1,8 @@
## Changelog ## Changelog
### CUDA 13.2
* Added the MSVC compile flag `-Xcompiler=/Zc:preprocessor` in CMakeLists.txt to comply with CUDA13.2 CCCL. Previously, using the traditional preprocessor triggered the warning “MSVC/cl.exe with traditional preprocessor is used…”, which now leads to a build error.
### CUDA 13.1 ### CUDA 13.1
* Minor bug fixes and enhancements, no structural or functional changes * Minor bug fixes and enhancements, no structural or functional changes

View File

@ -22,6 +22,11 @@ endif()
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --extended-lambda") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --extended-lambda")
# Add MSVC-specific flags for standard-conforming preprocessor (required for CCCL)
if(MSVC)
add_compile_options($<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=/Zc:preprocessor>)
endif()
# Include installation configuration before processing samples # Include installation configuration before processing samples
include(cmake/InstallSamples.cmake) include(cmake/InstallSamples.cmake)

View File

@ -39,10 +39,7 @@ if(${OpenGL_FOUND})
# Add target for particles # Add target for particles
add_executable(particles particleSystem.cpp particleSystem_cuda.cu particles.cpp render_particles.cpp shaders.cpp) add_executable(particles particleSystem.cpp particleSystem_cuda.cu particles.cpp render_particles.cpp shaders.cpp)
target_compile_options(particles PRIVATE target_compile_options(particles PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>)
$<$<COMPILE_LANGUAGE:CUDA>:--extended-lambda>
$<$<AND:$<COMPILE_LANGUAGE:CUDA>,$<BOOL:${MSVC}>>:-Xcompiler="/Zc:preprocessor">
)
target_compile_features(particles PRIVATE cxx_std_17 cuda_std_17) target_compile_features(particles PRIVATE cxx_std_17 cuda_std_17)