Commit 39ae0258 authored by Brad King's avatar Brad King
Browse files

Merge branch 'backport-target-property-policy-context' into release

parents 890efcb6 23409f50
......@@ -302,7 +302,8 @@ bool cmGetPropertyCommand::HandleTargetMode()
}
if(cmTarget* target = this->Makefile->FindTargetToUse(this->Name))
{
return this->StoreResult(target->GetProperty(this->PropertyName.c_str()));
return this->StoreResult(target->GetProperty(this->PropertyName.c_str(),
this->Makefile));
}
else
{
......
......@@ -38,7 +38,7 @@ bool cmGetTargetPropertyCommand
else if(cmTarget* tgt = this->Makefile->FindTargetToUse(targetName))
{
cmTarget& target = *tgt;
prop = target.GetProperty(args[2].c_str());
prop = target.GetProperty(args[2].c_str(), this->Makefile);
}
else
{
......
......@@ -2624,13 +2624,7 @@ const char* cmTarget::GetFeature(const char* feature, const char* config) const
}
//----------------------------------------------------------------------------
const char *cmTarget::GetProperty(const char* prop) const
{
return this->GetProperty(prop, cmProperty::TARGET);
}
//----------------------------------------------------------------------------
bool cmTarget::HandleLocationPropertyPolicy() const
bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const
{
if (this->IsImported())
{
......@@ -2639,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()
......@@ -2660,15 +2654,21 @@ 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;
}
//----------------------------------------------------------------------------
const char *cmTarget::GetProperty(const char* prop) const
{
return this->GetProperty(prop, this->Makefile);
}
//----------------------------------------------------------------------------
const char *cmTarget::GetProperty(const char* prop,
cmProperty::ScopeType scope) const
cmMakefile* context) const
{
if(!prop)
{
......@@ -2681,7 +2681,7 @@ const char *cmTarget::GetProperty(const char* prop,
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;
}
......@@ -2700,7 +2700,7 @@ const char *cmTarget::GetProperty(const char* prop,
{
if(strcmp(prop,"LOCATION") == 0)
{
if (!this->HandleLocationPropertyPolicy())
if (!this->HandleLocationPropertyPolicy(context))
{
return 0;
}
......@@ -2721,7 +2721,7 @@ const char *cmTarget::GetProperty(const char* prop,
// Support "LOCATION_<CONFIG>".
if(cmHasLiteralPrefix(prop, "LOCATION_"))
{
if (!this->HandleLocationPropertyPolicy())
if (!this->HandleLocationPropertyPolicy(context))
{
return 0;
}
......@@ -2736,7 +2736,7 @@ const char *cmTarget::GetProperty(const char* prop,
std::string configName(prop, strlen(prop) - 9);
if(configName != "IMPORTED")
{
if (!this->HandleLocationPropertyPolicy())
if (!this->HandleLocationPropertyPolicy(context))
{
return 0;
}
......@@ -2857,10 +2857,10 @@ const char *cmTarget::GetProperty(const char* prop,
}
bool chain = false;
const char *retVal =
this->Properties.GetPropertyValue(prop, scope, chain);
this->Properties.GetPropertyValue(prop, cmProperty::TARGET, chain);
if (chain)
{
return this->Makefile->GetProperty(prop,scope);
return this->Makefile->GetProperty(prop, cmProperty::TARGET);
}
return retVal;
}
......
......@@ -257,7 +257,7 @@ public:
void SetProperty(const char *prop, const char *value);
void AppendProperty(const char* prop, const char* value,bool asString=false);
const char *GetProperty(const char *prop) const;
const char *GetProperty(const char *prop, cmProperty::ScopeType scope) const;
const char *GetProperty(const char *prop, cmMakefile* context) const;
bool GetPropertyAsBool(const char *prop) const;
void CheckProperty(const char* prop, cmMakefile* context) const;
......@@ -580,7 +580,7 @@ public:
const std::string &compatibilityType) const;
private:
bool HandleLocationPropertyPolicy() const;
bool HandleLocationPropertyPolicy(cmMakefile* context) const;
// The set of include directories that are marked as system include
// directories.
......
......@@ -10,3 +10,16 @@ CMake Warning \(dev\) at CMP0026-WARN.cmake:5 \(get_target_property\):
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
+
CMake Warning \(dev\) at CMP0026-WARN.cmake:8 \(get_target_property\):
Policy CMP0026 is not set: Disallow use of the LOCATION target property.
Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
The LOCATION property should not be read from target "otherlib". Use the
target name directly with add_custom_command, or use the generator
expression \$<TARGET_FILE>, as appropriate.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
......@@ -3,3 +3,6 @@ enable_language(CXX)
add_library(somelib empty.cpp)
get_target_property(_loc somelib LOCATION)
add_subdirectory(CMP0026-WARN-Dir)
get_target_property(_loc otherlib LOCATION)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment