| 11 | #include "cmTarget.h" |
| 12 | |
| 13 | bool cmSetTargetPropertiesCommand(std::vector<std::string> const& args, |
| 14 | cmExecutionStatus& status) |
| 15 | { |
| 16 | if (args.size() < 2) { |
| 17 | status.SetError("called with incorrect number of arguments"); |
| 18 | return false; |
| 19 | } |
| 20 | |
| 21 | // first identify the properties arguments |
| 22 | auto propsIter = std::find(args.begin(), args.end(), "PROPERTIES"); |
| 23 | if (propsIter == args.end() || propsIter + 1 == args.end()) { |
| 24 | status.SetError("called with illegal arguments, maybe missing a " |
| 25 | "PROPERTIES specifier?"); |
| 26 | return false; |
| 27 | } |
| 28 | |
| 29 | if (std::distance(propsIter, args.end()) % 2 != 1) { |
| 30 | status.SetError("called with incorrect number of arguments."); |
| 31 | return false; |
| 32 | } |
| 33 | |
| 34 | cmMakefile& mf = status.GetMakefile(); |
| 35 | |
| 36 | // loop over all the targets |
| 37 | for (std::string const& tname : cmStringRange{ args.begin(), propsIter }) { |
| 38 | if (mf.IsAlias(tname)) { |
| 39 | status.SetError("can not be used on an ALIAS target."); |
| 40 | return false; |
| 41 | } |
| 42 | if (cmTarget* target = mf.FindTargetToUse(tname)) { |
| 43 | if (target->IsSymbolic()) { |
| 44 | status.SetError("can not be used on a SYMBOLIC target."); |
| 45 | return false; |
| 46 | } |
| 47 | // loop through all the props and set them |
| 48 | for (auto k = propsIter + 1; k != args.end(); k += 2) { |
| 49 | target->SetProperty(*k, *(k + 1)); |
| 50 | target->CheckProperty(*k, &mf); |
| 51 | } |
| 52 | } else { |
| 53 | status.SetError( |
| 54 | cmStrCat("Can not find target to add properties to: ", tname)); |
| 55 | return false; |
| 56 | } |
| 57 | } |
| 58 | return true; |
| 59 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…