mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-19 02:17:27 +08:00
target_link_libraries: Handle keyword arguments in dedicated code path
This commit is contained in:
@@ -178,16 +178,31 @@ bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args,
|
||||
// specification if the keyword is encountered as the first argument.
|
||||
ProcessingState currentProcessingState = ProcessingLinkLibraries;
|
||||
|
||||
// Keep this list in sync with the keyword dispatch below.
|
||||
static std::unordered_set<std::string> const keywords{
|
||||
"LINK_INTERFACE_LIBRARIES",
|
||||
"INTERFACE",
|
||||
"LINK_PUBLIC",
|
||||
"PUBLIC",
|
||||
"LINK_PRIVATE",
|
||||
"PRIVATE",
|
||||
"debug",
|
||||
"optimized",
|
||||
"general",
|
||||
};
|
||||
|
||||
// Add libraries, note that there is an optional prefix
|
||||
// of debug and optimized that can be used.
|
||||
for (unsigned int i = 1; i < args.size(); ++i) {
|
||||
if (keywords.count(args[i])) {
|
||||
// Process this keyword argument.
|
||||
if (args[i] == "LINK_INTERFACE_LIBRARIES") {
|
||||
currentProcessingState = ProcessingPlainLinkInterface;
|
||||
if (i != 1) {
|
||||
mf.IssueMessage(
|
||||
MessageType::FATAL_ERROR,
|
||||
"The LINK_INTERFACE_LIBRARIES option must appear as the second "
|
||||
"argument, just after the target name.");
|
||||
"The LINK_INTERFACE_LIBRARIES option must appear as the "
|
||||
"second argument, just after the target name.");
|
||||
return true;
|
||||
}
|
||||
} else if (args[i] == "INTERFACE") {
|
||||
@@ -195,10 +210,10 @@ bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args,
|
||||
currentProcessingState != ProcessingKeywordPrivateInterface &&
|
||||
currentProcessingState != ProcessingKeywordPublicInterface &&
|
||||
currentProcessingState != ProcessingKeywordLinkInterface) {
|
||||
mf.IssueMessage(
|
||||
MessageType::FATAL_ERROR,
|
||||
"The INTERFACE, PUBLIC or PRIVATE option must appear as the second "
|
||||
"argument, just after the target name.");
|
||||
mf.IssueMessage(MessageType::FATAL_ERROR,
|
||||
"The INTERFACE, PUBLIC or PRIVATE option must "
|
||||
"appear as the second argument, just after the "
|
||||
"target name.");
|
||||
return true;
|
||||
}
|
||||
currentProcessingState = ProcessingKeywordLinkInterface;
|
||||
@@ -208,8 +223,8 @@ bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args,
|
||||
currentProcessingState != ProcessingPlainPublicInterface) {
|
||||
mf.IssueMessage(
|
||||
MessageType::FATAL_ERROR,
|
||||
"The LINK_PUBLIC or LINK_PRIVATE option must appear as the second "
|
||||
"argument, just after the target name.");
|
||||
"The LINK_PUBLIC or LINK_PRIVATE option must appear as the "
|
||||
"second argument, just after the target name.");
|
||||
return true;
|
||||
}
|
||||
currentProcessingState = ProcessingPlainPublicInterface;
|
||||
@@ -218,20 +233,21 @@ bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args,
|
||||
currentProcessingState != ProcessingKeywordPrivateInterface &&
|
||||
currentProcessingState != ProcessingKeywordPublicInterface &&
|
||||
currentProcessingState != ProcessingKeywordLinkInterface) {
|
||||
mf.IssueMessage(
|
||||
MessageType::FATAL_ERROR,
|
||||
"The INTERFACE, PUBLIC or PRIVATE option must appear as the second "
|
||||
"argument, just after the target name.");
|
||||
mf.IssueMessage(MessageType::FATAL_ERROR,
|
||||
"The INTERFACE, PUBLIC or PRIVATE option must "
|
||||
"appear as the second argument, just after the "
|
||||
"target name.");
|
||||
return true;
|
||||
}
|
||||
currentProcessingState = ProcessingKeywordPublicInterface;
|
||||
} else if (args[i] == "LINK_PRIVATE") {
|
||||
if (i != 1 && currentProcessingState != ProcessingPlainPublicInterface &&
|
||||
if (i != 1 &&
|
||||
currentProcessingState != ProcessingPlainPublicInterface &&
|
||||
currentProcessingState != ProcessingPlainPrivateInterface) {
|
||||
mf.IssueMessage(
|
||||
MessageType::FATAL_ERROR,
|
||||
"The LINK_PUBLIC or LINK_PRIVATE option must appear as the second "
|
||||
"argument, just after the target name.");
|
||||
"The LINK_PUBLIC or LINK_PRIVATE option must appear as the "
|
||||
"second argument, just after the target name.");
|
||||
return true;
|
||||
}
|
||||
currentProcessingState = ProcessingPlainPrivateInterface;
|
||||
@@ -240,10 +256,10 @@ bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args,
|
||||
currentProcessingState != ProcessingKeywordPrivateInterface &&
|
||||
currentProcessingState != ProcessingKeywordPublicInterface &&
|
||||
currentProcessingState != ProcessingKeywordLinkInterface) {
|
||||
mf.IssueMessage(
|
||||
MessageType::FATAL_ERROR,
|
||||
"The INTERFACE, PUBLIC or PRIVATE option must appear as the second "
|
||||
"argument, just after the target name.");
|
||||
mf.IssueMessage(MessageType::FATAL_ERROR,
|
||||
"The INTERFACE, PUBLIC or PRIVATE option must "
|
||||
"appear as the second argument, just after the "
|
||||
"target name.");
|
||||
return true;
|
||||
}
|
||||
currentProcessingState = ProcessingKeywordPrivateInterface;
|
||||
@@ -265,6 +281,7 @@ bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args,
|
||||
}
|
||||
llt = GENERAL_LibraryType;
|
||||
haveLLT = true;
|
||||
}
|
||||
} else if (haveLLT) {
|
||||
// The link type was specified by the previous argument.
|
||||
haveLLT = false;
|
||||
|
Reference in New Issue
Block a user