summaryrefslogtreecommitdiffstats
path: root/Source/cmTargetLinkLibrariesCommand.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-11-05 18:15:53 (GMT)
committerStephen Kelly <steveire@gmail.com>2013-11-07 10:06:40 (GMT)
commit596b2a8c0820bed8195e2377927a18cf2d76727c (patch)
tree093b7a88d4d3b32dffce49dce5d57d27ceeaa1aa /Source/cmTargetLinkLibrariesCommand.cxx
parent301bb5cdda081f0bef0702e41ae4b47102b235df (diff)
downloadCMake-596b2a8c0820bed8195e2377927a18cf2d76727c.zip
CMake-596b2a8c0820bed8195e2377927a18cf2d76727c.tar.gz
CMake-596b2a8c0820bed8195e2377927a18cf2d76727c.tar.bz2
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 c289459..209609d 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)
{