MCPcopy Create free account
hub / github.com/Kitware/CMake / HandleRPathSetCommand

Function HandleRPathSetCommand

Source/cmFileCommand.cxx:1084–1137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1082}
1083
1084bool 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
1139bool HandleRPathRemoveCommand(std::vector<std::string> const& args,
1140 cmExecutionStatus& status)

Callers

nothing calls this directly

Calls 13

cmMakeRangeFunction · 0.85
MaybeReportErrorMethod · 0.80
DisplayStatusMethod · 0.80
cmStrCatFunction · 0.70
FileExistsFunction · 0.50
BindMethod · 0.45
ParseMethod · 0.45
advanceMethod · 0.45
emptyMethod · 0.45
SetErrorMethod · 0.45
frontMethod · 0.45
GetMakefileMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…