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

Function cmGetTargetPropertyCommand

Source/cmGetTargetPropertyCommand.cxx:13–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11#include "cmValue.h"
12
13bool 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}

Callers

nothing calls this directly

Calls 13

FindTargetToUseMethod · 0.80
GetComputedPropertyMethod · 0.80
cmStrCatFunction · 0.70
sizeMethod · 0.45
SetErrorMethod · 0.45
GetMakefileMethod · 0.45
IsAliasMethod · 0.45
GetNameMethod · 0.45
GetGlobalGeneratorMethod · 0.45
emptyMethod · 0.45
GetPropertyMethod · 0.45
IssueMessageMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…