diff --git a/CMakeLists.txt b/CMakeLists.txt index 5314ff9093..383d6ca3c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -204,6 +204,13 @@ if((USE_CUDA OR USE_TRT_RTX) AND CMAKE_CUDA_COMPILER) $<$:-Wno-deprecated-gpu-targets> $<$,$>:-Xcompiler=/wd4996> ) + + # nvcc compiles CUDA code with cl.exe, so we need to pass the /Zc:preprocessor option to avoid compilation errors + if(WIN32 AND MSVC AND MSVC_VERSION GREATER_EQUAL 1925) + add_compile_options( + $<$,$>:-Xcompiler=/Zc:preprocessor> + ) + endif() if(WIN32) add_library(onnxruntime-genai-cuda SHARED ${generator_cudalib_srcs} "${GENERATORS_ROOT}/dll/onnxruntime-genai.rc")