2016-09-27 22:01:08 +03:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2002-12-21 19:14:47 +03:00
|
|
|
#include "cmGetTargetPropertyCommand.h"
|
|
|
|
|
|
|
|
// cmSetTargetPropertyCommand
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmGetTargetPropertyCommand::InitialPass(
|
|
|
|
std::vector<std::string> const& args, cmExecutionStatus&)
|
2002-12-21 19:14:47 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (args.size() != 3) {
|
2002-12-21 19:14:47 +03:00
|
|
|
this->SetError("called with incorrect number of arguments");
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-03-11 03:04:11 +04:00
|
|
|
std::string var = args[0];
|
2014-01-16 02:56:38 +04:00
|
|
|
const std::string& targetName = args[1];
|
2013-09-03 00:27:32 +04:00
|
|
|
std::string prop;
|
2015-01-08 23:20:38 +03:00
|
|
|
bool prop_exists = false;
|
2005-06-20 22:00:48 +04:00
|
|
|
|
2016-06-26 23:00:00 +03:00
|
|
|
if (cmTarget* tgt = this->Makefile->FindTargetToUse(targetName)) {
|
|
|
|
if (args[2] == "ALIASED_TARGET") {
|
|
|
|
if (this->Makefile->IsAlias(targetName)) {
|
|
|
|
prop = tgt->GetName();
|
|
|
|
prop_exists = true;
|
|
|
|
}
|
|
|
|
} else if (!args[2].empty()) {
|
|
|
|
const char* prop_cstr = tgt->GetProperty(args[2], this->Makefile);
|
|
|
|
if (prop_cstr) {
|
|
|
|
prop = prop_cstr;
|
2015-01-08 23:20:38 +03:00
|
|
|
prop_exists = true;
|
2002-12-21 19:14:47 +03:00
|
|
|
}
|
2013-07-12 11:14:31 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-01-08 16:16:33 +04:00
|
|
|
bool issueMessage = false;
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2014-01-08 16:16:33 +04:00
|
|
|
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0045)) {
|
2014-01-08 16:16:33 +04:00
|
|
|
case cmPolicies::WARN:
|
|
|
|
issueMessage = true;
|
2015-05-03 11:12:10 +03:00
|
|
|
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0045) << "\n";
|
2014-01-08 16:16:33 +04:00
|
|
|
case cmPolicies::OLD:
|
|
|
|
break;
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
issueMessage = true;
|
|
|
|
messageType = cmake::FATAL_ERROR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (issueMessage) {
|
2014-01-08 16:16:33 +04:00
|
|
|
e << "get_target_property() called with non-existent target \""
|
2016-05-16 17:34:04 +03:00
|
|
|
<< targetName << "\".";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->IssueMessage(messageType, e.str());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (messageType == cmake::FATAL_ERROR) {
|
2014-01-08 16:16:33 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (prop_exists) {
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->AddDefinition(var, prop.c_str());
|
2013-07-12 11:14:31 +04:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
this->Makefile->AddDefinition(var, (var + "-NOTFOUND").c_str());
|
2002-12-21 19:14:47 +03:00
|
|
|
return true;
|
|
|
|
}
|