From fa9fb60df332a430ed10ce007d3a07ec90aefcb5 Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Tue, 6 Jun 2023 23:41:02 +0200 Subject: CachedCMakePackage: fix bug where CMAKE_CUDA_ARCHITECTURES=none is set (#38169) #37592 updated cached cmake packages to set CMAKE_CUDA_ARCHITECTURES. The condition `if archs != "none"` lead to `CMAKE_CUDA_ARCHITECTURES=none` when cuda_arch=none (incorrect check on the value of a multi-valued variant), i.e. CMAKE_CUDA_ARCHITECTURES is always set. This PR udpates the condition to if archs[0] != "none" to ensure CMAKE_CUDA_ARCHITECTURES is only set if cuda_arch is not none (which seems to be the pattern used in other packages). This does the same for HIP (although in general ROCmPackage disallows amdgpu_target=none when +rocm). --- lib/spack/spack/build_systems/cached_cmake.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/spack/spack/build_systems/cached_cmake.py b/lib/spack/spack/build_systems/cached_cmake.py index cabe8d52d8..f1a466597c 100644 --- a/lib/spack/spack/build_systems/cached_cmake.py +++ b/lib/spack/spack/build_systems/cached_cmake.py @@ -252,7 +252,7 @@ class CachedCMakeBuilder(CMakeBuilder): entries.append(cmake_cache_path("CUDA_TOOLKIT_ROOT_DIR", cudatoolkitdir)) archs = spec.variants["cuda_arch"].value - if archs != "none": + if archs[0] != "none": arch_str = ";".join(archs) entries.append( cmake_cache_string("CMAKE_CUDA_ARCHITECTURES", "{0}".format(arch_str)) @@ -269,7 +269,7 @@ class CachedCMakeBuilder(CMakeBuilder): cmake_cache_path("HIP_CXX_COMPILER", "{0}".format(self.spec["hip"].hipcc)) ) archs = self.spec.variants["amdgpu_target"].value - if archs != "none": + if archs[0] != "none": arch_str = ";".join(archs) entries.append( cmake_cache_string("CMAKE_HIP_ARCHITECTURES", "{0}".format(arch_str)) -- cgit v1.2.3-70-g09d2