diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmPolicies.cxx | 5 | ||||
-rw-r--r-- | Source/cmPolicies.h | 1 | ||||
-rw-r--r-- | Source/cmTargetLinkLibrariesCommand.cxx | 31 |
3 files changed, 37 insertions, 0 deletions
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index af33d0b..3881c54 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -296,6 +296,11 @@ cmPolicies::cmPolicies() CMP0038, "CMP0038", "Targets may not link directly to themselves.", 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0039, "CMP0039", + "Utility targets may not have link dependencies", + 3,0,0,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 2ea9973..fc239d4 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -90,6 +90,7 @@ public: CMP0036, ///< Disallow command: build_name CMP0037, ///< Target names should match a validity pattern. CMP0038, ///< Targets may not link directly to themselves + CMP0039, ///< Utility targets may not have link dependencies /** \brief Always the last entry. * 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) { |