diff --git a/lib/spack/spack/build_systems/cached_cmake.py b/lib/spack/spack/build_systems/cached_cmake.py index d5121c847b5..5d14693817f 100644 --- a/lib/spack/spack/build_systems/cached_cmake.py +++ b/lib/spack/spack/build_systems/cached_cmake.py @@ -298,7 +298,14 @@ def initconfig_hardware_entries(self): def std_initconfig_entries(self): cmake_prefix_path_env = os.environ["CMAKE_PREFIX_PATH"] cmake_prefix_path = cmake_prefix_path_env.replace(os.pathsep, ";") - + complete_rpath_list = ";".join( + [ + self.pkg.spec.prefix.lib, + self.pkg.spec.prefix.lib64, + *os.environ.get("SPACK_COMPILER_EXTRA_RPATHS", "").split(":"), + *os.environ.get("SPACK_COMPILER_IMPLICIT_RPATHS", "").split(":"), + ] + ) return [ "#------------------{0}".format("-" * 60), "# !!!! This is a generated file, edit at own risk !!!!", @@ -307,6 +314,8 @@ def std_initconfig_entries(self): "#------------------{0}\n".format("-" * 60), cmake_cache_string("CMAKE_PREFIX_PATH", cmake_prefix_path), cmake_cache_string("CMAKE_INSTALL_RPATH_USE_LINK_PATH", "ON"), + cmake_cache_string("CMAKE_BUILD_RPATH", complete_rpath_list), + cmake_cache_string("CMAKE_INSTALL_RPATH", complete_rpath_list), self.define_cmake_cache_from_variant("CMAKE_BUILD_TYPE", "build_type"), ]