| 11 | #include "cmValue.h" |
| 12 | |
| 13 | bool cmGetTargetPropertyCommand(std::vector<std::string> const& args, |
| 14 | cmExecutionStatus& status) |
| 15 | { |
| 16 | if (args.size() != 3) { |
| 17 | status.SetError("called with incorrect number of arguments"); |
| 18 | return false; |
| 19 | } |
| 20 | std::string const& var = args[0]; |
| 21 | std::string const& targetName = args[1]; |
| 22 | std::string prop; |
| 23 | bool prop_exists = false; |
| 24 | cmMakefile& mf = status.GetMakefile(); |
| 25 | |
| 26 | if (cmTarget* tgt = mf.FindTargetToUse(targetName)) { |
| 27 | if (args[2] == "ALIASED_TARGET" || args[2] == "ALIAS_GLOBAL") { |
| 28 | if (mf.IsAlias(targetName)) { |
| 29 | prop_exists = true; |
| 30 | if (args[2] == "ALIASED_TARGET") { |
| 31 | |
| 32 | prop = tgt->GetName(); |
| 33 | } |
| 34 | if (args[2] == "ALIAS_GLOBAL") { |
| 35 | prop = |
| 36 | mf.GetGlobalGenerator()->IsAlias(targetName) ? "TRUE" : "FALSE"; |
| 37 | } |
| 38 | } |
| 39 | } else if (!args[2].empty()) { |
| 40 | cmValue prop_cstr = nullptr; |
| 41 | prop_cstr = tgt->GetComputedProperty(args[2], mf); |
| 42 | if (!prop_cstr) { |
| 43 | prop_cstr = tgt->GetProperty(args[2]); |
| 44 | } |
| 45 | if (prop_cstr) { |
| 46 | prop = *prop_cstr; |
| 47 | prop_exists = true; |
| 48 | } |
| 49 | } |
| 50 | } else { |
| 51 | mf.IssueMessage( |
| 52 | MessageType::FATAL_ERROR, |
| 53 | cmStrCat("get_target_property() called with non-existent target \"", |
| 54 | targetName, "\".")); |
| 55 | return false; |
| 56 | } |
| 57 | if (prop_exists) { |
| 58 | mf.AddDefinition(var, prop); |
| 59 | return true; |
| 60 | } |
| 61 | mf.AddDefinition(var, var + "-NOTFOUND"); |
| 62 | return true; |
| 63 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…