summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--var/spack/repos/builtin/packages/kokkos/package.py52
1 files changed, 19 insertions, 33 deletions
diff --git a/var/spack/repos/builtin/packages/kokkos/package.py b/var/spack/repos/builtin/packages/kokkos/package.py
index cc7fb73e11..7e2469fbf5 100644
--- a/var/spack/repos/builtin/packages/kokkos/package.py
+++ b/var/spack/repos/builtin/packages/kokkos/package.py
@@ -175,6 +175,7 @@ class Kokkos(CMakePackage, CudaPackage, ROCmPackage):
conflicts("+wrapper", when="~cuda")
stds = ["11", "14", "17", "20"]
+ # TODO: This should be named cxxstd for consistency with other packages
variant("std", default="14", values=stds, multi=False)
variant("pic", default=False, description="Build position independent code")
@@ -208,18 +209,10 @@ class Kokkos(CMakePackage, CudaPackage, ROCmPackage):
def append_args(self, cmake_prefix, cmake_options, spack_options):
variant_to_cmake_option = {'rocm': 'hip'}
for variant_name in cmake_options:
- enablestr = "+%s" % variant_name
opt = variant_to_cmake_option.get(variant_name, variant_name)
- optuc = opt.upper()
- optname = "Kokkos_%s_%s" % (cmake_prefix, optuc)
- option = None
- if enablestr in self.spec:
- option = "-D%s=ON" % optname
- else:
- # explicitly turn off if not enabled
- # this avoids any confusing implicit defaults
- # that come from the CMake
- option = "-D%s=OFF" % optname
+ optname = "Kokkos_%s_%s" % (cmake_prefix, opt.upper())
+ # Explicitly enable or disable
+ option = self.define_from_variant(optname, variant_name)
if option not in spack_options:
spack_options.append(option)
@@ -231,6 +224,7 @@ class Kokkos(CMakePackage, CudaPackage, ROCmPackage):
def cmake_args(self):
spec = self.spec
+ from_variant = self.define_from_variant
if spec.satisfies("~wrapper+cuda") and not (
spec.satisfies("%clang") or spec.satisfies("%cce")
@@ -238,14 +232,11 @@ class Kokkos(CMakePackage, CudaPackage, ROCmPackage):
raise InstallError("Kokkos requires +wrapper when using +cuda"
"without clang")
- options = []
-
- isdiy = "+diy" in spec
- if isdiy:
- options.append("-DSpack_WORKAROUND=On")
-
- if "+pic" in spec:
- options.append("-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
+ options = [
+ from_variant("CMAKE_POSITION_INDEPENDENT_CODE", "pic"),
+ from_variant("Kokkos_CXX_STANDARD", "std"),
+ from_variant("BUILD_SHARED_LIBS", "shared"),
+ ]
spack_microarches = []
if "+cuda" in spec:
@@ -272,29 +263,24 @@ class Kokkos(CMakePackage, CudaPackage, ROCmPackage):
amdgpu_target))
for arch in spack_microarches:
- options.append("-DKokkos_ARCH_%s=ON" % arch.upper())
+ options.append(self.define("Kokkos_ARCH_" + arch.upper(), True))
self.append_args("ENABLE", self.devices_values, options)
self.append_args("ENABLE", self.options_values, options)
self.append_args("ENABLE", self.tpls_values, options)
for tpl in self.tpls_values:
- var = "+%s" % tpl
- if var in self.spec:
- options.append("-D%s_DIR=%s" % (tpl, spec[tpl].prefix))
+ if spec.variants[tpl].value:
+ options.append(self.define(tpl + "_DIR", spec[tpl].prefix))
if '+rocm' in self.spec:
- options.append('-DCMAKE_CXX_COMPILER=%s' %
- self.spec['hip'].hipcc)
+ options.append(self.define(
+ 'CMAKE_CXX_COMPILER', self.spec['hip'].hipcc))
elif '+wrapper' in self.spec:
- options.append("-DCMAKE_CXX_COMPILER=%s" %
- self.spec["kokkos-nvcc-wrapper"].kokkos_cxx)
-
- # Set the C++ standard to use
- options.append("-DKokkos_CXX_STANDARD=%s" %
- self.spec.variants["std"].value)
-
- options.append('-DBUILD_SHARED_LIBS=%s' % ('+shared' in self.spec))
+ options.append(self.define(
+ "CMAKE_CXX_COMPILER",
+ self.spec["kokkos-nvcc-wrapper"].kokkos_cxx
+ ))
return options