cmComputeLinkInformation: combine string literals where possible

This commit is contained in:
Ben Boeckel
2023-02-03 15:18:58 -05:00
parent 41da256b02
commit 52ca45e485

View File

@@ -1401,8 +1401,7 @@ void cmComputeLinkInformation::ComputeItemParserInfo()
reg += p;
reg += "|";
}
reg += ")";
reg += "([^/:]*)";
reg += ")([^/:]*)";
// Create a regex to match any library name.
std::string reg_any = cmStrCat(reg, libext);
@@ -1860,8 +1859,8 @@ void cmComputeLinkInformation::AddFrameworkItem(LinkEntry const& entry)
: cmGlobalGenerator::FrameworkFormat::Extended);
if (!fwDescriptor) {
std::ostringstream e;
e << "Could not parse framework path \"" << item << "\" "
<< "linked by target " << this->Target->GetName() << ".";
e << "Could not parse framework path \"" << item << "\" linked by target "
<< this->Target->GetName() << ".";
cmSystemTools::Error(e.str());
return;
}
@@ -1995,9 +1994,9 @@ void cmComputeLinkInformation::HandleBadFullItem(LinkEntry const& entry,
std::ostringstream w;
/* clang-format off */
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0008) << "\n"
<< "Target \"" << this->Target->GetName() << "\" links to item\n"
<< " " << item << "\n"
<< "which is a full-path but not a valid library file name.";
"Target \"" << this->Target->GetName() << "\" links to item\n"
" " << item << "\n"
"which is a full-path but not a valid library file name.";
/* clang-format on */
this->CMakeInstance->IssueMessage(MessageType::AUTHOR_WARNING, w.str(),
this->Target->GetBacktrace());
@@ -2015,9 +2014,9 @@ void cmComputeLinkInformation::HandleBadFullItem(LinkEntry const& entry,
std::ostringstream e;
/* clang-format off */
e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0008) << "\n"
<< "Target \"" << this->Target->GetName() << "\" links to item\n"
<< " " << item << "\n"
<< "which is a full-path but not a valid library file name.";
"Target \"" << this->Target->GetName() << "\" links to item\n"
" " << item << "\n"
"which is a full-path but not a valid library file name.";
/* clang-format on */
this->CMakeInstance->IssueMessage(MessageType::FATAL_ERROR, e.str(),
this->Target->GetBacktrace());
@@ -2076,18 +2075,17 @@ void cmComputeLinkInformation::PrintLinkPolicyDiagnosis(std::ostream& os)
// Tell the user what to do.
/* clang-format off */
os << "Policy CMP0003 should be set before this line. "
<< "Add code such as\n"
<< " if(COMMAND cmake_policy)\n"
<< " cmake_policy(SET CMP0003 NEW)\n"
<< " endif(COMMAND cmake_policy)\n"
<< "as early as possible but after the most recent call to "
<< "cmake_minimum_required or cmake_policy(VERSION). ";
"Add code such as\n"
" if(COMMAND cmake_policy)\n"
" cmake_policy(SET CMP0003 NEW)\n"
" endif(COMMAND cmake_policy)\n"
"as early as possible but after the most recent call to "
"cmake_minimum_required or cmake_policy(VERSION). ";
/* clang-format on */
// List the items that might need the old-style paths.
os << "This warning appears because target \"" << this->Target->GetName()
<< "\" "
<< "links to some libraries for which the linker must search:\n";
<< "\" links to some libraries for which the linker must search:\n";
{
// Format the list of unknown items to be as short as possible while
// still fitting in the allowed width (a true solution would be the
@@ -2125,11 +2123,11 @@ void cmComputeLinkInformation::PrintLinkPolicyDiagnosis(std::ostream& os)
// Explain.
os << "CMake is adding directories in the second list to the linker "
<< "search path in case they are needed to find libraries from the "
<< "first list (for backwards compatibility with CMake 2.4). "
<< "Set policy CMP0003 to OLD or NEW to enable or disable this "
<< "behavior explicitly. "
<< "Run \"cmake --help-policy CMP0003\" for more information.";
"search path in case they are needed to find libraries from the "
"first list (for backwards compatibility with CMake 2.4). "
"Set policy CMP0003 to OLD or NEW to enable or disable this "
"behavior explicitly. "
"Run \"cmake --help-policy CMP0003\" for more information.";
}
void cmComputeLinkInformation::LoadImplicitLinkInfo()