2016-09-27 19:01:08 +00:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2001-04-30 14:44:00 +00:00
|
|
|
#include "cmTargetLinkLibrariesCommand.h"
|
|
|
|
|
2013-02-06 12:32:15 +00:00
|
|
|
#include "cmGeneratorExpression.h"
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
const char* cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[3] = {
|
|
|
|
"general", "debug", "optimized"
|
2008-08-07 21:51:29 +00:00
|
|
|
};
|
|
|
|
|
2001-04-30 14:44:00 +00:00
|
|
|
// cmTargetLinkLibrariesCommand
|
2016-05-16 14:34:04 +00:00
|
|
|
bool cmTargetLinkLibrariesCommand::InitialPass(
|
|
|
|
std::vector<std::string> const& args, cmExecutionStatus&)
|
2001-04-30 14:44:00 +00:00
|
|
|
{
|
2002-07-19 18:40:49 +00:00
|
|
|
// must have one argument
|
2016-09-15 21:59:29 +00:00
|
|
|
if (args.empty()) {
|
2001-04-30 14:44:00 +00:00
|
|
|
this->SetError("called with incorrect number of arguments");
|
|
|
|
return false;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2003-08-07 20:09:19 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (this->Makefile->IsAlias(args[0])) {
|
2013-07-12 07:14:31 +00:00
|
|
|
this->SetError("can not be used on an ALIAS target.");
|
|
|
|
return false;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2008-08-11 20:23:02 +00:00
|
|
|
// Lookup the target for which libraries are specified.
|
|
|
|
this->Target =
|
2016-05-16 14:34:04 +00:00
|
|
|
this->Makefile->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(
|
|
|
|
args[0]);
|
|
|
|
if (!this->Target) {
|
|
|
|
cmake::MessageType t = cmake::FATAL_ERROR; // fail by default
|
2015-01-05 19:31:31 +00:00
|
|
|
std::ostringstream e;
|
2008-08-11 20:23:02 +00:00
|
|
|
e << "Cannot specify link libraries for target \"" << args[0] << "\" "
|
|
|
|
<< "which is not built by this project.";
|
2010-08-28 14:06:45 +00:00
|
|
|
// The bad target is the only argument. Check how policy CMP0016 is set,
|
|
|
|
// and accept, warn or fail respectively:
|
2016-05-16 14:34:04 +00:00
|
|
|
if (args.size() < 2) {
|
|
|
|
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0016)) {
|
2010-08-28 14:06:45 +00:00
|
|
|
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."
|
2016-05-16 14:34:04 +00:00
|
|
|
<< "\n"
|
|
|
|
<< cmPolicies::GetPolicyWarning(cmPolicies::CMP0016);
|
|
|
|
break;
|
|
|
|
case cmPolicies::OLD: // OLD behavior does not warn.
|
2010-08-28 14:06:45 +00:00
|
|
|
t = cmake::MESSAGE;
|
|
|
|
break;
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
2015-05-03 08:12:10 +00:00
|
|
|
e << "\n" << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0016);
|
2010-08-28 14:06:45 +00:00
|
|
|
break;
|
2016-05-16 14:34:04 +00:00
|
|
|
case cmPolicies::NEW: // NEW behavior prints the error.
|
2010-08-28 14:06:45 +00:00
|
|
|
break;
|
2010-08-26 19:54:43 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2010-08-28 14:06:45 +00:00
|
|
|
|
|
|
|
// now actually print the message
|
2016-05-16 14:34:04 +00:00
|
|
|
switch (t) {
|
2010-08-28 14:06:45 +00:00
|
|
|
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;
|
2008-08-11 20:23:02 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
return true;
|
|
|
|
}
|
2008-08-11 20:23:02 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (this->Target->GetType() == cmState::OBJECT_LIBRARY) {
|
2015-01-05 19:31:31 +00:00
|
|
|
std::ostringstream e;
|
2012-03-12 14:47:40 +00:00
|
|
|
e << "Object library target \"" << args[0] << "\" "
|
|
|
|
<< "may not link to anything.";
|
|
|
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
|
|
cmSystemTools::SetFatalErrorOccured();
|
|
|
|
return true;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2012-03-12 14:47:40 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (this->Target->GetType() == cmState::UTILITY) {
|
2015-01-05 19:31:31 +00:00
|
|
|
std::ostringstream e;
|
2016-06-27 20:44:16 +00:00
|
|
|
const char* modal = CM_NULLPTR;
|
2013-11-05 18:15:53 +00:00
|
|
|
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
|
2016-05-16 14:34:04 +00:00
|
|
|
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0039)) {
|
2013-11-05 18:15:53 +00:00
|
|
|
case cmPolicies::WARN:
|
2015-05-03 08:12:10 +00:00
|
|
|
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0039) << "\n";
|
2013-11-05 18:15:53 +00:00
|
|
|
modal = "should";
|
|
|
|
case cmPolicies::OLD:
|
|
|
|
break;
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
modal = "must";
|
|
|
|
messageType = cmake::FATAL_ERROR;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (modal) {
|
|
|
|
e << "Utility target \"" << this->Target->GetName() << "\" " << modal
|
2013-11-05 18:15:53 +00:00
|
|
|
<< " not be used as the target of a target_link_libraries call.";
|
2014-03-10 23:04:11 +00:00
|
|
|
this->Makefile->IssueMessage(messageType, e.str());
|
2016-05-16 14:34:04 +00:00
|
|
|
if (messageType == cmake::FATAL_ERROR) {
|
2013-11-05 18:15:53 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2013-11-05 18:15:53 +00:00
|
|
|
|
2010-08-26 19:02:40 +00:00
|
|
|
// but we might not have any libs after variable expansion
|
2016-05-16 14:34:04 +00:00
|
|
|
if (args.size() < 2) {
|
2010-08-26 19:02:40 +00:00
|
|
|
return true;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2010-08-26 19:02:40 +00:00
|
|
|
|
2008-08-07 21:51:29 +00:00
|
|
|
// Keep track of link configuration specifiers.
|
2015-10-10 11:56:36 +00:00
|
|
|
cmTargetLinkLibraryType llt = GENERAL_LibraryType;
|
2008-08-07 21:51:29 +00:00
|
|
|
bool haveLLT = false;
|
|
|
|
|
2008-08-11 20:23:02 +00:00
|
|
|
// Start with primary linking and switch to link interface
|
2011-10-07 00:41:37 +00:00
|
|
|
// specification if the keyword is encountered as the first argument.
|
|
|
|
this->CurrentProcessingState = ProcessingLinkLibraries;
|
2008-08-11 20:23:02 +00:00
|
|
|
|
2012-09-23 13:02:29 +00:00
|
|
|
// add libraries, note that there is an optional prefix
|
|
|
|
// of debug and optimized that can be used
|
2016-05-16 14:34:04 +00:00
|
|
|
for (unsigned int i = 1; i < args.size(); ++i) {
|
|
|
|
if (args[i] == "LINK_INTERFACE_LIBRARIES") {
|
2013-06-04 14:21:33 +00:00
|
|
|
this->CurrentProcessingState = ProcessingPlainLinkInterface;
|
2016-05-16 14:34:04 +00:00
|
|
|
if (i != 1) {
|
2008-08-18 14:11:29 +00:00
|
|
|
this->Makefile->IssueMessage(
|
|
|
|
cmake::FATAL_ERROR,
|
|
|
|
"The LINK_INTERFACE_LIBRARIES option must appear as the second "
|
2016-05-16 14:34:04 +00:00
|
|
|
"argument, just after the target name.");
|
2008-08-18 14:11:29 +00:00
|
|
|
return true;
|
2008-08-11 20:23:02 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (args[i] == "INTERFACE") {
|
|
|
|
if (i != 1 &&
|
|
|
|
this->CurrentProcessingState != ProcessingKeywordPrivateInterface &&
|
|
|
|
this->CurrentProcessingState != ProcessingKeywordPublicInterface &&
|
|
|
|
this->CurrentProcessingState != ProcessingKeywordLinkInterface) {
|
2013-06-04 14:21:33 +00:00
|
|
|
this->Makefile->IssueMessage(
|
2016-05-16 14:34:04 +00:00
|
|
|
cmake::FATAL_ERROR, "The INTERFACE option must appear as the second "
|
|
|
|
"argument, just after the target name.");
|
2013-06-04 14:21:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CurrentProcessingState = ProcessingKeywordLinkInterface;
|
|
|
|
} else if (args[i] == "LINK_PUBLIC") {
|
|
|
|
if (i != 1 &&
|
|
|
|
this->CurrentProcessingState != ProcessingPlainPrivateInterface &&
|
|
|
|
this->CurrentProcessingState != ProcessingPlainPublicInterface) {
|
2011-10-07 00:41:37 +00:00
|
|
|
this->Makefile->IssueMessage(
|
|
|
|
cmake::FATAL_ERROR,
|
|
|
|
"The LINK_PUBLIC or LINK_PRIVATE option must appear as the second "
|
2016-05-16 14:34:04 +00:00
|
|
|
"argument, just after the target name.");
|
2011-10-07 00:41:37 +00:00
|
|
|
return true;
|
2013-06-04 14:21:33 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CurrentProcessingState = ProcessingPlainPublicInterface;
|
|
|
|
} else if (args[i] == "PUBLIC") {
|
|
|
|
if (i != 1 &&
|
|
|
|
this->CurrentProcessingState != ProcessingKeywordPrivateInterface &&
|
|
|
|
this->CurrentProcessingState != ProcessingKeywordPublicInterface &&
|
|
|
|
this->CurrentProcessingState != ProcessingKeywordLinkInterface) {
|
2013-06-04 14:21:33 +00:00
|
|
|
this->Makefile->IssueMessage(
|
|
|
|
cmake::FATAL_ERROR,
|
|
|
|
"The PUBLIC or PRIVATE option must appear as the second "
|
2016-05-16 14:34:04 +00:00
|
|
|
"argument, just after the target name.");
|
2013-06-04 14:21:33 +00:00
|
|
|
return true;
|
2011-10-07 00:41:37 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CurrentProcessingState = ProcessingKeywordPublicInterface;
|
|
|
|
} else if (args[i] == "LINK_PRIVATE") {
|
|
|
|
if (i != 1 &&
|
|
|
|
this->CurrentProcessingState != ProcessingPlainPublicInterface &&
|
|
|
|
this->CurrentProcessingState != ProcessingPlainPrivateInterface) {
|
2011-10-07 00:41:37 +00:00
|
|
|
this->Makefile->IssueMessage(
|
|
|
|
cmake::FATAL_ERROR,
|
|
|
|
"The LINK_PUBLIC or LINK_PRIVATE option must appear as the second "
|
2016-05-16 14:34:04 +00:00
|
|
|
"argument, just after the target name.");
|
2011-10-07 00:41:37 +00:00
|
|
|
return true;
|
2013-06-04 14:21:33 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CurrentProcessingState = ProcessingPlainPrivateInterface;
|
|
|
|
} else if (args[i] == "PRIVATE") {
|
|
|
|
if (i != 1 &&
|
|
|
|
this->CurrentProcessingState != ProcessingKeywordPrivateInterface &&
|
|
|
|
this->CurrentProcessingState != ProcessingKeywordPublicInterface &&
|
|
|
|
this->CurrentProcessingState != ProcessingKeywordLinkInterface) {
|
2013-06-04 14:21:33 +00:00
|
|
|
this->Makefile->IssueMessage(
|
|
|
|
cmake::FATAL_ERROR,
|
|
|
|
"The PUBLIC or PRIVATE option must appear as the second "
|
2016-05-16 14:34:04 +00:00
|
|
|
"argument, just after the target name.");
|
2013-06-04 14:21:33 +00:00
|
|
|
return true;
|
2011-10-07 00:41:37 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
this->CurrentProcessingState = ProcessingKeywordPrivateInterface;
|
|
|
|
} else if (args[i] == "debug") {
|
|
|
|
if (haveLLT) {
|
2015-10-10 11:56:36 +00:00
|
|
|
this->LinkLibraryTypeSpecifierWarning(llt, DEBUG_LibraryType);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-10-10 11:56:36 +00:00
|
|
|
llt = DEBUG_LibraryType;
|
2008-08-07 21:51:29 +00:00
|
|
|
haveLLT = true;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (args[i] == "optimized") {
|
|
|
|
if (haveLLT) {
|
2015-10-10 11:56:36 +00:00
|
|
|
this->LinkLibraryTypeSpecifierWarning(llt, OPTIMIZED_LibraryType);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-10-10 11:56:36 +00:00
|
|
|
llt = OPTIMIZED_LibraryType;
|
2008-08-07 21:51:29 +00:00
|
|
|
haveLLT = true;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (args[i] == "general") {
|
|
|
|
if (haveLLT) {
|
2015-10-10 11:56:36 +00:00
|
|
|
this->LinkLibraryTypeSpecifierWarning(llt, GENERAL_LibraryType);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-10-10 11:56:36 +00:00
|
|
|
llt = GENERAL_LibraryType;
|
2008-08-07 21:51:29 +00:00
|
|
|
haveLLT = true;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (haveLLT) {
|
2008-08-07 21:51:29 +00:00
|
|
|
// The link type was specified by the previous argument.
|
|
|
|
haveLLT = false;
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!this->HandleLibrary(args[i], llt)) {
|
2013-06-04 14:21:33 +00:00
|
|
|
return false;
|
2006-11-29 16:00:17 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
} else {
|
2008-08-07 21:51:29 +00:00
|
|
|
// Lookup old-style cache entry if type is unspecified. So if you
|
2006-11-29 16:00:17 +00:00
|
|
|
// do a target_link_libraries(foo optimized bar) it will stay optimized
|
|
|
|
// and not use the lookup. As there maybe the case where someone has
|
|
|
|
// specifed that a library is both debug and optimized. (this check is
|
|
|
|
// only there for backwards compatibility when mixing projects built
|
|
|
|
// with old versions of CMake and new)
|
2015-10-10 11:56:36 +00:00
|
|
|
llt = GENERAL_LibraryType;
|
2006-11-29 16:00:17 +00:00
|
|
|
std::string linkType = args[0];
|
|
|
|
linkType += "_LINK_TYPE";
|
2016-05-16 14:34:04 +00:00
|
|
|
const char* linkTypeString = this->Makefile->GetDefinition(linkType);
|
|
|
|
if (linkTypeString) {
|
|
|
|
if (strcmp(linkTypeString, "debug") == 0) {
|
2015-10-10 11:56:36 +00:00
|
|
|
llt = DEBUG_LibraryType;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (strcmp(linkTypeString, "optimized") == 0) {
|
2015-10-10 11:56:36 +00:00
|
|
|
llt = OPTIMIZED_LibraryType;
|
2006-11-29 16:00:17 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (!this->HandleLibrary(args[i], llt)) {
|
2013-06-04 14:21:33 +00:00
|
|
|
return false;
|
2001-04-30 14:44:00 +00:00
|
|
|
}
|
2010-08-26 19:01:58 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2008-08-07 21:51:29 +00:00
|
|
|
|
|
|
|
// Make sure the last argument was not a library type specifier.
|
2016-05-16 14:34:04 +00:00
|
|
|
if (haveLLT) {
|
2015-01-05 19:31:31 +00:00
|
|
|
std::ostringstream e;
|
2008-08-07 21:51:29 +00:00
|
|
|
e << "The \"" << this->LinkLibraryTypeNames[llt]
|
|
|
|
<< "\" argument must be followed by a library.";
|
|
|
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
|
|
cmSystemTools::SetFatalErrorOccured();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2008-08-07 21:51:29 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
const cmPolicies::PolicyStatus policy22Status =
|
|
|
|
this->Target->GetPolicyStatusCMP0022();
|
2013-06-04 14:21:33 +00:00
|
|
|
|
2011-10-07 00:41:37 +00:00
|
|
|
// If any of the LINK_ options were given, make sure the
|
|
|
|
// LINK_INTERFACE_LIBRARIES target property exists.
|
|
|
|
// Use of any of the new keywords implies awareness of
|
|
|
|
// this property. And if no libraries are named, it should
|
|
|
|
// result in an empty link interface.
|
2016-05-16 14:34:04 +00:00
|
|
|
if ((policy22Status == cmPolicies::OLD ||
|
|
|
|
policy22Status == cmPolicies::WARN) &&
|
2013-06-04 14:21:33 +00:00
|
|
|
this->CurrentProcessingState != ProcessingLinkLibraries &&
|
2016-05-16 14:34:04 +00:00
|
|
|
!this->Target->GetProperty("LINK_INTERFACE_LIBRARIES")) {
|
2008-08-11 20:23:02 +00:00
|
|
|
this->Target->SetProperty("LINK_INTERFACE_LIBRARIES", "");
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2008-08-11 20:23:02 +00:00
|
|
|
|
2001-04-30 14:44:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
2008-08-07 21:51:29 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
void cmTargetLinkLibrariesCommand::LinkLibraryTypeSpecifierWarning(int left,
|
|
|
|
int right)
|
2008-08-07 21:51:29 +00:00
|
|
|
{
|
2015-01-05 19:31:31 +00:00
|
|
|
std::ostringstream w;
|
2016-05-16 14:34:04 +00:00
|
|
|
w << "Link library type specifier \"" << this->LinkLibraryTypeNames[left]
|
|
|
|
<< "\" is followed by specifier \"" << this->LinkLibraryTypeNames[right]
|
|
|
|
<< "\" instead of a library name. "
|
2008-08-07 21:51:29 +00:00
|
|
|
<< "The first specifier will be ignored.";
|
|
|
|
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
|
|
|
|
}
|
2008-08-11 20:23:02 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
|
|
|
|
cmTargetLinkLibraryType llt)
|
2008-08-11 20:23:02 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (this->Target->GetType() == cmState::INTERFACE_LIBRARY &&
|
|
|
|
this->CurrentProcessingState != ProcessingKeywordLinkInterface) {
|
|
|
|
this->Makefile->IssueMessage(
|
|
|
|
cmake::FATAL_ERROR,
|
2012-11-02 14:47:40 +00:00
|
|
|
"INTERFACE library can only be used with the INTERFACE keyword of "
|
|
|
|
"target_link_libraries");
|
|
|
|
return false;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2012-11-02 14:47:40 +00:00
|
|
|
|
2013-06-04 14:21:33 +00:00
|
|
|
cmTarget::TLLSignature sig =
|
2016-05-16 14:34:04 +00:00
|
|
|
(this->CurrentProcessingState == ProcessingPlainPrivateInterface ||
|
|
|
|
this->CurrentProcessingState == ProcessingPlainPublicInterface ||
|
|
|
|
this->CurrentProcessingState == ProcessingKeywordPrivateInterface ||
|
|
|
|
this->CurrentProcessingState == ProcessingKeywordPublicInterface ||
|
|
|
|
this->CurrentProcessingState == ProcessingKeywordLinkInterface)
|
|
|
|
? cmTarget::KeywordTLLSignature
|
|
|
|
: cmTarget::PlainTLLSignature;
|
2015-06-23 18:56:47 +00:00
|
|
|
if (!this->Target->PushTLLCommandTrace(
|
2016-05-16 14:34:04 +00:00
|
|
|
sig, this->Makefile->GetExecutionContext())) {
|
2015-01-05 19:31:31 +00:00
|
|
|
std::ostringstream e;
|
2016-06-27 20:44:16 +00:00
|
|
|
const char* modal = CM_NULLPTR;
|
2013-06-04 14:21:33 +00:00
|
|
|
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
|
2016-05-16 14:34:04 +00:00
|
|
|
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0023)) {
|
2013-06-04 14:21:33 +00:00
|
|
|
case cmPolicies::WARN:
|
2015-05-03 08:12:10 +00:00
|
|
|
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0023) << "\n";
|
2013-06-04 14:21:33 +00:00
|
|
|
modal = "should";
|
|
|
|
case cmPolicies::OLD:
|
|
|
|
break;
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
modal = "must";
|
|
|
|
messageType = cmake::FATAL_ERROR;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2013-06-04 14:21:33 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (modal) {
|
|
|
|
// If the sig is a keyword form and there is a conflict, the existing
|
|
|
|
// form must be the plain form.
|
|
|
|
const char* existingSig =
|
|
|
|
(sig == cmTarget::KeywordTLLSignature ? "plain" : "keyword");
|
|
|
|
e << "The " << existingSig << " signature for target_link_libraries "
|
|
|
|
"has already been used with the target \""
|
|
|
|
<< this->Target->GetName() << "\". All uses of "
|
|
|
|
"target_link_libraries with a target "
|
|
|
|
<< modal << " be either "
|
|
|
|
"all-keyword or all-plain.\n";
|
|
|
|
this->Target->GetTllSignatureTraces(e,
|
2013-06-04 14:21:33 +00:00
|
|
|
sig == cmTarget::KeywordTLLSignature
|
|
|
|
? cmTarget::PlainTLLSignature
|
|
|
|
: cmTarget::KeywordTLLSignature);
|
2016-05-16 14:34:04 +00:00
|
|
|
this->Makefile->IssueMessage(messageType, e.str());
|
|
|
|
if (messageType == cmake::FATAL_ERROR) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-06-04 14:21:33 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2013-06-04 14:21:33 +00:00
|
|
|
|
2013-11-02 11:07:53 +00:00
|
|
|
// Handle normal case first.
|
2016-05-16 14:34:04 +00:00
|
|
|
if (this->CurrentProcessingState != ProcessingKeywordLinkInterface &&
|
|
|
|
this->CurrentProcessingState != ProcessingPlainLinkInterface) {
|
|
|
|
this->Makefile->AddLinkLibraryForTarget(this->Target->GetName(), lib, llt);
|
|
|
|
if (this->CurrentProcessingState == ProcessingLinkLibraries) {
|
|
|
|
this->Target->AppendProperty(
|
|
|
|
"INTERFACE_LINK_LIBRARIES",
|
2013-11-02 16:36:23 +00:00
|
|
|
this->Target->GetDebugGeneratorExpressions(lib, llt).c_str());
|
|
|
|
return true;
|
2016-09-16 20:45:24 +00:00
|
|
|
}
|
|
|
|
if (this->CurrentProcessingState != ProcessingKeywordPublicInterface &&
|
|
|
|
this->CurrentProcessingState != ProcessingPlainPublicInterface) {
|
2016-05-16 14:34:04 +00:00
|
|
|
if (this->Target->GetType() == cmState::STATIC_LIBRARY) {
|
|
|
|
std::string configLib =
|
|
|
|
this->Target->GetDebugGeneratorExpressions(lib, llt);
|
|
|
|
if (cmGeneratorExpression::IsValidTargetName(lib) ||
|
|
|
|
cmGeneratorExpression::Find(lib) != std::string::npos) {
|
2013-10-20 18:39:16 +00:00
|
|
|
configLib = "$<LINK_ONLY:" + configLib + ">";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2013-06-04 14:21:33 +00:00
|
|
|
this->Target->AppendProperty("INTERFACE_LINK_LIBRARIES",
|
2013-10-20 18:39:16 +00:00
|
|
|
configLib.c_str());
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2013-06-04 14:21:33 +00:00
|
|
|
// Not a 'public' or 'interface' library. Do not add to interface
|
|
|
|
// property.
|
|
|
|
return true;
|
2008-08-11 20:23:02 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2008-08-11 20:23:02 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
this->Target->AppendProperty(
|
|
|
|
"INTERFACE_LINK_LIBRARIES",
|
|
|
|
this->Target->GetDebugGeneratorExpressions(lib, llt).c_str());
|
2013-06-04 14:21:33 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
const cmPolicies::PolicyStatus policy22Status =
|
|
|
|
this->Target->GetPolicyStatusCMP0022();
|
2013-06-04 14:21:33 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (policy22Status != cmPolicies::OLD &&
|
|
|
|
policy22Status != cmPolicies::WARN) {
|
2013-06-04 14:21:33 +00:00
|
|
|
return true;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2013-06-04 14:21:33 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (this->Target->GetType() == cmState::INTERFACE_LIBRARY) {
|
2012-11-02 14:47:40 +00:00
|
|
|
return true;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2012-11-02 14:47:40 +00:00
|
|
|
|
2008-09-04 21:34:25 +00:00
|
|
|
// Get the list of configurations considered to be DEBUG.
|
2015-04-11 10:04:05 +00:00
|
|
|
std::vector<std::string> debugConfigs =
|
2008-09-04 21:34:25 +00:00
|
|
|
this->Makefile->GetCMakeInstance()->GetDebugConfigs();
|
|
|
|
std::string prop;
|
|
|
|
|
2008-08-11 20:23:02 +00:00
|
|
|
// Include this library in the link interface for the target.
|
2016-05-16 14:34:04 +00:00
|
|
|
if (llt == DEBUG_LibraryType || llt == GENERAL_LibraryType) {
|
2008-09-04 21:34:25 +00:00
|
|
|
// Put in the DEBUG configuration interfaces.
|
2016-05-16 14:34:04 +00:00
|
|
|
for (std::vector<std::string>::const_iterator i = debugConfigs.begin();
|
|
|
|
i != debugConfigs.end(); ++i) {
|
2008-09-04 21:34:25 +00:00
|
|
|
prop = "LINK_INTERFACE_LIBRARIES_";
|
|
|
|
prop += *i;
|
2014-03-10 23:04:11 +00:00
|
|
|
this->Target->AppendProperty(prop, lib.c_str());
|
2008-08-11 20:23:02 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (llt == OPTIMIZED_LibraryType || llt == GENERAL_LibraryType) {
|
2008-09-04 21:34:25 +00:00
|
|
|
// Put in the non-DEBUG configuration interfaces.
|
2014-02-09 02:36:26 +00:00
|
|
|
this->Target->AppendProperty("LINK_INTERFACE_LIBRARIES", lib.c_str());
|
2008-08-11 20:23:02 +00:00
|
|
|
|
2008-09-04 21:34:25 +00:00
|
|
|
// Make sure the DEBUG configuration interfaces exist so that the
|
|
|
|
// general one will not be used as a fall-back.
|
2016-05-16 14:34:04 +00:00
|
|
|
for (std::vector<std::string>::const_iterator i = debugConfigs.begin();
|
|
|
|
i != debugConfigs.end(); ++i) {
|
2008-09-04 21:34:25 +00:00
|
|
|
prop = "LINK_INTERFACE_LIBRARIES_";
|
|
|
|
prop += *i;
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!this->Target->GetProperty(prop)) {
|
2014-03-10 23:04:11 +00:00
|
|
|
this->Target->SetProperty(prop, "");
|
2008-08-11 20:23:02 +00:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2013-06-04 14:21:33 +00:00
|
|
|
return true;
|
2008-08-11 20:23:02 +00:00
|
|
|
}
|