summaryrefslogtreecommitdiffstats
path: root/Source/cmTarget.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-05-09 14:50:29 (GMT)
committerBrad King <brad.king@kitware.com>2014-05-09 15:12:48 (GMT)
commit23409f50f13a337333021b458a42273464100eae (patch)
tree66f0342306d147defd4cea0c307fc8b4e6e899b1 /Source/cmTarget.cxx
parent2e75bf672b0d8e58972f9445a0ef475d21dbe87f (diff)
downloadCMake-23409f50f13a337333021b458a42273464100eae.zip
CMake-23409f50f13a337333021b458a42273464100eae.tar.gz
CMake-23409f50f13a337333021b458a42273464100eae.tar.bz2
cmTarget: Evaluate CMP0026 in calling context
This policy should be checked at the call site that tries to access the LOCATION property, not the directory scope containing the target. Thread the caller context through cmTarget::GetProperty to use for checking the policy setting and emitting a diagnostic with proper backtrace. Extend the RunCMake.CMP0026 test with a cross-directory case.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r--Source/cmTarget.cxx21
1 files changed, 14 insertions, 7 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 9eb1f63..219560e 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -2624,7 +2624,7 @@ const char* cmTarget::GetFeature(const char* feature, const char* config) const
}
//----------------------------------------------------------------------------
-bool cmTarget::HandleLocationPropertyPolicy() const
+bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const
{
if (this->IsImported())
{
@@ -2633,7 +2633,7 @@ bool cmTarget::HandleLocationPropertyPolicy() const
cmOStringStream e;
const char *modal = 0;
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
- switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0026))
+ switch (context->GetPolicyStatus(cmPolicies::CMP0026))
{
case cmPolicies::WARN:
e << (this->Makefile->GetPolicies()
@@ -2654,7 +2654,7 @@ bool cmTarget::HandleLocationPropertyPolicy() const
<< this->GetName() << "\". Use the target name directly with "
"add_custom_command, or use the generator expression $<TARGET_FILE>, "
"as appropriate.\n";
- this->Makefile->IssueMessage(messageType, e.str().c_str());
+ context->IssueMessage(messageType, e.str().c_str());
}
return messageType != cmake::FATAL_ERROR;
@@ -2663,6 +2663,13 @@ bool cmTarget::HandleLocationPropertyPolicy() const
//----------------------------------------------------------------------------
const char *cmTarget::GetProperty(const char* prop) const
{
+ return this->GetProperty(prop, this->Makefile);
+}
+
+//----------------------------------------------------------------------------
+const char *cmTarget::GetProperty(const char* prop,
+ cmMakefile* context) const
+{
if(!prop)
{
return 0;
@@ -2674,7 +2681,7 @@ const char *cmTarget::GetProperty(const char* prop) const
cmOStringStream e;
e << "INTERFACE_LIBRARY targets may only have whitelisted properties. "
"The property \"" << prop << "\" is not allowed.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ context->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
return 0;
}
@@ -2693,7 +2700,7 @@ const char *cmTarget::GetProperty(const char* prop) const
{
if(strcmp(prop,"LOCATION") == 0)
{
- if (!this->HandleLocationPropertyPolicy())
+ if (!this->HandleLocationPropertyPolicy(context))
{
return 0;
}
@@ -2714,7 +2721,7 @@ const char *cmTarget::GetProperty(const char* prop) const
// Support "LOCATION_<CONFIG>".
if(cmHasLiteralPrefix(prop, "LOCATION_"))
{
- if (!this->HandleLocationPropertyPolicy())
+ if (!this->HandleLocationPropertyPolicy(context))
{
return 0;
}
@@ -2729,7 +2736,7 @@ const char *cmTarget::GetProperty(const char* prop) const
std::string configName(prop, strlen(prop) - 9);
if(configName != "IMPORTED")
{
- if (!this->HandleLocationPropertyPolicy())
+ if (!this->HandleLocationPropertyPolicy(context))
{
return 0;
}