diff --git a/cmake/CompilerOptions.cmake b/cmake/CompilerOptions.cmake index 9fca7493a3179c8126681a93db1446ccf5001e9b..8a1e5ed409029f428c967e9f251d859c52d82187 100644 --- a/cmake/CompilerOptions.cmake +++ b/cmake/CompilerOptions.cmake @@ -135,12 +135,15 @@ function(set_arch_target optvar arch) endif() endif() - # 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) + if (ARB_WITH_GPU) + # 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) + endif() + endfunction()