From 2d9980cc0218de5b1a00d04f2d960130cb77e6c4 Mon Sep 17 00:00:00 2001
From: Ben Cumming <bcumming@cscs.ch>
Date: Wed, 5 Sep 2018 10:49:26 +0200
Subject: [PATCH] Only make CUDA -march workaround if compiling with CUDA
 target (#585)

Fixes #584.
---
 cmake/CompilerOptions.cmake | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/cmake/CompilerOptions.cmake b/cmake/CompilerOptions.cmake
index 9fca7493..8a1e5ed4 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()
-- 
GitLab