diff options
Diffstat (limited to 'Source/cmTargetLinkLibrariesCommand.cxx')
-rw-r--r-- | Source/cmTargetLinkLibrariesCommand.cxx | 31 |
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) { |