From f8da6eafca3f8290f19143c8b0596925370f979f Mon Sep 17 00:00:00 2001
From: Sam Yates <yates@cscs.ch>
Date: Wed, 5 Sep 2018 13:10:16 +0200
Subject: [PATCH] Tweak fix for CUDA not-enabled with ARB_ARCH specification.
 (#586)

Fixes #584.

* Add CUDA compile guard generator expression to architecture options iff CUDA is an enabled language.
---
 cmake/CompilerOptions.cmake | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/cmake/CompilerOptions.cmake b/cmake/CompilerOptions.cmake
index 8a1e5ed4..5ab1586c 100644
--- a/cmake/CompilerOptions.cmake
+++ b/cmake/CompilerOptions.cmake
@@ -135,7 +135,8 @@ function(set_arch_target optvar arch)
         endif()
     endif()
 
-    if (ARB_WITH_GPU)
+    get_property(enabled_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
+    if ("CUDA" IN_LIST enabled_languages)
         # Prefix architecture options with `-Xcompiler=` when compiling CUDA sources, i.e.
         # with nvcc.
         set(arch_opt_cuda_guarded)
@@ -144,6 +145,8 @@ function(set_arch_target optvar arch)
         endforeach()
 
         set("${optvar}" "${arch_opt_cuda_guarded}" PARENT_SCOPE)
+    else()
+        set("${optvar}" "${arch_opt}" PARENT_SCOPE)
     endif()
 
 endfunction()
-- 
GitLab