Merge topic 'target-LOCATION-policy'

e4e5b28 cmTarget: Deprecate the LOCATION target property with a policy.
This commit is contained in:
Brad King
2013-10-15 09:33:05 -04:00
committed by CMake Topic Stage
20 changed files with 152 additions and 9 deletions

View File

@@ -637,6 +637,28 @@ cmPolicies::cmPolicies()
"The OLD behavior for this policy is to use compiler id \"Clang\". "
"The NEW behavior for this policy is to use compiler id \"AppleClang\".",
2,8,13,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0026, "CMP0026",
"Disallow use of the LOCATION target property.",
"CMake 2.8.12 and lower allowed reading the LOCATION target property to "
"determine the eventual location of build targets. This relies on the "
"assumption that all necessary information is available at "
"configure-time to determine the final location and filename of the "
"target. However, this property is not fully determined until later at "
"generate-time. At generate time, the $<TARGET_FILE> generator "
"expression can be used to determine the eventual LOCATION of a target "
"output."
"\n"
"Code which reads the LOCATION target property can be ported to use the "
"$<TARGET_FILE> generator expression together with the file(GENERATE) "
"subcommand to generate a file containing the target location."
"\n"
"The OLD behavior for this policy is to allow reading the LOCATION "
"property from build-targets. "
"The NEW behavior for this policy is to not to allow reading the "
"LOCATION property from build-targets.",
2,8,13,0, cmPolicies::WARN);
}
cmPolicies::~cmPolicies()

View File

@@ -76,6 +76,7 @@ public:
CMP0023, ///< Disallow mixing keyword and plain tll signatures
CMP0024, ///< Disallow including export() result.
CMP0025, ///< Compiler id for Apple Clang is now AppleClang
CMP0026, ///< Disallow use of the LOCATION target property.
/** \brief Always the last entry.
*

View File

@@ -4132,6 +4132,43 @@ const char *cmTarget::GetProperty(const char* prop)
return this->GetProperty(prop, cmProperty::TARGET);
}
//----------------------------------------------------------------------------
bool cmTarget::HandleLocationPropertyPolicy()
{
if (this->IsImported())
{
return true;
}
const char *modal = 0;
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0026))
{
case cmPolicies::WARN:
modal = "should";
case cmPolicies::OLD:
break;
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::NEW:
modal = "may";
messageType = cmake::FATAL_ERROR;
}
if (modal)
{
cmOStringStream e;
e << (this->Makefile->GetPolicies()
->GetPolicyWarning(cmPolicies::CMP0026)) << "\n";
e << "The LOCATION property " << modal << " not be read from target \""
<< 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());
}
return messageType != cmake::FATAL_ERROR;
}
//----------------------------------------------------------------------------
const char *cmTarget::GetProperty(const char* prop,
cmProperty::ScopeType scope)
@@ -4157,6 +4194,11 @@ const char *cmTarget::GetProperty(const char* prop,
{
if(strcmp(prop,"LOCATION") == 0)
{
if (!this->HandleLocationPropertyPolicy())
{
return 0;
}
// Set the LOCATION property of the target.
//
// For an imported target this is the location of an arbitrary
@@ -4172,6 +4214,10 @@ const char *cmTarget::GetProperty(const char* prop,
// Support "LOCATION_<CONFIG>".
if(strncmp(prop, "LOCATION_", 9) == 0)
{
if (!this->HandleLocationPropertyPolicy())
{
return 0;
}
std::string configName = prop+9;
this->SetProperty(prop, this->GetLocation(configName.c_str()));
}
@@ -4184,6 +4230,10 @@ const char *cmTarget::GetProperty(const char* prop,
std::string configName(prop, len-9);
if(configName != "IMPORTED")
{
if (!this->HandleLocationPropertyPolicy())
{
return 0;
}
this->SetProperty(prop, this->GetLocation(configName.c_str()));
}
}

View File

@@ -554,6 +554,8 @@ public:
{ return this->TargetTypeValue == STATIC_LIBRARY; }
private:
bool HandleLocationPropertyPolicy();
// The set of include directories that are marked as system include
// directories.
std::set<cmStdString> SystemIncludeDirectories;