diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 6b496a0290..7f41fcff9a 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -2294,7 +2294,11 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the toolchains' runtime libraries. // This is done even when skipping RPATH entries modeled by CMake. - { + // However, INSTALL_REMOVE_ENVIRONMENT_RPATH tells us to exclude + // toolchain-defined RPATH entries from installation. + bool const removeEnvironmentRPath = for_install && + this->Target->GetPropertyAsBool("INSTALL_REMOVE_ENVIRONMENT_RPATH"); + if (!removeEnvironmentRPath) { cmGeneratorTarget::LinkClosure const* lc = this->Target->GetLinkClosure(this->Config); for (std::string const& li : lc->Languages) {