summaryrefslogtreecommitdiffstats
path: root/Source/cmTargetLinkLibrariesCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2010-12-17 15:31:19 (GMT)
committerBrad King <brad.king@kitware.com>2010-12-17 15:31:19 (GMT)
commit9bcaff02ff066e9bdd69e3e1e3134aa65c53c121 (patch)
tree2f46b8a3e84e07b51b20c70065c8a1c26ad47fd5 /Source/cmTargetLinkLibrariesCommand.cxx
parent544d0c37742a068fa07b265380315a25af3ae9f3 (diff)
parent3d13502c986e43f070366d04891c8a3da05e2cb8 (diff)
downloadCMake-9bcaff02ff066e9bdd69e3e1e3134aa65c53c121.zip
CMake-9bcaff02ff066e9bdd69e3e1e3134aa65c53c121.tar.gz
CMake-9bcaff02ff066e9bdd69e3e1e3134aa65c53c121.tar.bz2
Merge branch 'cmake-guiRememberAdvancedCheckbox' into dev/strict-mode
Conflicts: Source/QtDialog/CMakeSetupDialog.cxx
Diffstat (limited to 'Source/cmTargetLinkLibrariesCommand.cxx')
-rw-r--r--Source/cmTargetLinkLibrariesCommand.cxx63
1 files changed, 52 insertions, 11 deletions
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index f1f76c8..805959d 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -29,23 +29,64 @@ bool cmTargetLinkLibrariesCommand
return false;
}
- // but we might not have any libs after variable expansion
- if(args.size() < 2)
- {
- return true;
- }
-
// Lookup the target for which libraries are specified.
this->Target =
this->Makefile->GetCMakeInstance()
->GetGlobalGenerator()->FindTarget(0, args[0].c_str());
if(!this->Target)
{
+ cmake::MessageType t = cmake::FATAL_ERROR; // fail by default
cmOStringStream e;
e << "Cannot specify link libraries for target \"" << args[0] << "\" "
<< "which is not built by this project.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
- cmSystemTools::SetFatalErrorOccured();
+ // The bad target is the only argument. Check how policy CMP0016 is set,
+ // and accept, warn or fail respectively:
+ if (args.size() < 2)
+ {
+ switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0016))
+ {
+ case cmPolicies::WARN:
+ t = cmake::AUTHOR_WARNING;
+ // Print the warning.
+ e << "\n"
+ << "CMake does not support this but it used to work accidentally "
+ << "and is being allowed for compatibility."
+ << "\n" << this->Makefile->GetPolicies()->
+ GetPolicyWarning(cmPolicies::CMP0016);
+ break;
+ case cmPolicies::OLD: // OLD behavior does not warn.
+ t = cmake::MESSAGE;
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ e << "\n" << this->Makefile->GetPolicies()->
+ GetRequiredPolicyError(cmPolicies::CMP0016);
+ break;
+ case cmPolicies::NEW: // NEW behavior prints the error.
+ default:
+ break;
+ }
+ }
+
+ // now actually print the message
+ switch(t)
+ {
+ case cmake::AUTHOR_WARNING:
+ this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, e.str());
+ break;
+ case cmake::FATAL_ERROR:
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ cmSystemTools::SetFatalErrorOccured();
+ break;
+ default:
+ break;
+ }
+ return true;
+ }
+
+ // but we might not have any libs after variable expansion
+ if(args.size() < 2)
+ {
return true;
}
@@ -57,7 +98,7 @@ bool cmTargetLinkLibrariesCommand
// specification when the keyword is encountered.
this->DoingInterface = false;
- // add libraries, nothe that there is an optional prefix
+ // add libraries, nothe that there is an optional prefix
// of debug and optimized than can be used
for(unsigned int i=1; i < args.size(); ++i)
{
@@ -118,7 +159,7 @@ bool cmTargetLinkLibrariesCommand
llt = cmTarget::GENERAL;
std::string linkType = args[0];
linkType += "_LINK_TYPE";
- const char* linkTypeString =
+ const char* linkTypeString =
this->Makefile->GetDefinition( linkType.c_str() );
if(linkTypeString)
{
@@ -133,7 +174,7 @@ bool cmTargetLinkLibrariesCommand
}
this->HandleLibrary(args[i].c_str(), llt);
}
- }
+ }
// Make sure the last argument was not a library type specifier.
if(haveLLT)