CMakePackage: allow custom CMAKE_PREFIX_PATH entries (#32547)
* define `cmake_prefix_paths` property for packages add to CMake arguments via CMakePackage Co-authored-by: Robert Underwood <runderwood@anl.gov>
This commit is contained in:
parent
e3f87035b6
commit
02151ac649
@ -1030,8 +1030,11 @@ def get_cmake_prefix_path(pkg):
|
||||
spack_built.insert(0, dspec)
|
||||
|
||||
ordered_build_link_deps = spack_built + externals
|
||||
build_link_prefixes = filter_system_paths(x.prefix for x in ordered_build_link_deps)
|
||||
return build_link_prefixes
|
||||
cmake_prefix_path_entries = []
|
||||
for spec in ordered_build_link_deps:
|
||||
cmake_prefix_path_entries.extend(spec.package.cmake_prefix_paths)
|
||||
|
||||
return filter_system_paths(cmake_prefix_path_entries)
|
||||
|
||||
|
||||
def _setup_pkg_and_run(
|
||||
|
@ -1740,6 +1740,10 @@ def content_hash(self, content=None):
|
||||
|
||||
return b32_hash
|
||||
|
||||
@property
|
||||
def cmake_prefix_paths(self):
|
||||
return [self.prefix]
|
||||
|
||||
def _has_make_target(self, target):
|
||||
"""Checks to see if 'target' is a valid target in a Makefile.
|
||||
|
||||
|
@ -133,6 +133,14 @@ def test_url_for_version_with_no_urls(mock_packages, config):
|
||||
pkg_cls(spec).url_for_version("1.1")
|
||||
|
||||
|
||||
def test_custom_cmake_prefix_path(mock_packages, config):
|
||||
spec = Spec("depends-on-define-cmake-prefix-paths").concretized()
|
||||
|
||||
assert spack.build_environment.get_cmake_prefix_path(spec.package) == [
|
||||
spec["define-cmake-prefix-paths"].prefix.test
|
||||
]
|
||||
|
||||
|
||||
def test_url_for_version_with_only_overrides(mock_packages, config):
|
||||
s = Spec("url-only-override").concretized()
|
||||
|
||||
|
@ -0,0 +1,20 @@
|
||||
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
|
||||
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
||||
#
|
||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||
|
||||
from spack.package import *
|
||||
|
||||
|
||||
class DefineCmakePrefixPaths(Package):
|
||||
"""Package that defines cmake_prefix_paths"""
|
||||
|
||||
homepage = "http://www.example.com"
|
||||
url = "http://www.example.com/definecmakeprefixpaths-1.0.tar.gz"
|
||||
|
||||
version("1.0", "0123456789abcdef0123456789abcdef")
|
||||
|
||||
@property
|
||||
def cmake_prefix_paths(self):
|
||||
paths = [self.prefix.test]
|
||||
return paths
|
@ -0,0 +1,17 @@
|
||||
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
|
||||
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
||||
#
|
||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||
|
||||
from spack.package import *
|
||||
|
||||
|
||||
class DependsOnDefineCmakePrefixPaths(Package):
|
||||
"""Package that defines cmake_prefix_paths"""
|
||||
|
||||
homepage = "http://www.example.com"
|
||||
url = "http://www.example.com/dependsonefinecmakeprefixpaths-1.0.tar.gz"
|
||||
|
||||
version("1.0", "0123456789abcdef0123456789abcdef")
|
||||
|
||||
depends_on("define-cmake-prefix-paths")
|
@ -465,6 +465,14 @@ def setup_build_environment(self, env):
|
||||
def setup_dependent_build_environment(self, env, dependent_spec):
|
||||
env.set("CUDAHOSTCXX", dependent_spec.package.compiler.cxx)
|
||||
|
||||
@property
|
||||
def cmake_prefix_paths(self):
|
||||
cmake_prefix_paths = [self.prefix]
|
||||
if self.spec.satisfies("target=x86_64:"):
|
||||
cub_path = self.prefix.targets + "/x86_64-linux/lib/cmake"
|
||||
cmake_prefix_paths.append(cub_path)
|
||||
return cmake_prefix_paths
|
||||
|
||||
def setup_run_environment(self, env):
|
||||
env.set("CUDA_HOME", self.prefix)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user