summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPeter Scheibel <scheibel1@llnl.gov>2022-09-08 16:23:04 -0700
committerGitHub <noreply@github.com>2022-09-08 16:23:04 -0700
commit02151ac649bcccf0661ef40a1516c9cf46543855 (patch)
tree0b296fa1335874232e98eeffc6eb9d234d031544 /lib
parente3f87035b64ab37a9f878bc6018edb25d8e5b1e6 (diff)
downloadspack-02151ac649bcccf0661ef40a1516c9cf46543855.tar.gz
spack-02151ac649bcccf0661ef40a1516c9cf46543855.tar.bz2
spack-02151ac649bcccf0661ef40a1516c9cf46543855.tar.xz
spack-02151ac649bcccf0661ef40a1516c9cf46543855.zip
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>
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/build_environment.py7
-rw-r--r--lib/spack/spack/package_base.py4
-rw-r--r--lib/spack/spack/test/packages.py8
3 files changed, 17 insertions, 2 deletions
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py
index c292fb89bb..c1aee2c749 100644
--- a/lib/spack/spack/build_environment.py
+++ b/lib/spack/spack/build_environment.py
@@ -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(
diff --git a/lib/spack/spack/package_base.py b/lib/spack/spack/package_base.py
index 401303e949..e8f7ccd92a 100644
--- a/lib/spack/spack/package_base.py
+++ b/lib/spack/spack/package_base.py
@@ -1740,6 +1740,10 @@ class PackageBase(six.with_metaclass(PackageMeta, PackageViewMixin, object)):
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.
diff --git a/lib/spack/spack/test/packages.py b/lib/spack/spack/test/packages.py
index c91d749b0a..07161ad83f 100644
--- a/lib/spack/spack/test/packages.py
+++ b/lib/spack/spack/test/packages.py
@@ -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()