summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-10-15 13:33:05 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2013-10-15 13:33:05 (GMT)
commitb31ca93ba2665c353ba723fecff55eaedf5fb569 (patch)
tree8c9bd5adbc725329f658707078cddfe959d73dea /Source
parent21ccad58fd5abae66b67baba200e2b6cb2402e91 (diff)
parente4e5b28c27dc2e6f0073e11fb64c4ea62022a051 (diff)
downloadCMake-b31ca93ba2665c353ba723fecff55eaedf5fb569.zip
CMake-b31ca93ba2665c353ba723fecff55eaedf5fb569.tar.gz
CMake-b31ca93ba2665c353ba723fecff55eaedf5fb569.tar.bz2
Merge topic 'target-LOCATION-policy'
e4e5b28 cmTarget: Deprecate the LOCATION target property with a policy.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmPolicies.cxx22
-rw-r--r--Source/cmPolicies.h1
-rw-r--r--Source/cmTarget.cxx50
-rw-r--r--Source/cmTarget.h2
4 files changed, 75 insertions, 0 deletions
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index 1d3469f..d07645c 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -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()
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index ec8959d..e33171b 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -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.
*
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index a1d9889..d03ed49 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -4133,6 +4133,43 @@ const char *cmTarget::GetProperty(const char* prop)
}
//----------------------------------------------------------------------------
+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()));
}
}
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index a88c5ec..3c36da7 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -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;