cmTargetLinkLibrariesCommand: Optimize ostream::operator<< calls

This commit is contained in:
Alex Turbov
2024-09-16 21:55:08 +04:00
parent 1ffb746c92
commit f40712fc10
+8 -8
View File
@@ -97,8 +97,8 @@ bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args,
if (!target) { if (!target) {
MessageType t = MessageType::FATAL_ERROR; // fail by default MessageType t = MessageType::FATAL_ERROR; // fail by default
std::ostringstream e; std::ostringstream e;
e << "Cannot specify link libraries for target \"" << args[0] << "\" " e << "Cannot specify link libraries for target \"" << args[0]
<< "which is not built by this project."; << "\" which is not built by this project.";
// The bad target is the only argument. Check how policy CMP0016 is set, // The bad target is the only argument. Check how policy CMP0016 is set,
// and accept, warn or fail respectively: // and accept, warn or fail respectively:
if (args.size() < 2) { if (args.size() < 2) {
@@ -107,9 +107,9 @@ bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args,
t = MessageType::AUTHOR_WARNING; t = MessageType::AUTHOR_WARNING;
// Print the warning. // Print the warning.
e << "\n" e << "\n"
<< "CMake does not support this but it used to work accidentally " "CMake does not support this but it used to work accidentally "
<< "and is being allowed for compatibility." "and is being allowed for compatibility."
<< "\n" "\n"
<< cmPolicies::GetPolicyWarning(cmPolicies::CMP0016); << cmPolicies::GetPolicyWarning(cmPolicies::CMP0016);
break; break;
case cmPolicies::OLD: // OLD behavior does not warn. case cmPolicies::OLD: // OLD behavior does not warn.
@@ -117,7 +117,7 @@ bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args,
break; break;
case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_ALWAYS:
e << "\n" << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0016); e << '\n' << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0016);
break; break;
case cmPolicies::NEW: // NEW behavior prints the error. case cmPolicies::NEW: // NEW behavior prints the error.
break; break;
@@ -145,7 +145,7 @@ bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args,
MessageType messageType = MessageType::AUTHOR_WARNING; MessageType messageType = MessageType::AUTHOR_WARNING;
switch (mf.GetPolicyStatus(cmPolicies::CMP0039)) { switch (mf.GetPolicyStatus(cmPolicies::CMP0039)) {
case cmPolicies::WARN: case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0039) << "\n"; e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0039) << '\n';
modal = "should"; modal = "should";
CM_FALLTHROUGH; CM_FALLTHROUGH;
case cmPolicies::OLD: case cmPolicies::OLD:
@@ -456,7 +456,7 @@ bool TLL::HandleLibrary(ProcessingState currentProcessingState,
MessageType messageType = MessageType::AUTHOR_WARNING; MessageType messageType = MessageType::AUTHOR_WARNING;
switch (this->Makefile.GetPolicyStatus(cmPolicies::CMP0023)) { switch (this->Makefile.GetPolicyStatus(cmPolicies::CMP0023)) {
case cmPolicies::WARN: case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0023) << "\n"; e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0023) << '\n';
modal = "should"; modal = "should";
CM_FALLTHROUGH; CM_FALLTHROUGH;
case cmPolicies::OLD: case cmPolicies::OLD: