Source: migrate ostringstream usage to cmStrCat

This commit is contained in:
AJIOB committed 2026-09-30 16:54:28 +03:00
1 parent 8f12d00e83
commit 5fba25c052
35 files changed
+217 -276

No files matched your search

+11 -11
View File
@@ -3,13 +3,16 @@
#include "cmCPackIFWCommon.h"
#include <cstddef> // IWYU pragma: keep
#include <sstream>
#include <utility>
#include <cm/string_view>
#include <cmext/string_view>
#include "cmCPackGenerator.h"
#include "cmCPackIFWGenerator.h"
#include "cmCPackLog.h" // IWYU pragma: keep
#include "cmList.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTimestamp.h"
#include "cmVersionConfig.h"
@@ -120,14 +123,11 @@ void cmCPackIFWCommon::WriteGeneratedByToStrim(cmXMLWriter& xout) const
return;
}
std::ostringstream comment;
comment << "Generated by CPack " << CMake_VERSION << " IFW generator "
<< "for QtIFW ";
if (this->IsVersionEqual("1.9.9")) {
comment << "less 2.0";
} else {
comment << this->Generator->FrameworkVersion;
}
comment << " tools at " << cmTimestamp().CurrentTime("", true);
xout.Comment(comment.str().c_str());
std::string const comment =
cmStrCat("Generated by CPack ", CMake_VERSION, " IFW generator for QtIFW ",
this->IsVersionEqual("1.9.9")
? "less 2.0"_s
: cm::string_view(this->Generator->FrameworkVersion),
" tools at ", cmTimestamp().CurrentTime("", true));
xout.Comment(comment.c_str());
}
@@ -4,6 +4,8 @@
#include <cmext/string_view>
#include "cmStringAlgorithms.h"
cmWIXDirectoriesSourceWriter::cmWIXDirectoriesSourceWriter(
unsigned long wixVersion, cmCPackLog* logger, std::string const& filename,
GuidType componentGuidType, cmWIXInstallScope installScope,
@@ -126,9 +128,7 @@ cmWIXDirectoriesSourceWriter::BeginInstallationPrefixDirectory(
if (i == installRoot.size() - 1) {
AddAttribute("Id", "INSTALL_ROOT");
} else {
std::ostringstream tmp;
tmp << "INSTALL_PREFIX_" << i;
AddAttribute("Id", tmp.str());
AddAttribute("Id", cmStrCat("INSTALL_PREFIX_", i));
}
AddAttribute("Name", installRoot[i]);
+6 -5
View File
@@ -11,6 +11,7 @@
#include "cmCMakeToWixPath.h"
#include "cmInstalledFile.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmWIXAccessControlList.h"
@@ -45,17 +46,17 @@ void cmWIXFilesSourceWriter::EmitShortcut(std::string const& id,
std::string const& shortcutPrefix,
size_t shortcutIndex)
{
std::ostringstream shortcutId;
shortcutId << shortcutPrefix << id;
std::string shortcutId;
if (shortcutIndex > 0) {
shortcutId << "_" << shortcutIndex;
shortcutId = cmStrCat(shortcutPrefix, id, '_', shortcutIndex);
} else {
shortcutId = cmStrCat(shortcutPrefix, id);
}
std::string fileId = std::string("CM_F") + id;
BeginElement("Shortcut");
AddAttribute("Id", shortcutId.str());
AddAttribute("Id", shortcutId);
AddAttribute("Name", shortcut.label);
std::string target = "[#" + fileId + "]";
AddAttribute("Target", target);
+3 -3
View File
@@ -10,6 +10,7 @@
#include <cm3p/expat.h>
#include "cmCPackGenerator.h"
#include "cmStringAlgorithms.h"
cmWIXPatchNode::Type cmWIXPatchText::type()
{
@@ -79,9 +80,8 @@ void cmWIXPatchParser::StartFragment(char const** attributes)
if (key == "Id"_s) {
if (Fragments.find(value) != Fragments.end()) {
std::ostringstream tmp;
tmp << "Invalid reuse of 'CPackWixFragment' 'Id': " << value;
ReportValidationError(tmp.str());
ReportValidationError(
cmStrCat("Invalid reuse of 'CPackWixFragment' 'Id': ", value));
}
new_element = &Fragments[value];
+4 -5
View File
@@ -8,7 +8,6 @@
#include <iterator>
#include <map>
#include <memory>
#include <sstream>
#include <string>
#include <type_traits>
#include <utility>
@@ -604,10 +603,10 @@ int main(int argc, char const* const* argv)
mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR");
cmValue projVersionPatch =
mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
std::ostringstream ostr;
ostr << *projVersionMajor << '.' << *projVersionMinor << '.'
<< *projVersionPatch;
mf->AddDefinition("CPACK_PACKAGE_VERSION", ostr.str());
mf->AddDefinition("CPACK_PACKAGE_VERSION",
cmStrCat(*projVersionMajor, '.',
*projVersionMinor, '.',
*projVersionPatch));
}
int res = cpackGenerator->DoPackage();
+10 -10
View File
@@ -3,7 +3,7 @@
#include "cmCTestStartCommand.h"
#include <cstddef>
#include <sstream>
#include <ios>
#include <vector>
#include "cmCTest.h"
@@ -35,9 +35,8 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
cnt++;
if (cnt >= args.size() || args[cnt] == "APPEND" ||
args[cnt] == "QUIET") {
std::ostringstream e;
e << args[cnt - 1] << " argument missing group name";
status.SetError(e.str());
status.SetError(
cmStrCat(args[cnt - 1], " argument missing group name"));
return false;
}
this->CTest->SetSpecificGroup(args[cnt].c_str());
@@ -134,12 +133,13 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
return false;
}
if (!cmSystemTools::FileIsDirectory(sourceDir)) {
std::ostringstream e;
e << "given source path\n"
<< " " << sourceDir << "\n"
<< "which is not an existing directory. "
<< "Set CTEST_CHECKOUT_COMMAND to a command line to create it.";
status.SetError(e.str());
status.SetError(
cmStrCat("given source path\n"
" ",
sourceDir,
"\n"
"which is not an existing directory. "
"Set CTEST_CHECKOUT_COMMAND to a command line to create it."));
return false;
}
+4 -9
View File
@@ -3,7 +3,7 @@
#include "cmCTestUpdateCommand.h"
#include <chrono>
#include <sstream>
#include <iosfwd>
#include <string>
#include <cm/memory>
@@ -187,14 +187,9 @@ bool cmCTestUpdateCommand::ExecuteUpdate(UpdateArguments& args,
}
if (updateCommand.empty()) {
std::ostringstream e;
e << "called with no update command specified. "
"Please set CTEST_UPDATE_COMMAND";
if (key) {
e << " or " << key;
}
e << '.';
status.SetError(e.str());
status.SetError(cmStrCat("called with no update command specified. "
"Please set CTEST_UPDATE_COMMAND",
key ? " or "_s : ""_s, key ? key : "", '.'));
return false;
}
}
+4 -5
View File
@@ -4,7 +4,6 @@
#include <algorithm>
#include <chrono>
#include <sstream>
#include <string>
#include <cm/vector>
@@ -32,10 +31,10 @@ bool cmCTestUploadCommand::ExecuteUpload(UploadArguments& args,
cm::erase_if(args.Files, [&mf](std::string const& arg) -> bool {
if (!cmSystemTools::FileExists(arg)) {
std::ostringstream e;
e << "File \"" << arg << "\" does not exist. Cannot submit "
<< "a non-existent file.";
mf.IssueMessage(MessageType::FATAL_ERROR, e.str());
mf.IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("File \"", arg,
"\" does not exist. Cannot submit a non-existent file."));
return true;
}
return false;
+10 -14
View File
@@ -4,7 +4,6 @@
#include "cmBinUtilsLinuxELFLinker.h"
#include <queue>
#include <sstream>
#include <unordered_set>
#include <utility>
@@ -62,9 +61,8 @@ bool cmBinUtilsLinuxELFLinker::Prepare()
cm::make_unique<cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool>(
this->Archive);
} else {
std::ostringstream e;
e << "Invalid value for CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL: " << tool;
this->SetError(e.str());
this->SetError(cmStrCat(
"Invalid value for CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL: ", tool));
return false;
}
@@ -80,9 +78,8 @@ bool cmBinUtilsLinuxELFLinker::Prepare()
return false;
}
} else {
std::ostringstream e;
e << "Invalid value for CMAKE_LDCONFIG_TOOL: " << ldConfigTool;
this->SetError(e.str());
this->SetError(
cmStrCat("Invalid value for CMAKE_LDCONFIG_TOOL: ", ldConfigTool));
return false;
}
@@ -214,13 +211,12 @@ bool cmBinUtilsLinuxELFLinker::ResolveDependency(
path = cmStrCat(searchPath, '/', name);
if (cmSystemTools::PathExists(path) &&
FileHasArchitecture(path.c_str(), this->Machine)) {
std::ostringstream warning;
warning << "Dependency " << name << " found in search directory:\n "
<< searchPath
<< "\nSee file(GET_RUNTIME_DEPENDENCIES) documentation for "
<< "more information.";
this->Archive->GetMakefile()->IssueMessage(MessageType::WARNING,
warning.str());
this->Archive->GetMakefile()->IssueMessage(
MessageType::WARNING,
cmStrCat("Dependency ", name, " found in search directory:\n ",
searchPath,
"\nSee file(GET_RUNTIME_DEPENDENCIES) documentation for more "
"information."));
resolved = true;
return true;
}
@@ -3,12 +3,13 @@
#include "cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool.h"
#include <sstream>
#include <istream>
#include <vector>
#include <cmsys/RegularExpression.hxx>
#include "cmRuntimeDependencyArchive.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmUVProcessChain.h"
#include "cmUVStream.h"
@@ -38,9 +39,7 @@ bool cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool::GetFileInfo(
auto process = builder.Start();
if (!process.Valid() || process.GetStatus(0).SpawnResult != 0) {
std::ostringstream e;
e << "Failed to start objdump process for:\n " << file;
this->SetError(e.str());
this->SetError(cmStrCat("Failed to start objdump process for:\n ", file));
return false;
}
@@ -71,15 +70,12 @@ bool cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool::GetFileInfo(
}
if (!process.Wait()) {
std::ostringstream e;
e << "Failed to wait on objdump process for:\n " << file;
this->SetError(e.str());
this->SetError(
cmStrCat("Failed to wait on objdump process for:\n ", file));
return false;
}
if (process.GetStatus(0).ExitStatus != 0) {
std::ostringstream e;
e << "Failed to run objdump on:\n " << file;
this->SetError(e.str());
this->SetError(cmStrCat("Failed to run objdump on:\n ", file));
return false;
}
+2 -4
View File
@@ -3,7 +3,6 @@
#include "cmBinUtilsMacOSMachOLinker.h"
#include <sstream>
#include <string>
#include <utility>
#include <vector>
@@ -45,9 +44,8 @@ bool cmBinUtilsMacOSMachOLinker::Prepare()
cm::make_unique<cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool>(
this->Archive);
} else {
std::ostringstream e;
e << "Invalid value for CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL: " << tool;
this->SetError(e.str());
this->SetError(cmStrCat(
"Invalid value for CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL: ", tool));
return false;
}
@@ -3,12 +3,13 @@
#include "cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool.h"
#include <sstream>
#include <istream>
#include <vector>
#include <cmsys/RegularExpression.hxx>
#include "cmRuntimeDependencyArchive.h"
#include "cmStringAlgorithms.h"
#include "cmUVProcessChain.h"
#include "cmUVStream.h"
@@ -37,9 +38,7 @@ bool cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool::GetFileInfo(
auto process = builder.Start();
if (!process.Valid() || process.GetStatus(0).SpawnResult != 0) {
std::ostringstream e;
e << "Failed to start otool process for:\n " << file;
this->SetError(e.str());
this->SetError(cmStrCat("Failed to start otool process for:\n ", file));
return false;
}
@@ -86,15 +85,11 @@ bool cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool::GetFileInfo(
}
if (!process.Wait()) {
std::ostringstream e;
e << "Failed to wait on otool process for:\n " << file;
this->SetError(e.str());
this->SetError(cmStrCat("Failed to wait on otool process for:\n ", file));
return false;
}
if (process.GetStatus(0).ExitStatus != 0) {
std::ostringstream e;
e << "Failed to run otool on:\n " << file;
this->SetError(e.str());
this->SetError(cmStrCat("Failed to run otool on:\n ", file));
return false;
}
@@ -3,12 +3,13 @@
#include "cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool.h"
#include <sstream>
#include <istream>
#include <vector>
#include <cmsys/RegularExpression.hxx>
#include "cmRuntimeDependencyArchive.h"
#include "cmStringAlgorithms.h"
#include "cmUVProcessChain.h"
#include "cmUVStream.h"
@@ -36,9 +37,7 @@ bool cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool::GetFileInfo(
auto process = builder.Start();
if (!process.Valid() || process.GetStatus(0).SpawnResult != 0) {
std::ostringstream e;
e << "Failed to start dumpbin process for:\n " << file;
this->SetError(e.str());
this->SetError(cmStrCat("Failed to start dumpbin process for:\n ", file));
return false;
}
@@ -54,15 +53,12 @@ bool cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool::GetFileInfo(
}
if (!process.Wait()) {
std::ostringstream e;
e << "Failed to wait on dumpbin process for:\n " << file;
this->SetError(e.str());
this->SetError(
cmStrCat("Failed to wait on dumpbin process for:\n ", file));
return false;
}
if (process.GetStatus(0).ExitStatus != 0) {
std::ostringstream e;
e << "Failed to run dumpbin on:\n " << file;
this->SetError(e.str());
this->SetError(cmStrCat("Failed to run dumpbin on:\n ", file));
return false;
}
+3 -6
View File
@@ -6,7 +6,6 @@
#include <algorithm>
#include <cstddef>
#include <iterator>
#include <sstream>
#include <utility>
#include <vector>
@@ -16,6 +15,7 @@
#include "cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool.h"
#include "cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.h"
#include "cmRuntimeDependencyArchive.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTargetTypes.h"
@@ -23,8 +23,6 @@
# include <windows.h>
# include "cmsys/Encoding.hxx"
# include "cmStringAlgorithms.h"
#else
# include "cmsys/Directory.hxx"
#endif
@@ -95,9 +93,8 @@ bool cmBinUtilsWindowsPELinker::Prepare()
cm::make_unique<cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool>(
this->Archive);
} else {
std::ostringstream e;
e << "Invalid value for CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL: " << tool;
this->SetError(e.str());
this->SetError(cmStrCat(
"Invalid value for CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL: ", tool));
return false;
}
@@ -3,12 +3,13 @@
#include "cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.h"
#include <sstream>
#include <istream> // IWYU pragma: keep
#include <vector>
#include <cmsys/RegularExpression.hxx>
#include "cmRuntimeDependencyArchive.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmUVProcessChain.h"
#include "cmUVStream.h"
@@ -37,9 +38,7 @@ bool cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool::GetFileInfo(
auto process = builder.Start();
if (!process.Valid() || process.GetStatus(0).SpawnResult != 0) {
std::ostringstream e;
e << "Failed to start objdump process for:\n " << file;
this->SetError(e.str());
this->SetError(cmStrCat("Failed to start objdump process for:\n ", file));
return false;
}
@@ -55,15 +54,12 @@ bool cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool::GetFileInfo(
}
if (!process.Wait()) {
std::ostringstream e;
e << "Failed to wait on objdump process for:\n " << file;
this->SetError(e.str());
this->SetError(
cmStrCat("Failed to wait on objdump process for:\n ", file));
return false;
}
if (process.GetStatus(0).ExitStatus != 0) {
std::ostringstream e;
e << "Failed to run objdump on:\n " << file;
this->SetError(e.str());
this->SetError(cmStrCat("Failed to run objdump on:\n ", file));
return false;
}
+3 -7
View File
@@ -2,9 +2,9 @@
file LICENSE.rst or https://cmake.org/licensing for details. */
#include "cmCLocaleEnvironmentScope.h"
#include <sstream>
#include <utility>
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
cmCLocaleEnvironmentScope::cmCLocaleEnvironmentScope()
@@ -37,17 +37,13 @@ void cmCLocaleEnvironmentScope::SetEnv(std::string const& key,
if (value.empty()) {
cmSystemTools::UnsetEnv(key.c_str());
} else {
std::ostringstream tmp;
tmp << key << "=" << value;
cmSystemTools::PutEnv(tmp.str());
cmSystemTools::PutEnv(cmStrCat(key, '=', value));
}
}
cmCLocaleEnvironmentScope::~cmCLocaleEnvironmentScope()
{
for (auto const& envb : this->EnvironmentBackup) {
std::ostringstream tmp;
tmp << envb.first << "=" << envb.second;
cmSystemTools::PutEnv(tmp.str());
cmSystemTools::PutEnv(cmStrCat(envb.first, '=', envb.second));
}
}
+16 -16
View File
@@ -14,7 +14,6 @@
#include <iterator>
#include <map>
#include <ratio>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
@@ -3794,12 +3793,12 @@ bool cmCTest::StartResultingXML(Part part, char const* name, int submitIndex,
if (submitIndex == 0) {
submitIndex = this->Impl->SubmitIndex;
}
std::ostringstream ostr;
ostr << name;
std::string fname;
if (submitIndex > 0) {
ostr << "_" << submitIndex;
fname = cmStrCat(name, '_', submitIndex, ".xml");
} else {
fname = cmStrCat(name, ".xml");
}
ostr << ".xml";
if (this->Impl->CurrentTag.empty()) {
cmCTestLog(this, ERROR_MESSAGE,
"Current Tag empty, this may mean NightlyStartTime / "
@@ -3809,12 +3808,12 @@ bool cmCTest::StartResultingXML(Part part, char const* name, int submitIndex,
cmSystemTools::SetFatalErrorOccurred();
return false;
}
if (!this->OpenOutputFile(this->Impl->CurrentTag, ostr.str(), xofs, true)) {
if (!this->OpenOutputFile(this->Impl->CurrentTag, fname, xofs, true)) {
cmCTestLog(this, ERROR_MESSAGE,
"Cannot create resulting XML file: ", ostr.str(), '\n');
"Cannot create resulting XML file: ", fname, '\n');
return false;
}
this->AddSubmitFile(part, ostr.str());
this->AddSubmitFile(part, fname);
return true;
}
@@ -3829,18 +3828,19 @@ bool cmCTest::StartLogFile(char const* name, int submitIndex,
if (submitIndex == 0) {
submitIndex = this->Impl->SubmitIndex;
}
std::ostringstream ostr;
ostr << "Last" << name;
std::string fname;
if (submitIndex > 0) {
ostr << "_" << submitIndex;
fname = cmStrCat("Last", name, '_', submitIndex);
} else {
fname = cmStrCat("Last", name);
}
if (!this->Impl->CurrentTag.empty()) {
ostr << "_" << this->Impl->CurrentTag;
fname = cmStrCat(std::move(fname), '_', this->Impl->CurrentTag, ".log");
} else {
fname = cmStrCat(std::move(fname), ".log");
}
ostr << ".log";
if (!this->OpenOutputFile("Temporary", ostr.str(), xofs)) {
cmCTestLog(this, ERROR_MESSAGE, "Cannot create log file: ", ostr.str(),
'\n');
if (!this->OpenOutputFile("Temporary", fname, xofs)) {
cmCTestLog(this, ERROR_MESSAGE, "Cannot create log file: ", fname, '\n');
return false;
}
return true;
+3 -5
View File
@@ -5,7 +5,6 @@
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <string>
#include "cmsys/FStream.hxx"
@@ -109,10 +108,9 @@ bool cmCacheManager::LoadCache(std::string const& path, bool internal,
}
}
} else {
std::ostringstream error;
error << "Parse error in cache file " << cacheFile << " on line "
<< lineno << ". Offending entry: " << realbuffer;
cmSystemTools::Error(error.str());
cmSystemTools::Error(cmStrCat("Parse error in cache file ", cacheFile,
" on line ", lineno,
". Offending entry: ", realbuffer));
}
}
this->CacheMajorVersion = 0;
+3 -5
View File
@@ -3,7 +3,6 @@
#include "cmComputeLinkInformation.h"
#include <algorithm>
#include <sstream>
#include <utility>
#include <cm/memory>
@@ -1897,10 +1896,9 @@ void cmComputeLinkInformation::AddFrameworkItem(LinkEntry const& entry)
entry.Feature == DEFAULT ? cmGlobalGenerator::FrameworkFormat::Relaxed
: cmGlobalGenerator::FrameworkFormat::Extended);
if (!fwDescriptor) {
std::ostringstream e;
e << "Could not parse framework path \"" << item << "\" linked by target "
<< this->Target->GetName() << '.';
cmSystemTools::Error(e.str());
cmSystemTools::Error(cmStrCat("Could not parse framework path \"", item,
"\" linked by target ",
this->Target->GetName(), '.'));
return;
}
+2 -4
View File
@@ -8,7 +8,6 @@
#include <functional>
#include <iterator>
#include <list>
#include <sstream>
#include <utility>
#include <cm/optional>
@@ -603,9 +602,8 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs,
auto const& rex = args.nextnext->GetValue();
cmsys::RegularExpression regEntry;
if (!regEntry.compile(rex)) {
std::ostringstream error;
error << "Regular expression \"" << rex << "\" cannot compile";
errorString = error.str();
errorString =
cmStrCat("Regular expression \"", rex, "\" cannot compile");
status = MessageType::FATAL_ERROR;
return false;
}
+2 -4
View File
@@ -7,7 +7,6 @@
#include <cstdint>
#include <map>
#include <memory>
#include <sstream>
#include <utility>
#include <vector>
@@ -18,6 +17,7 @@
#include "cmsys/FStream.hxx"
#include "cmStringAlgorithms.h"
#include "cmelf/elf32.h"
#include "cmelf/elf64.h"
#include "cmelf/elf_common.h"
@@ -452,9 +452,7 @@ cmELFInternalImpl<Types>::cmELFInternalImpl(cmELF* external,
this->ELFType = cmELF::FileTypeSpecificProc;
break;
}
std::ostringstream e;
e << "Unknown ELF file type " << eti;
this->SetErrorMessage(e.str().c_str());
this->SetErrorMessage(cmStrCat("Unknown ELF file type ", eti).c_str());
return;
}
}
+5 -7
View File
@@ -5,7 +5,7 @@
#include <cstddef>
#include <functional>
#include <memory>
#include <sstream>
#include <ostream>
#include <vector>
#include "cmExportSet.h"
@@ -28,12 +28,10 @@ cmExportInstallAndroidMKGenerator::cmExportInstallAndroidMKGenerator(
void cmExportInstallAndroidMKGenerator::ReportDuplicateTarget(
std::string const& targetName) const
{
std::ostringstream e;
e << "install(EXPORT_ANDROID_MK \"" << this->GetExportSet()->GetName()
<< "\" ...) "
<< "includes target \"" << targetName
<< "\" more than once in the export set.";
this->ReportError(e.str());
this->ReportError(cmStrCat("install(EXPORT_ANDROID_MK \"",
this->GetExportSet()->GetName(),
"\" ...) includes target \"", targetName,
"\" more than once in the export set."));
}
bool cmExportInstallAndroidMKGenerator::GenerateMainFile(std::ostream& os)
@@ -5,8 +5,8 @@
#include <functional>
#include <map>
#include <memory>
#include <ostream>
#include <set>
#include <sstream>
#include <utility>
#include <vector>
@@ -400,9 +400,8 @@ bool cmExportInstallCMakeConfigGenerator::
cmGeneratedFileStream os(fileName, true);
if (!os) {
std::string se = cmSystemTools::GetLastSystemError();
std::ostringstream e;
e << "cannot write to file \"" << fileName << "\": " << se;
cmSystemTools::Error(e.str());
cmSystemTools::Error(
cmStrCat("cannot write to file \"", fileName, "\": ", se));
return false;
}
os.SetCopyIfDifferent(true);
+4 -8
View File
@@ -3,7 +3,6 @@
#include "cmExprParserHelper.h"
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <utility>
@@ -95,9 +94,7 @@ int cmExprParserHelper::LexInput(char* buf, int maxlen)
void cmExprParserHelper::Error(char const* str)
{
unsigned long pos = static_cast<unsigned long>(this->InputBufferPos);
std::ostringstream ostr;
ostr << str << " (" << pos << ")";
this->ErrorString = ostr.str();
this->ErrorString = cmStrCat(str, " (", pos, ')');
}
void cmExprParserHelper::Warning(std::string str)
@@ -108,10 +105,9 @@ void cmExprParserHelper::Warning(std::string str)
void cmExprParserHelper::UnexpectedChar(char c)
{
unsigned long pos = static_cast<unsigned long>(this->InputBufferPos);
std::ostringstream ostr;
ostr << "Unexpected character in expression at position " << pos << ": " << c
<< "\n";
this->WarningString += ostr.str();
this->WarningString = cmStrCat(
this->WarningString, "Unexpected character in expression at position ",
pos, ": ", c, '\n');
}
void cmExprParserHelper::SetResult(std::int64_t value)
+6 -6
View File
@@ -4,8 +4,8 @@
#include <cstring>
#include <memory>
#include <ostream>
#include <set>
#include <sstream>
#include <utility>
#include "cmsys/RegularExpression.hxx"
@@ -156,11 +156,11 @@ void cmExtraSublimeTextGenerator::CreateNewProjectFile(
fout << "\n\t\t\t\"" << varName << "\":\"" << varValue << "\"";
} else {
std::ostringstream e;
e << "Could not parse Env Vars specified in "
"\"CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS\""
<< ", corrupted string " << t;
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
mf->IssueMessage(MessageType::FATAL_ERROR,
cmStrCat("Could not parse Env Vars specified in "
"\"CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS\""
", corrupted string ",
t));
}
}
fout << "\n\t\t}";
+5 -7
View File
@@ -8,7 +8,6 @@
#include <initializer_list>
#include <iterator>
#include <queue>
#include <sstream>
#include <cm/memory>
@@ -443,12 +442,11 @@ void cmGlobalFastbuildGenerator::Generate()
if (cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
this->FastbuildVersion,
RequiredFastbuildVersion())) {
std::ostringstream msg;
msg << "The detected version of Fastbuild (" << this->FastbuildVersion;
msg << ") is less than the version of Fastbuild required by CMake (";
msg << this->RequiredFastbuildVersion() << ").";
this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR,
msg.str());
this->GetCMakeInstance()->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("The detected version of Fastbuild (", this->FastbuildVersion,
") is less than the version of Fastbuild required by CMake (",
this->RequiredFastbuildVersion(), ")."));
return;
}
this->ProcessEnvironment();
+5 -6
View File
@@ -5,7 +5,7 @@
#include <algorithm>
#include <functional>
#include <map>
#include <sstream>
#include <ostream>
#include <utility>
#include <cm/memory>
@@ -681,11 +681,10 @@ bool cmGlobalGhsMultiGenerator::AddCheckTarget()
// Print not implemented warning.
if (this->GetCMakeInstance()->DoWriteGlobVerifyTarget()) {
std::ostringstream msg;
msg << "Any pre-check scripts, such as those generated for file(GLOB "
"CONFIGURE_DEPENDS), will not be run by gbuild.";
this->GetCMakeInstance()->IssueDiagnostic(cmDiagnostics::CMD_AUTHOR,
msg.str());
this->GetCMakeInstance()->IssueDiagnostic(
cmDiagnostics::CMD_AUTHOR,
"Any pre-check scripts, such as those generated for file(GLOB "
"CONFIGURE_DEPENDS), will not be run by gbuild.");
}
// Sort the list of input files and remove duplicates.
+13 -13
View File
@@ -3,7 +3,6 @@
#include "cmGlobalVisualStudio14Generator.h"
#include <cstring>
#include <sstream>
#include <cm/vector>
#include <cmext/string_view>
@@ -126,18 +125,19 @@ bool cmGlobalVisualStudio14Generator::VerifyNoGeneratorPlatformVersion(
if (!this->GeneratorPlatformVersion) {
return true;
}
std::ostringstream e;
/* clang-format off */
e <<
"Generator\n"
" " << this->GetName() << "\n"
"given platform specification containing a\n"
" version=" << *this->GeneratorPlatformVersion << "\n"
"field. The version field is not supported when targeting\n"
" " << this->SystemName << ' ' << this->SystemVersion << '\n'
;
/* clang-format on */
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
mf->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Generator\n"
" ",
this->GetName(),
"\n"
"given platform specification containing a\n"
" version=",
*this->GeneratorPlatformVersion,
"\n"
"field. The version field is not supported when targeting\n"
" ",
this->SystemName, ' ', this->SystemVersion, '\n'));
return false;
}
@@ -4,7 +4,6 @@
#include <cstring>
#include <set>
#include <sstream>
#include <utility>
#include <vector>
@@ -582,22 +581,23 @@ bool cmGlobalVisualStudioVersionedGenerator::SetGeneratorInstance(
vsInstance = i;
if (!this->vsSetupAPIHelper.SetVSInstance(
this->GeneratorInstance, this->GeneratorInstanceVersion)) {
std::ostringstream e;
/* clang-format off */
e <<
"Generator\n"
" " << this->GetName() << "\n"
"could not find specified instance of Visual Studio:\n"
" " << i;
/* clang-format on */
if (!this->GeneratorInstance.empty() &&
this->GeneratorInstanceVersion.empty() &&
cmSystemTools::FileIsDirectory(this->GeneratorInstance)) {
e << "\n"
"The directory exists, but the instance is not known to the "
"Visual Studio Installer, and no 'version=' field was given.";
}
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
mf->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat(
"Generator\n"
" ",
this->GetName(),
"\n"
"could not find specified instance of Visual Studio:\n"
" ",
i,
(!this->GeneratorInstance.empty() &&
this->GeneratorInstanceVersion.empty() &&
cmSystemTools::FileIsDirectory(this->GeneratorInstance))
? "\n"
"The directory exists, but the instance is not known to the "
"Visual Studio Installer, and no 'version=' field was given."
: ""));
return false;
}
} else if (!this->vsSetupAPIHelper.GetVSInstanceInfo(vsInstance)) {
+4 -5
View File
@@ -3,7 +3,7 @@
#include "cmInstallExportGenerator.h"
#include <map>
#include <sstream>
#include <ostream>
#include <utility>
#include "cmCryptoHash.h"
@@ -77,10 +77,9 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os)
{
// Skip empty sets.
if (this->ExportSet->GetTargetExports().empty()) {
std::ostringstream e;
e << "INSTALL(" << this->InstallSubcommand() << ") given unknown export \""
<< this->ExportSet->GetName() << "\"";
cmSystemTools::Error(e.str());
cmSystemTools::Error(cmStrCat("INSTALL(", this->InstallSubcommand(),
") given unknown export \"",
this->ExportSet->GetName(), '"'));
return;
}
+4 -5
View File
@@ -4,7 +4,6 @@
#include "cmRuntimeDependencyArchive.h"
#include <algorithm>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
@@ -17,6 +16,7 @@
#include "cmExecutionStatus.h"
#include "cmList.h"
#include "cmMakefile.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTargetTypes.h"
@@ -164,10 +164,9 @@ bool cmRuntimeDependencyArchive::Prepare()
} else if (platform == "macos+macho") {
this->Linker = cm::make_unique<cmBinUtilsMacOSMachOLinker>(this);
} else {
std::ostringstream e;
e << "Invalid value for CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM: "
<< platform;
this->SetError(e.str());
this->SetError(
cmStrCat("Invalid value for CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM: ",
platform));
return false;
}
+14 -16
View File
@@ -8,7 +8,6 @@
#include <map>
#include <memory>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
@@ -606,21 +605,20 @@ bool cmSbomBuilder::NoteLinkedTarget(cmGeneratorTarget const* target,
return true;
}
std::ostringstream e;
e << "Target \"" << target->GetName() << "\" references target \""
<< linkedName << "\" ";
if (exportInfo.Sets.size() == 1) {
e << "that is in an export set which is exported multiple times "
"with different namespaces: ";
} else {
e << "that is in multiple export sets: ";
}
e << cmJoin(exportInfo.Files, ", ") << ".\n"
<< "An SBOM cannot attribute a dependency exported in more than one "
"export set or with more than one namespace. Consider "
"consolidating the exports of the \""
<< linkedTarget->GetName() << "\" target to a single export.";
target->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
target->Makefile->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Target \"", target->GetName(), "\" references target \"",
linkedName, "\" ",
exportInfo.Sets.size() == 1
? "that is in an export set which is exported multiple times "
"with different namespaces: "
: "that is in multiple export sets: ",
cmJoin(exportInfo.Files, ", "),
".\n"
"An SBOM cannot attribute a dependency exported in more than one "
"export set or with more than one namespace. Consider "
"consolidating the exports of the \"",
linkedTarget->GetName(), "\" target to a single export."));
return false;
}
+8 -10
View File
@@ -3,11 +3,11 @@
#include "cmStringReplaceHelper.h"
#include <sstream>
#include <utility>
#include "cmMakefile.h"
#include "cmPolicies.h"
#include "cmStringAlgorithms.h"
cmStringReplaceHelper::cmStringReplaceHelper(std::string const& regex,
std::string replace_expr,
@@ -53,11 +53,10 @@ bool cmStringReplaceHelper::Replace(cm::string_view input, std::string& output)
// Replace with part of the match.
auto n = replacement.Number;
if (n > re.num_groups()) {
std::ostringstream error;
error << "replace expression \"" << this->ReplaceExpression
<< "\" contains an out-of-range escape for regex \""
<< this->RegExString << "\"";
this->ErrorString = error.str();
this->ErrorString =
cmStrCat("replace expression \"", this->ReplaceExpression,
"\" contains an out-of-range escape for regex \"",
this->RegExString, '"');
return false;
}
output += re.match(n);
@@ -111,10 +110,9 @@ void cmStringReplaceHelper::ParseReplaceExpression()
this->Replacements.emplace_back("\\");
} else {
this->ValidReplaceExpression = false;
std::ostringstream error;
error << "Unknown escape \"" << this->ReplaceExpression.substr(r, 2)
<< "\" in replace-expression";
this->ErrorString = error.str();
this->ErrorString =
cmStrCat("Unknown escape \"", this->ReplaceExpression.substr(r, 2),
"\" in replace-expression");
return;
}
r += 2;
+4 -6
View File
@@ -2,7 +2,6 @@
file LICENSE.rst or https://cmake.org/licensing for details. */
#include "cmTargetTraceDependencies.h"
#include <sstream>
#include <utility>
#include <cmext/algorithm>
@@ -43,12 +42,11 @@ cmTargetTraceDependencies::cmTargetTraceDependencies(cmGeneratorTarget* target)
std::set<cmGeneratorTarget const*> const tgts =
this->GlobalGenerator->GetFilenameTargetDepends(sf);
if (cm::contains(tgts, this->GeneratorTarget)) {
std::ostringstream e;
e << "Evaluation output file\n \"" << sf->ResolveFullPath()
<< "\"\ndepends on the sources of a target it is used in. This "
"is a dependency loop and is not allowed.";
this->GeneratorTarget->LocalGenerator->IssueMessage(
MessageType::FATAL_ERROR, e.str());
MessageType::FATAL_ERROR,
cmStrCat("Evaluation output file\n \"", sf->ResolveFullPath(),
"\"\ndepends on the sources of a target it is used in. "
"This is a dependency loop and is not allowed."));
return;
}
if (emitted.insert(sf).second && this->SourcesQueued.insert(sf).second) {
+13 -10
View File
@@ -10,7 +10,6 @@
#include <cstdio>
#include <cstdlib>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <sstream>
@@ -2862,16 +2861,18 @@ int cmake::ActualConfigure()
// configure result
if (this->State->GetRole() == cmState::Role::Project) {
std::ostringstream msg;
std::string msg;
if (cmSystemTools::GetErrorOccurredFlag()) {
msg << "Configuring incomplete, errors occurred!";
msg = "Configuring incomplete, errors occurred!";
} else {
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
endTime - startTime);
msg << "Configuring done (" << std::fixed << std::setprecision(1)
<< ms.count() / 1000.0L << "s)";
msg.resize(128);
// NOLINTNEXTLINE(readability-container-data-pointer)
msg.resize(snprintf(&msg[0], msg.size(), "Configuring done (%.1fs)",
static_cast<double>(ms.count()) * 1e-3));
}
this->UpdateProgress(msg.str(), -1);
this->UpdateProgress(msg, -1);
}
#if !defined(CMAKE_BOOTSTRAP)
@@ -3346,10 +3347,12 @@ int cmake::Generate()
{
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(endTime -
startTime);
std::ostringstream msg;
msg << "Generating done (" << std::fixed << std::setprecision(1)
<< ms.count() / 1000.0L << "s)";
this->UpdateProgress(msg.str(), -1);
std::string msg;
msg.resize(128);
// NOLINTNEXTLINE(readability-container-data-pointer)
msg.resize(snprintf(&msg[0], msg.size(), "Generating done (%.1fs)",
static_cast<double>(ms.count()) * 1e-3));
this->UpdateProgress(msg, -1);
}
if (!this->GraphVizFile.empty()) {
std::cout << "Generate graphviz: " << this->GraphVizFile << '\n';