summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-01-08 12:16:33 (GMT)
committerStephen Kelly <steveire@gmail.com>2014-01-08 15:41:34 (GMT)
commit73e93400e2efab2096618ff58a5ad68236cd04aa (patch)
treebc144c3cd832a7afa9aab8d598ca82f6ac77da9e /Source
parentab9f58f657a244d182ccd9a9361fae0a7c068f20 (diff)
downloadCMake-73e93400e2efab2096618ff58a5ad68236cd04aa.zip
CMake-73e93400e2efab2096618ff58a5ad68236cd04aa.tar.gz
CMake-73e93400e2efab2096618ff58a5ad68236cd04aa.tar.bz2
get_target_property: Error on non-existent target.
Introduce policy CMP0045 to control this behavior.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGetTargetPropertyCommand.cxx31
-rw-r--r--Source/cmPolicies.cxx5
-rw-r--r--Source/cmPolicies.h1
3 files changed, 36 insertions, 1 deletions
diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx
index 02f00a5..488cc28 100644
--- a/Source/cmGetTargetPropertyCommand.cxx
+++ b/Source/cmGetTargetPropertyCommand.cxx
@@ -40,7 +40,36 @@ bool cmGetTargetPropertyCommand
cmTarget& target = *tgt;
prop = target.GetProperty(args[2].c_str());
}
-
+ else
+ {
+ bool issueMessage = false;
+ cmOStringStream e;
+ cmake::MessageType messageType = cmake::AUTHOR_WARNING;
+ switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0045))
+ {
+ case cmPolicies::WARN:
+ issueMessage = true;
+ e << this->Makefile->GetPolicies()
+ ->GetPolicyWarning(cmPolicies::CMP0045) << "\n";
+ case cmPolicies::OLD:
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::NEW:
+ issueMessage = true;
+ messageType = cmake::FATAL_ERROR;
+ }
+ if (issueMessage)
+ {
+ e << "get_target_property() called with non-existent target \""
+ << targetName << "\".";
+ this->Makefile->IssueMessage(messageType, e.str().c_str());
+ if (messageType == cmake::FATAL_ERROR)
+ {
+ return false;
+ }
+ }
+ }
if (prop)
{
this->Makefile->AddDefinition(var.c_str(), prop);
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index c9dacaf..5a189f8 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -326,6 +326,11 @@ cmPolicies::cmPolicies()
CMP0044, "CMP0044",
"Case sensitive <LANG>_COMPILER_ID generator expressions.",
3,0,0,0, cmPolicies::WARN);
+
+ this->DefinePolicy(
+ CMP0045, "CMP0045",
+ "Error on non-existent target in get_target_property.",
+ 3,0,0,0, cmPolicies::WARN);
}
cmPolicies::~cmPolicies()
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 0d7327f..b1342bf 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -98,6 +98,7 @@ public:
CMP0042, ///< Enable MACOSX_RPATH by default
CMP0043, ///< Ignore COMPILE_DEFINITIONS_<Config> properties
CMP0044, ///< Case sensitive <LANG>_COMPILER_ID generator expressions
+ CMP0045, ///< Error on non-existent target in get_target_property
/** \brief Always the last entry.
*