| 1082 | } |
| 1083 | |
| 1084 | bool HandleRPathSetCommand(std::vector<std::string> const& args, |
| 1085 | cmExecutionStatus& status) |
| 1086 | { |
| 1087 | // Evaluate arguments. |
| 1088 | std::string file; |
| 1089 | cm::optional<std::string> newRPath; |
| 1090 | cmArgumentParser<void> parser; |
| 1091 | std::vector<std::string> unknownArgs; |
| 1092 | parser.Bind("FILE"_s, file).Bind("NEW_RPATH"_s, newRPath); |
| 1093 | ArgumentParser::ParseResult parseResult = |
| 1094 | parser.Parse(cmMakeRange(args).advance(1), &unknownArgs); |
| 1095 | if (!unknownArgs.empty()) { |
| 1096 | status.SetError(cmStrCat("RPATH_SET given unrecognized argument \"", |
| 1097 | unknownArgs.front(), "\".")); |
| 1098 | return false; |
| 1099 | } |
| 1100 | if (parseResult.MaybeReportError(status.GetMakefile())) { |
| 1101 | return true; |
| 1102 | } |
| 1103 | if (file.empty()) { |
| 1104 | status.SetError("RPATH_SET not given FILE option."); |
| 1105 | return false; |
| 1106 | } |
| 1107 | if (!newRPath) { |
| 1108 | status.SetError("RPATH_SET not given NEW_RPATH option."); |
| 1109 | return false; |
| 1110 | } |
| 1111 | if (!cmSystemTools::FileExists(file, true)) { |
| 1112 | status.SetError( |
| 1113 | cmStrCat("RPATH_SET given FILE \"", file, "\" that does not exist.")); |
| 1114 | return false; |
| 1115 | } |
| 1116 | bool success = true; |
| 1117 | cmFileTimes const ft(file); |
| 1118 | std::string emsg; |
| 1119 | bool changed; |
| 1120 | |
| 1121 | if (!cmSystemTools::SetRPath(file, *newRPath, &emsg, &changed)) { |
| 1122 | status.SetError(cmStrCat("RPATH_SET could not write new RPATH:\n ", |
| 1123 | *newRPath, "\nto the file:\n ", file, '\n', |
| 1124 | emsg)); |
| 1125 | success = false; |
| 1126 | } |
| 1127 | if (success) { |
| 1128 | if (changed) { |
| 1129 | std::string message = |
| 1130 | cmStrCat("Set non-toolchain portion of runtime path of \"", file, |
| 1131 | "\" to \"", *newRPath, '"'); |
| 1132 | status.GetMakefile().DisplayStatus(message, -1); |
| 1133 | } |
| 1134 | ft.Store(file); |
| 1135 | } |
| 1136 | return success; |
| 1137 | } |
| 1138 | |
| 1139 | bool HandleRPathRemoveCommand(std::vector<std::string> const& args, |
| 1140 | cmExecutionStatus& status) |
nothing calls this directly
no test coverage detected
searching dependent graphs…