Fix bug where cmake prefix path on the command line does not include transitive deps (#23965)
This commit is contained in:
parent
690558f927
commit
e8afc5db15
2 changed files with 20 additions and 18 deletions
|
@ -314,6 +314,9 @@ def _place_externals_last(spec_container):
|
||||||
they should be deprioritized for any search order (i.e. in PATH, or
|
they should be deprioritized for any search order (i.e. in PATH, or
|
||||||
for a set of -L entries in a compiler invocation).
|
for a set of -L entries in a compiler invocation).
|
||||||
"""
|
"""
|
||||||
|
# Establish an arbitrary but fixed ordering of specs so that resulting
|
||||||
|
# environment variable values are stable
|
||||||
|
spec_container = sorted(spec_container, key=lambda x: x.name)
|
||||||
first = list(x for x in spec_container if not x.external)
|
first = list(x for x in spec_container if not x.external)
|
||||||
second = list(x for x in spec_container if x.external)
|
second = list(x for x in spec_container if x.external)
|
||||||
return first + second
|
return first + second
|
||||||
|
@ -343,22 +346,17 @@ def set_build_environment_variables(pkg, env, dirty):
|
||||||
for build_dep in build_deps:
|
for build_dep in build_deps:
|
||||||
build_and_supporting_deps.update(build_dep.traverse(deptype='run'))
|
build_and_supporting_deps.update(build_dep.traverse(deptype='run'))
|
||||||
|
|
||||||
# Establish an arbitrary but fixed ordering of specs so that resulting
|
|
||||||
# environment variable values are stable
|
|
||||||
def _order(specs):
|
|
||||||
return sorted(specs, key=lambda x: x.name)
|
|
||||||
|
|
||||||
# External packages may be installed in a prefix which contains many other
|
# External packages may be installed in a prefix which contains many other
|
||||||
# package installs. To avoid having those installations override
|
# package installs. To avoid having those installations override
|
||||||
# Spack-installed packages, they are placed at the end of search paths.
|
# Spack-installed packages, they are placed at the end of search paths.
|
||||||
# System prefixes are removed entirely later on since they are already
|
# System prefixes are removed entirely later on since they are already
|
||||||
# searched.
|
# searched.
|
||||||
build_deps = _place_externals_last(_order(build_deps))
|
build_deps = _place_externals_last(build_deps)
|
||||||
link_deps = _place_externals_last(_order(link_deps))
|
link_deps = _place_externals_last(link_deps)
|
||||||
build_link_deps = _place_externals_last(_order(build_link_deps))
|
build_link_deps = _place_externals_last(build_link_deps)
|
||||||
rpath_deps = _place_externals_last(_order(rpath_deps))
|
rpath_deps = _place_externals_last(rpath_deps)
|
||||||
build_and_supporting_deps = _place_externals_last(
|
build_and_supporting_deps = _place_externals_last(
|
||||||
_order(build_and_supporting_deps))
|
build_and_supporting_deps)
|
||||||
|
|
||||||
link_dirs = []
|
link_dirs = []
|
||||||
include_dirs = []
|
include_dirs = []
|
||||||
|
@ -411,7 +409,7 @@ def _order(specs):
|
||||||
x.prefix for x in build_link_deps)
|
x.prefix for x in build_link_deps)
|
||||||
|
|
||||||
# Add dependencies to CMAKE_PREFIX_PATH
|
# Add dependencies to CMAKE_PREFIX_PATH
|
||||||
env.set_path('CMAKE_PREFIX_PATH', build_link_prefixes)
|
env.set_path('CMAKE_PREFIX_PATH', get_cmake_prefix_path(pkg))
|
||||||
|
|
||||||
# Set environment variables if specified for
|
# Set environment variables if specified for
|
||||||
# the given compiler
|
# the given compiler
|
||||||
|
@ -714,6 +712,15 @@ def get_rpaths(pkg):
|
||||||
return list(dedupe(filter_system_paths(rpaths)))
|
return list(dedupe(filter_system_paths(rpaths)))
|
||||||
|
|
||||||
|
|
||||||
|
def get_cmake_prefix_path(pkg):
|
||||||
|
build_deps = set(pkg.spec.dependencies(deptype=('build', 'test')))
|
||||||
|
link_deps = set(pkg.spec.traverse(root=False, deptype=('link')))
|
||||||
|
build_link_deps = build_deps | link_deps
|
||||||
|
build_link_deps = _place_externals_last(build_link_deps)
|
||||||
|
build_link_prefixes = filter_system_paths(x.prefix for x in build_link_deps)
|
||||||
|
return build_link_prefixes
|
||||||
|
|
||||||
|
|
||||||
def get_std_cmake_args(pkg):
|
def get_std_cmake_args(pkg):
|
||||||
"""List of standard arguments used if a package is a CMakePackage.
|
"""List of standard arguments used if a package is a CMakePackage.
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
import spack.build_environment
|
import spack.build_environment
|
||||||
from llnl.util.filesystem import working_dir
|
from llnl.util.filesystem import working_dir
|
||||||
from spack.util.environment import filter_system_paths
|
|
||||||
from spack.directives import depends_on, variant, conflicts
|
from spack.directives import depends_on, variant, conflicts
|
||||||
from spack.package import PackageBase, InstallError, run_after
|
from spack.package import PackageBase, InstallError, run_after
|
||||||
|
|
||||||
|
@ -185,13 +184,9 @@ def _std_args(pkg):
|
||||||
define('CMAKE_INSTALL_RPATH_USE_LINK_PATH', False),
|
define('CMAKE_INSTALL_RPATH_USE_LINK_PATH', False),
|
||||||
define('CMAKE_INSTALL_RPATH',
|
define('CMAKE_INSTALL_RPATH',
|
||||||
spack.build_environment.get_rpaths(pkg)),
|
spack.build_environment.get_rpaths(pkg)),
|
||||||
|
define('CMAKE_PREFIX_PATH',
|
||||||
|
spack.build_environment.get_cmake_prefix_path(pkg))
|
||||||
])
|
])
|
||||||
# CMake's find_package() looks in CMAKE_PREFIX_PATH first, help CMake
|
|
||||||
# to find immediate link dependencies in right places:
|
|
||||||
deps = [d.prefix for d in
|
|
||||||
pkg.spec.dependencies(deptype=('build', 'link'))]
|
|
||||||
deps = filter_system_paths(deps)
|
|
||||||
args.append(define('CMAKE_PREFIX_PATH', deps))
|
|
||||||
return args
|
return args
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Reference in a new issue