diff options
author | Brad King <brad.king@kitware.com> | 2021-12-01 17:36:07 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-12-01 17:58:11 (GMT) |
commit | 643fc46bdc13dd57584d5d77eee30a99308ba896 (patch) | |
tree | 184ab10c031666afa8249a64662b8fa699b72ffe /Source/cmSystemTools.cxx | |
parent | 5596cba7dcb06b0641d4a5499fc046cf0959464e (diff) | |
download | CMake-643fc46bdc13dd57584d5d77eee30a99308ba896.zip CMake-643fc46bdc13dd57584d5d77eee30a99308ba896.tar.gz CMake-643fc46bdc13dd57584d5d77eee30a99308ba896.tar.bz2 |
file(RPATH): Restore tolerance of unknown formats if new RPATH is empty
Since commit 2e1149874d (cmSystemTools: Support multiple binary formats,
2021-06-14, v3.22.0-rc1~575^2) the `file(RPATH_...)` operations fail on
files that are not ELF or XCOFF format. Previously the RPATH operations
tolerated files of unknown format if the goal was to produce a file with
an empty RPATH. Restore this tolerance in order to support setting an
empty RPATH on GNU ld scripts.
Fixes: #22963
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 6320be8..1934393 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2869,6 +2869,14 @@ bool cmSystemTools::ChangeRPath(std::string const& file, file, oldRPath, newRPath, removeEnvironmentRPath, emsg, changed)) { return result.value(); } + // The file format is not recognized. Assume it has no RPATH. + if (newRPath.empty()) { + // The caller wanted no RPATH anyway. + return true; + } + if (emsg) { + *emsg = "The file format is not recognized."; + } return false; } @@ -2883,6 +2891,14 @@ bool cmSystemTools::SetRPath(std::string const& file, SetRPathXCOFF(file, newRPath, emsg, changed)) { return result.value(); } + // The file format is not recognized. Assume it has no RPATH. + if (newRPath.empty()) { + // The caller wanted no RPATH anyway. + return true; + } + if (emsg) { + *emsg = "The file format is not recognized."; + } return false; } @@ -3212,7 +3228,8 @@ bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg, if (cm::optional<bool> result = RemoveRPathXCOFF(file, emsg, removed)) { return result.value(); } - return false; + // The file format is not recognized. Assume it has no RPATH. + return true; } bool cmSystemTools::CheckRPath(std::string const& file, @@ -3252,7 +3269,9 @@ bool cmSystemTools::CheckRPath(std::string const& file, return false; } #endif - return false; + // The file format is not recognized. Assume it has no RPATH. + // Therefore we succeed if the new rpath is empty anyway. + return newRPath.empty(); } bool cmSystemTools::RepeatedRemoveDirectory(const std::string& dir) |