diff options
author | Stephen Kelly <steveire@gmail.com> | 2013-06-28 14:37:39 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2013-10-11 19:17:27 (GMT) |
commit | e4e5b28c27dc2e6f0073e11fb64c4ea62022a051 (patch) | |
tree | ba7aa13e6521fcf786811b9679b23269a11e5d36 /Source/cmTarget.cxx | |
parent | 7e4910fe47d667e059e42ac6395b0f4726f17064 (diff) | |
download | CMake-e4e5b28c27dc2e6f0073e11fb64c4ea62022a051.zip CMake-e4e5b28c27dc2e6f0073e11fb64c4ea62022a051.tar.gz CMake-e4e5b28c27dc2e6f0073e11fb64c4ea62022a051.tar.bz2 |
cmTarget: Deprecate the LOCATION target property with a policy.
The final location and name of a build-target is not determined
until generate-time. However, reading the LOCATION property from
a target is currently allowed at configure time. Apart from creating
possibly-erroneous results, this has an impact on the implementation
of cmake itself, and prevents some major cleanups from being made.
Disallow reading LOCATION from build-targets with a policy. Port some
existing uses of it in CMake itself to use the TARGET_FILE generator
expression.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r-- | Source/cmTarget.cxx | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1c04e4e..43d9ed1 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4130,6 +4130,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) { @@ -4154,6 +4191,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 @@ -4169,6 +4211,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())); } @@ -4181,6 +4227,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())); } } |