summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorTarget.cxx
diff options
context:
space:
mode:
authorJoseph Snyder <joe.snyder@kitware.com>2019-11-19 19:04:40 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2020-01-02 22:11:31 (GMT)
commitc621839bd9e17974c476e7332fc267ccaa351a8e (patch)
treeb043f29e1cfc20e44ddd6f0cc0328c09f30bd961 /Source/cmGeneratorTarget.cxx
parent10fea25139cc302ef0f0a41aa68b44cda72a4fd2 (diff)
downloadCMake-c621839bd9e17974c476e7332fc267ccaa351a8e.zip
CMake-c621839bd9e17974c476e7332fc267ccaa351a8e.tar.gz
CMake-c621839bd9e17974c476e7332fc267ccaa351a8e.tar.bz2
Add set_property option: DEPRECATION
Add a new property flag for a target which contains a message regarding deprecation status. Add a warning at "Generate" time if a linked target is marked as deprecated. Expand ExportImport test to ensure that new property is being set and passed correctly. Ensure that the message is shown during the "Generate" step run of the ExportImport test.
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r--Source/cmGeneratorTarget.cxx28
1 files changed, 28 insertions, 0 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 19d5b4d..927364d 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -6354,6 +6354,21 @@ std::string cmGeneratorTarget::CheckCMP0004(std::string const& item) const
return lib;
}
+bool cmGeneratorTarget::IsDeprecated() const
+{
+ const char* deprecation = this->GetProperty("DEPRECATION");
+ return deprecation && *deprecation;
+}
+
+std::string cmGeneratorTarget::GetDeprecation() const
+{
+ // find DEPRECATION property
+ if (const char* deprecation = this->GetProperty("DEPRECATION")) {
+ return deprecation;
+ }
+ return std::string();
+}
+
void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages,
const std::string& config) const
{
@@ -6624,6 +6639,19 @@ cmLinkItem cmGeneratorTarget::ResolveLinkItem(
return cmLinkItem(resolved.String, bt);
}
+ // Check deprecation, issue message with `bt` backtrace.
+ if (resolved.Target->IsDeprecated()) {
+ std::ostringstream w;
+ /* clang-format off */
+ w <<
+ "The library that is being linked to, " << resolved.Target->GetName() <<
+ ", is marked as being deprecated by the owner. The message provided by "
+ "the developer is: \n" << resolved.Target->GetDeprecation() << "\n";
+ /* clang-format on */
+ this->LocalGenerator->GetCMakeInstance()->IssueMessage(
+ MessageType::AUTHOR_WARNING, w.str(), bt);
+ }
+
// Skip targets that will not really be linked. This is probably a
// name conflict between an external library and an executable
// within the project.