summaryrefslogtreecommitdiff
path: root/Source/cmTargetLinkLibrariesCommand.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-11-05 19:15:53 +0100
committerStephen Kelly <steveire@gmail.com>2013-11-07 11:06:40 +0100
commit596b2a8c0820bed8195e2377927a18cf2d76727c (patch)
tree093b7a88d4d3b32dffce49dce5d57d27ceeaa1aa /Source/cmTargetLinkLibrariesCommand.cxx
parent301bb5cdda081f0bef0702e41ae4b47102b235df (diff)
downloadcmake-596b2a8c0820bed8195e2377927a18cf2d76727c.tar.gz
Disallow linking to utility targets (#13902).
Diffstat (limited to 'Source/cmTargetLinkLibrariesCommand.cxx')
-rw-r--r--Source/cmTargetLinkLibrariesCommand.cxx31
1 files changed, 31 insertions, 0 deletions
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index c28945954b..209609d20c 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -101,6 +101,37 @@ bool cmTargetLinkLibrariesCommand
return true;
}
+ if (this->Target->GetType() == cmTarget::UTILITY)
+ {
+ const char *modal = 0;
+ cmake::MessageType messageType = cmake::AUTHOR_WARNING;
+ switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0039))
+ {
+ case cmPolicies::WARN:
+ modal = "should";
+ case cmPolicies::OLD:
+ break;
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::NEW:
+ modal = "must";
+ messageType = cmake::FATAL_ERROR;
+ }
+ if (modal)
+ {
+ cmOStringStream e;
+ e << this->Makefile->GetPolicies()
+ ->GetPolicyWarning(cmPolicies::CMP0039) << "\n"
+ "Utility target \"" << this->Target->GetName() << "\" " << modal
+ << " not be used as the target of a target_link_libraries call.";
+ this->Makefile->IssueMessage(messageType, e.str().c_str());
+ if(messageType == cmake::FATAL_ERROR)
+ {
+ return false;
+ }
+ }
+ }
+
// but we might not have any libs after variable expansion
if(args.size() < 2)
{