diff --git a/Source/cmExportCMakeConfigGenerator.cxx b/Source/cmExportCMakeConfigGenerator.cxx index 83bf0e8fb5..7228d206ca 100644 --- a/Source/cmExportCMakeConfigGenerator.cxx +++ b/Source/cmExportCMakeConfigGenerator.cxx @@ -127,13 +127,14 @@ void cmExportCMakeConfigGenerator::SetImportLinkInterface( if (!this->ExportOld) { cmLocalGenerator* lg = target->GetLocalGenerator(); - std::ostringstream e; - e << "Target \"" << target->GetName() - << "\" has policy CMP0022 enabled, " - "but also has old-style LINK_INTERFACE_LIBRARIES properties " - "populated, but it was exported without the " - "EXPORT_LINK_INTERFACE_LIBRARIES to export the old-style properties"; - lg->IssueMessage(MessageType::FATAL_ERROR, e.str()); + lg->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat( + "Target \"", target->GetName(), + "\" has policy CMP0022 enabled, " + "but also has old-style LINK_INTERFACE_LIBRARIES properties " + "populated, but it was exported without the " + "EXPORT_LINK_INTERFACE_LIBRARIES to export the old-style properties")); return; } diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index e2dd9a6865..c570b7784f 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -3,7 +3,6 @@ #include "cmExportCommand.h" #include -#include #include #include @@ -152,10 +151,9 @@ static bool HandleTargetsMode(std::vector const& args, } else { // Make sure the file has a .cmake extension. if (!cmHasSuffix(arguments.Filename, ".cmake"_s)) { - std::ostringstream e; - e << "FILE option given filename \"" << arguments.Filename - << "\" which does not have an extension of \".cmake\".\n"; - status.SetError(e.str()); + status.SetError( + cmStrCat("FILE option given filename \"", arguments.Filename, + "\" which does not have an extension of \".cmake\".\n")); return false; } fname = arguments.Filename; @@ -166,10 +164,8 @@ static bool HandleTargetsMode(std::vector const& args, // Get the file to write. if (cmSystemTools::FileIsFullPath(fname)) { if (!mf.CanIWriteThisFile(fname)) { - std::ostringstream e; - e << "FILE option given filename \"" << fname - << "\" which is in the source tree.\n"; - status.SetError(e.str()); + status.SetError(cmStrCat("FILE option given filename \"", fname, + "\" which is in the source tree.\n")); return false; } } else { @@ -297,10 +293,9 @@ static bool HandleExportMode(std::vector const& args, fname = arguments.ExportSetName + ".cmake"; } else { if (!cmHasSuffix(arguments.Filename, ".cmake"_s)) { - std::ostringstream e; - e << "FILE option given filename \"" << arguments.Filename - << "\" which does not have an extension of \".cmake\".\n"; - status.SetError(e.str()); + status.SetError( + cmStrCat("FILE option given filename \"", arguments.Filename, + "\" which does not have an extension of \".cmake\".\n")); return false; } fname = arguments.Filename; @@ -308,10 +303,8 @@ static bool HandleExportMode(std::vector const& args, if (cmSystemTools::FileIsFullPath(fname)) { if (!mf.CanIWriteThisFile(fname)) { - std::ostringstream e; - e << "FILE option given filename \"" << fname - << "\" which is in the source tree.\n"; - status.SetError(e.str()); + status.SetError(cmStrCat("FILE option given filename \"", fname, + "\" which is in the source tree.\n")); return false; } } else { @@ -607,9 +600,7 @@ static bool HandlePackageMode(std::vector const& args, package = args[i]; doing = DoingNone; } else { - std::ostringstream e; - e << "PACKAGE given unknown argument: " << args[i]; - status.SetError(e.str()); + status.SetError("PACKAGE given unknown argument: " + args[i]); return false; } } @@ -622,10 +613,9 @@ static bool HandlePackageMode(std::vector const& args, char const* packageExpr = "^[A-Za-z0-9_.-]+$"; cmsys::RegularExpression packageRegex(packageExpr); if (!packageRegex.find(package)) { - std::ostringstream e; - e << "PACKAGE given invalid package name \"" << package << "\". " - << "Package names must match \"" << packageExpr << "\"."; - status.SetError(e.str()); + status.SetError(cmStrCat("PACKAGE given invalid package name \"", package, + "\". Package names must match \"", packageExpr, + "\".")); return false; } @@ -665,17 +655,15 @@ static bool HandlePackageMode(std::vector const& args, static void ReportRegistryError(cmMakefile& mf, std::string const& msg, std::string const& key, long err) { - std::ostringstream e; - e << msg << "\n" - << " HKEY_CURRENT_USER\\" << key << "\n"; + std::string e = cmStrCat(msg, "\n HKEY_CURRENT_USER\\", key, '\n'); wchar_t winmsg[1024]; if (FormatMessageW( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), winmsg, 1024, 0) > 0) { - e << "Windows reported:\n" - << " " << cmsys::Encoding::ToNarrow(winmsg); + e = cmStrCat(std::move(e), "Windows reported:\n ", + cmsys::Encoding::ToNarrow(winmsg)); } - mf.IssueMessage(MessageType::WARNING, e.str()); + mf.IssueMessage(MessageType::WARNING, e); } static void StorePackageRegistry(cmMakefile& mf, std::string const& package, @@ -698,9 +686,9 @@ static void StorePackageRegistry(cmMakefile& mf, std::string const& package, static_cast(wcontent.size() + 1) * sizeof(wchar_t)); RegCloseKey(hKey); if (err != ERROR_SUCCESS) { - std::ostringstream msg; - msg << "Cannot set registry value \"" << hash << "\" under key"; - ReportRegistryError(mf, msg.str(), key, err); + ReportRegistryError( + mf, cmStrCat("Cannot set registry value \"", hash, "\" under key"), key, + err); return; } } diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 6d9c74e15e..c3b3b1531f 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -846,15 +845,7 @@ bool parse_default_directory_permissions(std::string const& permissions, return false; } - std::ostringstream oss; - for (auto i = 0u; i < parsedPermissions.size(); i++) { - if (i != 0) { - oss << ';'; - } - oss << parsedPermissions[i]; - } - - parsedPermissionsVar = oss.str(); + parsedPermissionsVar = cmJoin(parsedPermissions, ";"); return true; }