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