| 1017 | } |
| 1018 | |
| 1019 | bool HandleRPathChangeCommand(std::vector<std::string> const& args, |
| 1020 | cmExecutionStatus& status) |
| 1021 | { |
| 1022 | // Evaluate arguments. |
| 1023 | std::string file; |
| 1024 | cm::optional<std::string> oldRPath; |
| 1025 | cm::optional<std::string> newRPath; |
| 1026 | bool removeEnvironmentRPath = false; |
| 1027 | cmArgumentParser<void> parser; |
| 1028 | std::vector<std::string> unknownArgs; |
| 1029 | parser.Bind("FILE"_s, file) |
| 1030 | .Bind("OLD_RPATH"_s, oldRPath) |
| 1031 | .Bind("NEW_RPATH"_s, newRPath) |
| 1032 | .Bind("INSTALL_REMOVE_ENVIRONMENT_RPATH"_s, removeEnvironmentRPath); |
| 1033 | ArgumentParser::ParseResult parseResult = |
| 1034 | parser.Parse(cmMakeRange(args).advance(1), &unknownArgs); |
| 1035 | if (!unknownArgs.empty()) { |
| 1036 | status.SetError( |
| 1037 | cmStrCat("RPATH_CHANGE given unknown argument ", unknownArgs.front())); |
| 1038 | return false; |
| 1039 | } |
| 1040 | if (parseResult.MaybeReportError(status.GetMakefile())) { |
| 1041 | return true; |
| 1042 | } |
| 1043 | if (file.empty()) { |
| 1044 | status.SetError("RPATH_CHANGE not given FILE option."); |
| 1045 | return false; |
| 1046 | } |
| 1047 | if (!oldRPath) { |
| 1048 | status.SetError("RPATH_CHANGE not given OLD_RPATH option."); |
| 1049 | return false; |
| 1050 | } |
| 1051 | if (!newRPath) { |
| 1052 | status.SetError("RPATH_CHANGE not given NEW_RPATH option."); |
| 1053 | return false; |
| 1054 | } |
| 1055 | if (!cmSystemTools::FileExists(file, true)) { |
| 1056 | status.SetError( |
| 1057 | cmStrCat("RPATH_CHANGE given FILE \"", file, "\" that does not exist.")); |
| 1058 | return false; |
| 1059 | } |
| 1060 | bool success = true; |
| 1061 | cmFileTimes const ft(file); |
| 1062 | std::string emsg; |
| 1063 | bool changed; |
| 1064 | |
| 1065 | if (!cmSystemTools::ChangeRPath(file, *oldRPath, *newRPath, |
| 1066 | removeEnvironmentRPath, &emsg, &changed)) { |
| 1067 | status.SetError(cmStrCat("RPATH_CHANGE could not write new RPATH:\n ", |
| 1068 | *newRPath, "\nto the file:\n ", file, '\n', |
| 1069 | emsg)); |
| 1070 | success = false; |
| 1071 | } |
| 1072 | if (success) { |
| 1073 | if (changed) { |
| 1074 | std::string message = |
| 1075 | cmStrCat("Set non-toolchain portion of runtime path of \"", file, |
| 1076 | "\" to \"", *newRPath, '"'); |
nothing calls this directly
no test coverage detected
searching dependent graphs…