diff --git a/cmake/CompilerOptions.cmake b/cmake/CompilerOptions.cmake index 9ae81d6e3cec183ccd50b67654a55d16dfa96af5..9fca7493a3179c8126681a93db1446ccf5001e9b 100644 --- a/cmake/CompilerOptions.cmake +++ b/cmake/CompilerOptions.cmake @@ -135,5 +135,12 @@ function(set_arch_target optvar arch) endif() endif() - set("${optvar}" "${arch_opt}" PARENT_SCOPE) + # Prefix architecture options with `-Xcompiler=` when compiling CUDA sources, i.e. + # with nvcc. + set(arch_opt_cuda_guarded) + foreach(opt ${arch_opt}) + list(APPEND arch_opt_cuda_guarded "$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=>${opt}") + endforeach() + + set("${optvar}" "${arch_opt_cuda_guarded}" PARENT_SCOPE) endfunction()