Honor cmake_prefix_paths
property if available (#42569)
* Honor package-specified cmake_prefix_paths at runtime * Add paths in the correct order and prune duplicates * Normalize paths for windows' sake
This commit is contained in:
parent
24abc3294a
commit
fe171a560b
@ -1234,6 +1234,10 @@ def _make_runnable(self, dep: spack.spec.Spec, env: EnvironmentModifications):
|
||||
if os.path.isdir(bin_dir):
|
||||
env.prepend_path("PATH", bin_dir)
|
||||
|
||||
for cp_dir in spack.build_systems.cmake.get_cmake_prefix_path(dep.package):
|
||||
env.append_path("CMAKE_PREFIX_PATH", cp_dir)
|
||||
env.prune_duplicate_paths("CMAKE_PREFIX_PATH")
|
||||
|
||||
|
||||
def _setup_pkg_and_run(
|
||||
serialized_pkg: "spack.subprocess_context.PackageInstallContext",
|
||||
|
@ -52,7 +52,8 @@ def test_load_shell(shell, set_command):
|
||||
mpileaks_spec = spack.concretize.concretize_one("mpileaks")
|
||||
|
||||
# Ensure our reference variable is clean.
|
||||
os.environ["CMAKE_PREFIX_PATH"] = "/hello" + os.pathsep + "/world"
|
||||
hello_world_paths = [os.path.normpath(p) for p in ("/hello", "/world")]
|
||||
os.environ["CMAKE_PREFIX_PATH"] = os.pathsep.join(hello_world_paths)
|
||||
|
||||
shell_out = load(shell, "mpileaks")
|
||||
|
||||
@ -69,7 +70,7 @@ def extract_value(output, variable):
|
||||
paths_shell = extract_value(shell_out, "CMAKE_PREFIX_PATH")
|
||||
|
||||
# We should've prepended new paths, and keep old ones.
|
||||
assert paths_shell[-2:] == ["/hello", "/world"]
|
||||
assert paths_shell[-2:] == hello_world_paths
|
||||
|
||||
# All but the last two paths are added by spack load; lookup what packages they're from.
|
||||
pkgs = [prefix_to_pkg(p) for p in paths_shell[:-2]]
|
||||
|
Loading…
Reference in New Issue
Block a user