Refactor: Use cmStrCat to construct error strings

Replace string construction using std::stringstream with cmStrCat and
cmWrap.
This commit is contained in:
Asit Dhal
2019-09-15 19:11:02 +02:00
committed by Brad King
parent 1423507a71
commit 9dba84cfa5
31 changed files with 545 additions and 797 deletions
+39 -35
View File
@@ -256,10 +256,11 @@ bool cmTargetLinkLibrariesCommand::InitialPass(
// Make sure the last argument was not a library type specifier.
if (haveLLT) {
std::ostringstream e;
e << "The \"" << cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[llt]
<< "\" argument must be followed by a library.";
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
this->Makefile->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("The \"",
cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[llt],
"\" argument must be followed by a library."));
cmSystemTools::SetFatalErrorOccured();
}
@@ -284,14 +285,14 @@ bool cmTargetLinkLibrariesCommand::InitialPass(
void cmTargetLinkLibrariesCommand::LinkLibraryTypeSpecifierWarning(int left,
int right)
{
std::ostringstream w;
w << "Link library type specifier \""
<< cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[left]
<< "\" is followed by specifier \""
<< cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[right]
<< "\" instead of a library name. "
<< "The first specifier will be ignored.";
this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
this->Makefile->IssueMessage(
MessageType::AUTHOR_WARNING,
cmStrCat(
"Link library type specifier \"",
cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[left],
"\" is followed by specifier \"",
cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[right],
"\" instead of a library name. The first specifier will be ignored."));
}
bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
@@ -404,12 +405,13 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
this->CurrentProcessingState != ProcessingPlainLinkInterface) {
if (rejectRemoteLinking) {
std::ostringstream e;
e << "Attempt to add link library \"" << lib << "\" to target \""
<< this->Target->GetName()
<< "\" which is not built in this directory.\n"
<< "This is allowed only when policy CMP0079 is set to NEW.";
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
this->Makefile->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Attempt to add link library \"", lib, "\" to target \"",
this->Target->GetName(),
"\" which is not built in this "
"directory.\nThis is allowed only when policy CMP0079 "
"is set to NEW."));
return false;
}
@@ -421,29 +423,31 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
(tgt->GetType() != cmStateEnums::OBJECT_LIBRARY) &&
(tgt->GetType() != cmStateEnums::INTERFACE_LIBRARY) &&
!tgt->IsExecutableWithExports()) {
std::ostringstream e;
e << "Target \"" << lib << "\" of type "
<< cmState::GetTargetTypeName(tgt->GetType())
<< " may not be linked into another target. One may link only to "
"INTERFACE, OBJECT, STATIC or SHARED libraries, or to executables "
"with the ENABLE_EXPORTS property set.";
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
this->Makefile->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat(
"Target \"", lib, "\" of type ",
cmState::GetTargetTypeName(tgt->GetType()),
" may not be linked into another target. One may link only to "
"INTERFACE, OBJECT, STATIC or SHARED libraries, or to ",
"executables with the ENABLE_EXPORTS property set."));
}
this->Target->AddLinkLibrary(*this->Makefile, lib, libRef, llt);
}
if (warnRemoteInterface) {
std::ostringstream w;
/* clang-format off */
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0079) << "\n"
"Target\n " << this->Target->GetName() << "\nis not created in this "
"directory. For compatibility with older versions of CMake, link "
"library\n " << lib << "\nwill be looked up in the directory in "
"which the target was created rather than in this calling "
"directory.";
/* clang-format on */
this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
this->Makefile->IssueMessage(
MessageType::AUTHOR_WARNING,
cmStrCat(
cmPolicies::GetPolicyWarning(cmPolicies::CMP0079), "\nTarget\n ",
this->Target->GetName(),
"\nis not created in this "
"directory. For compatibility with older versions of CMake, link "
"library\n ",
lib,
"\nwill be looked up in the directory in which "
"the target was created rather than in this calling directory."));
}
// Handle (additional) case where the command was called with PRIVATE /