diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2019-07-26 16:01:15 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-07-26 16:01:27 (GMT) |
commit | 618bd463ad853da9cd4594bc1ff08fb272a7450d (patch) | |
tree | a5b49ba0de0ce6d1de0663af9ee874cbed6aa4c9 /Source | |
parent | af3278af3612e9bc0599617767047eaeb186c998 (diff) | |
parent | bd2793b6e90c9c990a3cd4db260503e19e9a8ae0 (diff) | |
download | CMake-618bd463ad853da9cd4594bc1ff08fb272a7450d.zip CMake-618bd463ad853da9cd4594bc1ff08fb272a7450d.tar.gz CMake-618bd463ad853da9cd4594bc1ff08fb272a7450d.tar.bz2 |
Merge topic 'remove_compiler_rpath'
bd2793b6e9 Help: Add documentation for INSTALL_REMOVE_ENVIROMENT_RPATH
f08dcbffec Property: Add INSTALL_REMOVE_ENVIROMENT_RPATH property
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3544
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmFileCommand.cxx | 7 | ||||
-rw-r--r-- | Source/cmInstallTargetGenerator.cxx | 10 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 8 | ||||
-rw-r--r-- | Source/cmSystemTools.h | 1 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 1 |
5 files changed, 22 insertions, 5 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 1c40753..a8ee6a8 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -1071,6 +1071,7 @@ bool cmFileCommand::HandleRPathChangeCommand( std::string file; const char* oldRPath = nullptr; const char* newRPath = nullptr; + bool removeEnvironmentRPath = false; enum Doing { DoingNone, @@ -1086,6 +1087,8 @@ bool cmFileCommand::HandleRPathChangeCommand( doing = DoingNew; } else if (args[i] == "FILE") { doing = DoingFile; + } else if (args[i] == "INSTALL_REMOVE_ENVIRONMENT_RPATH") { + removeEnvironmentRPath = true; } else if (doing == DoingFile) { file = args[i]; doing = DoingNone; @@ -1124,7 +1127,9 @@ bool cmFileCommand::HandleRPathChangeCommand( cmFileTimes const ft(file); std::string emsg; bool changed; - if (!cmSystemTools::ChangeRPath(file, oldRPath, newRPath, &emsg, &changed)) { + + if (!cmSystemTools::ChangeRPath(file, oldRPath, newRPath, + removeEnvironmentRPath, &emsg, &changed)) { std::ostringstream e; /* clang-format off */ e << "RPATH_CHANGE could not write new RPATH:\n" diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index d891ad8..a61239e 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -767,12 +767,18 @@ void cmInstallTargetGenerator::AddChrpathPatchRule( this->IssueCMP0095Warning(newRpath); CM_FALLTHROUGH; case cmPolicies::OLD: - os << indent << " NEW_RPATH \"" << newRpath << "\")\n"; + os << indent << " NEW_RPATH \"" << newRpath << "\""; break; default: - os << indent << " NEW_RPATH " << escapedNewRpath << ")\n"; + os << indent << " NEW_RPATH " << escapedNewRpath; break; } + + if (this->Target->GetPropertyAsBool("INSTALL_REMOVE_ENVIRONMENT_RPATH")) { + os << "\n" << indent << " INSTALL_REMOVE_ENVIRONMENT_RPATH)\n"; + } else { + os << indent << ")\n"; + } } } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index e824757..3ba3640 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2367,7 +2367,8 @@ struct cmSystemToolsRPathInfo #if defined(CMAKE_USE_ELF_PARSER) bool cmSystemTools::ChangeRPath(std::string const& file, std::string const& oldRPath, - std::string const& newRPath, std::string* emsg, + std::string const& newRPath, + bool removeEnvironmentRPath, std::string* emsg, bool* changed) { if (changed) { @@ -2454,7 +2455,9 @@ bool cmSystemTools::ChangeRPath(std::string const& file, // Construct the new value which preserves the part of the path // not being changed. - rp[rp_count].Value = se[i]->Value.substr(0, prefix_len); + if (!removeEnvironmentRPath) { + rp[rp_count].Value = se[i]->Value.substr(0, prefix_len); + } rp[rp_count].Value += newRPath; rp[rp_count].Value += se[i]->Value.substr(pos + oldRPath.length()); @@ -2540,6 +2543,7 @@ bool cmSystemTools::ChangeRPath(std::string const& file, bool cmSystemTools::ChangeRPath(std::string const& /*file*/, std::string const& /*oldRPath*/, std::string const& /*newRPath*/, + bool /*removeEnvironmentRPath*/, std::string* /*emsg*/, bool* /*changed*/) { return false; diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 5ce6a48..1962389 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -493,6 +493,7 @@ public: /** Try to set the RPATH in an ELF binary. */ static bool ChangeRPath(std::string const& file, std::string const& oldRPath, std::string const& newRPath, + bool removeEnvironmentRPath, std::string* emsg = nullptr, bool* changed = nullptr); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b1a0127..beccfce 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -282,6 +282,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, initProp("BUILD_RPATH"); initProp("BUILD_RPATH_USE_ORIGIN"); initProp("INSTALL_NAME_DIR"); + initProp("INSTALL_REMOVE_ENVIRONMENT_RPATH"); initPropValue("INSTALL_RPATH", ""); initPropValue("INSTALL_RPATH_USE_LINK_PATH", "OFF"); initProp("INTERPROCEDURAL_OPTIMIZATION"); |