summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorAsit Dhal <dhal.asitk@gmail.com>2019-09-15 19:11:02 +0200
committerBrad King <brad.king@kitware.com>2019-09-18 14:18:46 -0400
commit9dba84cfa5e85e51ee6d6799f03a26656063ef8b (patch)
tree22fb29536def399e2ab763ac202a52467d45d7e2 /Source
parent1423507a71199fd76b457ad9b215a6caca70ee58 (diff)
downloadcmake-9dba84cfa5e85e51ee6d6799f03a26656063ef8b.tar.gz
Refactor: Use cmStrCat to construct error strings
Replace string construction using std::stringstream with cmStrCat and cmWrap.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmAddCustomCommandCommand.cxx13
-rw-r--r--Source/cmAddCustomTargetCommand.cxx16
-rw-r--r--Source/cmAddDependenciesCommand.cxx30
-rw-r--r--Source/cmAddExecutableCommand.cxx38
-rw-r--r--Source/cmAddLibraryCommand.cxx62
-rw-r--r--Source/cmAddSubDirectoryCommand.cxx15
-rw-r--r--Source/cmAddTestCommand.cxx19
-rw-r--r--Source/cmCMakePolicyCommand.cxx47
-rw-r--r--Source/cmConfigureFileCommand.cxx12
-rw-r--r--Source/cmFileCommand.cxx261
-rw-r--r--Source/cmFindPackageCommand.cxx45
-rw-r--r--Source/cmForEachCommand.cxx15
-rw-r--r--Source/cmGetPropertyCommand.cxx36
-rw-r--r--Source/cmInstallCommand.cxx314
-rw-r--r--Source/cmListCommand.cxx111
-rw-r--r--Source/cmLoadCommandCommand.cxx7
-rw-r--r--Source/cmOptionCommand.cxx16
-rw-r--r--Source/cmOrderDirectories.cxx14
-rw-r--r--Source/cmProjectCommand.cxx9
-rw-r--r--Source/cmSeparateArgumentsCommand.cxx6
-rw-r--r--Source/cmSetPropertyCommand.cxx56
-rw-r--r--Source/cmStringCommand.cxx32
-rw-r--r--Source/cmTargetCompileDefinitionsCommand.cxx11
-rw-r--r--Source/cmTargetCompileFeaturesCommand.cxx11
-rw-r--r--Source/cmTargetCompileOptionsCommand.cxx10
-rw-r--r--Source/cmTargetIncludeDirectoriesCommand.cxx9
-rw-r--r--Source/cmTargetLinkDirectoriesCommand.cxx10
-rw-r--r--Source/cmTargetLinkLibrariesCommand.cxx74
-rw-r--r--Source/cmTargetLinkOptionsCommand.cxx10
-rw-r--r--Source/cmTargetSourcesCommand.cxx9
-rw-r--r--Source/cmVariableWatchCommand.cxx24
31 files changed, 545 insertions, 797 deletions
diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx
index c91198c915..35db6a47ec 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -321,10 +321,9 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
}
// No command for this output exists.
- std::ostringstream e;
- e << "given APPEND option with output\n\"" << output[0]
- << "\"\nwhich is not already a custom command output.";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("given APPEND option with output\n\"", output[0],
+ "\"\nwhich is not already a custom command output."));
return false;
}
@@ -407,10 +406,8 @@ bool cmAddCustomCommandCommandCheckOutputs(
// Make sure the output file name has no invalid characters.
std::string::size_type pos = o.find_first_of("#<>");
if (pos != std::string::npos) {
- std::ostringstream msg;
- msg << "called with OUTPUT containing a \"" << o[pos]
- << "\". This character is not allowed.";
- status.SetError(msg.str());
+ status.SetError(cmStrCat("called with OUTPUT containing a \"", o[pos],
+ "\". This character is not allowed."));
return false;
}
}
diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx
index ec5c1a73b5..9fd1234145 100644
--- a/Source/cmAddCustomTargetCommand.cxx
+++ b/Source/cmAddCustomTargetCommand.cxx
@@ -2,7 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAddCustomTargetCommand.h"
-#include <sstream>
#include <utility>
#include "cmCustomCommandLines.h"
@@ -29,11 +28,9 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args,
// Check the target name.
if (targetName.find_first_of("/\\") != std::string::npos) {
- std::ostringstream e;
- e << "called with invalid target name \"" << targetName
- << "\". Target names may not contain a slash. "
- << "Use ADD_CUSTOM_COMMAND to generate files.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("called with invalid target name \"", targetName,
+ "\". Target names may not contain a slash. "
+ "Use ADD_CUSTOM_COMMAND to generate files."));
return false;
}
@@ -153,10 +150,9 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args,
std::string::size_type pos = targetName.find_first_of("#<>");
if (pos != std::string::npos) {
- std::ostringstream msg;
- msg << "called with target name containing a \"" << targetName[pos]
- << "\". This character is not allowed.";
- status.SetError(msg.str());
+ status.SetError(cmStrCat("called with target name containing a \"",
+ targetName[pos],
+ "\". This character is not allowed."));
return false;
}
diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx
index 0ddbda852e..b1fc89341f 100644
--- a/Source/cmAddDependenciesCommand.cxx
+++ b/Source/cmAddDependenciesCommand.cxx
@@ -2,12 +2,11 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAddDependenciesCommand.h"
-#include <sstream>
-
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmRange.h"
+#include "cmStringAlgorithms.h"
#include "cmTarget.h"
bool cmAddDependenciesCommand(std::vector<std::string> const& args,
@@ -21,10 +20,10 @@ bool cmAddDependenciesCommand(std::vector<std::string> const& args,
cmMakefile& mf = status.GetMakefile();
std::string const& target_name = args[0];
if (mf.IsAlias(target_name)) {
- std::ostringstream e;
- e << "Cannot add target-level dependencies to alias target \""
- << target_name << "\".\n";
- mf.IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot add target-level dependencies to alias target \"",
+ target_name, "\".\n"));
}
if (cmTarget* target = mf.FindTargetToUse(target_name)) {
@@ -33,14 +32,17 @@ bool cmAddDependenciesCommand(std::vector<std::string> const& args,
target->AddUtility(arg, &mf);
}
} else {
- std::ostringstream e;
- e << "Cannot add target-level dependencies to non-existent target \""
- << target_name << "\".\n"
- << "The add_dependencies works for top-level logical targets created "
- << "by the add_executable, add_library, or add_custom_target commands. "
- << "If you want to add file-level dependencies see the DEPENDS option "
- << "of the add_custom_target and add_custom_command commands.";
- mf.IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat(
+ "Cannot add target-level dependencies to non-existent "
+ "target \"",
+ target_name,
+ "\".\nThe add_dependencies works for "
+ "top-level logical targets created by the add_executable, "
+ "add_library, or add_custom_target commands. If you want to add "
+ "file-level dependencies see the DEPENDS option of the "
+ "add_custom_target and add_custom_command commands."));
}
return true;
diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx
index 1a870284ac..e738bc467f 100644
--- a/Source/cmAddExecutableCommand.cxx
+++ b/Source/cmAddExecutableCommand.cxx
@@ -2,13 +2,12 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAddExecutableCommand.h"
-#include <sstream>
-
#include "cmExecutionStatus.h"
#include "cmGeneratorExpression.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmTarget.h"
bool cmAddExecutableCommand(std::vector<std::string> const& args,
@@ -99,34 +98,30 @@ bool cmAddExecutableCommand(std::vector<std::string> const& args,
std::string const& aliasedName = *s;
if (mf.IsAlias(aliasedName)) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << exename << "\" because target \""
- << aliasedName << "\" is itself an ALIAS.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("cannot create ALIAS target \"", exename,
+ "\" because target \"", aliasedName,
+ "\" is itself an ALIAS."));
return false;
}
cmTarget* aliasedTarget = mf.FindTargetToUse(aliasedName, true);
if (!aliasedTarget) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << exename << "\" because target \""
- << aliasedName << "\" does not already exist.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("cannot create ALIAS target \"", exename,
+ "\" because target \"", aliasedName,
+ "\" does not already exist."));
return false;
}
cmStateEnums::TargetType type = aliasedTarget->GetType();
if (type != cmStateEnums::EXECUTABLE) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << exename << "\" because target \""
- << aliasedName << "\" is not an executable.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("cannot create ALIAS target \"", exename,
+ "\" because target \"", aliasedName,
+ "\" is not an executable."));
return false;
}
if (aliasedTarget->IsImported() &&
!aliasedTarget->IsImportedGloballyVisible()) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << exename << "\" because target \""
- << aliasedName << "\" is imported but not globally visible.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("cannot create ALIAS target \"", exename,
+ "\" because target \"", aliasedName,
+ "\" is imported but not globally visible."));
return false;
}
mf.AddAlias(exename, aliasedName);
@@ -137,10 +132,9 @@ bool cmAddExecutableCommand(std::vector<std::string> const& args,
if (importTarget) {
// Make sure the target does not already exist.
if (mf.FindTargetToUse(exename)) {
- std::ostringstream e;
- e << "cannot create imported target \"" << exename
- << "\" because another target with the same name already exists.";
- status.SetError(e.str());
+ status.SetError(cmStrCat(
+ "cannot create imported target \"", exename,
+ "\" because another target with the same name already exists."));
return false;
}
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index dc8937a6a0..0439c518c0 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -2,8 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAddLibraryCommand.h"
-#include <sstream>
-
#include "cmAlgorithms.h"
#include "cmExecutionStatus.h"
#include "cmGeneratorExpression.h"
@@ -184,20 +182,16 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args,
std::string const& aliasedName = *s;
if (mf.IsAlias(aliasedName)) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << libName << "\" because target \""
- << aliasedName << "\" is itself an ALIAS.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("cannot create ALIAS target \"", libName,
+ "\" because target \"", aliasedName,
+ "\" is itself an ALIAS."));
return false;
}
cmTarget* aliasedTarget = mf.FindTargetToUse(aliasedName, true);
if (!aliasedTarget) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << libName << "\" because target \""
- << aliasedName
- << "\" does not already "
- "exist.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("cannot create ALIAS target \"", libName,
+ "\" because target \"", aliasedName,
+ "\" does not already exist."));
return false;
}
cmStateEnums::TargetType aliasedType = aliasedTarget->GetType();
@@ -208,18 +202,16 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args,
aliasedType != cmStateEnums::INTERFACE_LIBRARY &&
!(aliasedType == cmStateEnums::UNKNOWN_LIBRARY &&
aliasedTarget->IsImported())) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << libName << "\" because target \""
- << aliasedName << "\" is not a library.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("cannot create ALIAS target \"", libName,
+ "\" because target \"", aliasedName,
+ "\" is not a library."));
return false;
}
if (aliasedTarget->IsImported() &&
!aliasedTarget->IsImportedGloballyVisible()) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << libName << "\" because target \""
- << aliasedName << "\" is imported but not globally visible.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("cannot create ALIAS target \"", libName,
+ "\" because target \"", aliasedName,
+ "\" is imported but not globally visible."));
return false;
}
mf.AddAlias(libName, aliasedName);
@@ -238,12 +230,13 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args,
if ((type == cmStateEnums::SHARED_LIBRARY ||
type == cmStateEnums::MODULE_LIBRARY) &&
!mf.GetState()->GetGlobalPropertyAsBool("TARGET_SUPPORTS_SHARED_LIBS")) {
- std::ostringstream w;
- w << "ADD_LIBRARY called with "
- << (type == cmStateEnums::SHARED_LIBRARY ? "SHARED" : "MODULE")
- << " option but the target platform does not support dynamic linking. "
- "Building a STATIC library instead. This may lead to problems.";
- mf.IssueMessage(MessageType::AUTHOR_WARNING, w.str());
+ mf.IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmStrCat(
+ "ADD_LIBRARY called with ",
+ (type == cmStateEnums::SHARED_LIBRARY ? "SHARED" : "MODULE"),
+ " option but the target platform does not support dynamic linking. ",
+ "Building a STATIC library instead. This may lead to problems."));
type = cmStateEnums::STATIC_LIBRARY;
}
@@ -266,19 +259,17 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args,
}
if (type == cmStateEnums::INTERFACE_LIBRARY) {
if (!cmGeneratorExpression::IsValidTargetName(libName)) {
- std::ostringstream e;
- e << "Invalid name for IMPORTED INTERFACE library target: " << libName;
- status.SetError(e.str());
+ status.SetError(cmStrCat(
+ "Invalid name for IMPORTED INTERFACE library target: ", libName));
return false;
}
}
// Make sure the target does not already exist.
if (mf.FindTargetToUse(libName)) {
- std::ostringstream e;
- e << "cannot create imported target \"" << libName
- << "\" because another target with the same name already exists.";
- status.SetError(e.str());
+ status.SetError(cmStrCat(
+ "cannot create imported target \"", libName,
+ "\" because another target with the same name already exists."));
return false;
}
@@ -309,9 +300,8 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args,
if (type == cmStateEnums::INTERFACE_LIBRARY) {
if (!cmGeneratorExpression::IsValidTargetName(libName) ||
libName.find("::") != std::string::npos) {
- std::ostringstream e;
- e << "Invalid name for INTERFACE library target: " << libName;
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("Invalid name for INTERFACE library target: ", libName));
return false;
}
diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx
index c0be308e3a..6a1a514f76 100644
--- a/Source/cmAddSubDirectoryCommand.cxx
+++ b/Source/cmAddSubDirectoryCommand.cxx
@@ -3,7 +3,6 @@
#include "cmAddSubDirectoryCommand.h"
#include <cstring>
-#include <sstream>
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
@@ -64,13 +63,13 @@ bool cmAddSubDirectoryCommand(std::vector<std::string> const& args,
// error.
if (!cmSystemTools::IsSubDirectory(srcPath,
mf.GetCurrentSourceDirectory())) {
- std::ostringstream e;
- e << "not given a binary directory but the given source directory "
- << "\"" << srcPath << "\" is not a subdirectory of \""
- << mf.GetCurrentSourceDirectory() << "\". "
- << "When specifying an out-of-tree source a binary directory "
- << "must be explicitly specified.";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("not given a binary directory but the given source ",
+ "directory \"", srcPath, "\" is not a subdirectory of \"",
+ mf.GetCurrentSourceDirectory(),
+ "\". When specifying an "
+ "out-of-tree source a binary directory must be explicitly "
+ "specified."));
return false;
}
diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx
index 7904bf5c55..89421131ab 100644
--- a/Source/cmAddTestCommand.cxx
+++ b/Source/cmAddTestCommand.cxx
@@ -2,10 +2,9 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAddTestCommand.h"
-#include <sstream>
-
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
#include "cmTest.h"
#include "cmTestGenerator.h"
@@ -38,10 +37,8 @@ bool cmAddTestCommand(std::vector<std::string> const& args,
// If the test was already added by a new-style signature do not
// allow it to be duplicated.
if (!test->GetOldStyle()) {
- std::ostringstream e;
- e << " given test name \"" << args[0]
- << "\" which already exists in this directory.";
- status.SetError(e.str());
+ status.SetError(cmStrCat(" given test name \"", args[0],
+ "\" which already exists in this directory."));
return false;
}
} else {
@@ -110,9 +107,7 @@ bool cmAddTestCommandHandleNameMode(std::vector<std::string> const& args,
working_directory = args[i];
doing = DoingNone;
} else {
- std::ostringstream e;
- e << " given unknown argument:\n " << args[i] << "\n";
- status.SetError(e.str());
+ status.SetError(cmStrCat(" given unknown argument:\n ", args[i], "\n"));
return false;
}
}
@@ -133,10 +128,8 @@ bool cmAddTestCommandHandleNameMode(std::vector<std::string> const& args,
// Require a unique test name within the directory.
if (mf.GetTest(name)) {
- std::ostringstream e;
- e << " given test NAME \"" << name
- << "\" which already exists in this directory.";
- status.SetError(e.str());
+ status.SetError(cmStrCat(" given test NAME \"", name,
+ "\" which already exists in this directory."));
return false;
}
diff --git a/Source/cmCMakePolicyCommand.cxx b/Source/cmCMakePolicyCommand.cxx
index 9b1aea9f33..b7f08d2dd0 100644
--- a/Source/cmCMakePolicyCommand.cxx
+++ b/Source/cmCMakePolicyCommand.cxx
@@ -2,14 +2,13 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCMakePolicyCommand.h"
-#include <sstream>
-
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmState.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
namespace {
bool HandleSetMode(std::vector<std::string> const& args,
@@ -60,9 +59,7 @@ bool cmCMakePolicyCommand(std::vector<std::string> const& args,
return HandleGetWarningMode(args, status);
}
- std::ostringstream e;
- e << "given unknown first argument \"" << args[0] << "\"";
- status.SetError(e.str());
+ status.SetError(cmStrCat("given unknown first argument \"", args[0], "\""));
return false;
}
@@ -82,9 +79,8 @@ bool HandleSetMode(std::vector<std::string> const& args,
} else if (args[2] == "NEW") {
policyStatus = cmPolicies::NEW;
} else {
- std::ostringstream e;
- e << "SET given unrecognized policy status \"" << args[2] << "\"";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("SET given unrecognized policy status \"", args[2], "\""));
return false;
}
@@ -128,10 +124,9 @@ bool HandleGetMode(std::vector<std::string> const& args,
// Lookup the policy number.
cmPolicies::PolicyID pid;
if (!cmPolicies::GetPolicyID(id.c_str(), pid)) {
- std::ostringstream e;
- e << "GET given policy \"" << id << "\" which is not known to this "
- << "version of CMake.";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("GET given policy \"", id,
+ "\" which is not known to this version of CMake."));
return false;
}
@@ -155,12 +150,14 @@ bool HandleGetMode(std::vector<std::string> const& args,
case cmPolicies::REQUIRED_ALWAYS:
// The policy is required to be set before anything needs it.
{
- std::ostringstream e;
- e << cmPolicies::GetRequiredPolicyError(pid) << "\n"
- << "The call to cmake_policy(GET " << id << " ...) at which this "
- << "error appears requests the policy, and this version of CMake "
- << "requires that the policy be set to NEW before it is checked.";
- status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat(
+ cmPolicies::GetRequiredPolicyError(pid), "\n",
+ "The call to cmake_policy(GET ", id,
+ " ...) at which this "
+ "error appears requests the policy, and this version of CMake ",
+ "requires that the policy be set to NEW before it is checked."));
}
}
@@ -188,10 +185,9 @@ bool HandleVersionMode(std::vector<std::string> const& args,
: std::string();
if (dd != std::string::npos &&
(version_min.empty() || version_max.empty())) {
- std::ostringstream e;
- e << "VERSION \"" << version_string
- << R"(" does not have a version on both sides of "...".)";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("VERSION \"", version_string,
+ R"(" does not have a version on both sides of "...".)"));
return false;
}
@@ -215,10 +211,9 @@ bool HandleGetWarningMode(std::vector<std::string> const& args,
// Lookup the policy number.
cmPolicies::PolicyID pid;
if (!cmPolicies::GetPolicyID(id.c_str(), pid)) {
- std::ostringstream e;
- e << "GET_WARNING given policy \"" << id
- << "\" which is not known to this version of CMake.";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("GET_WARNING given policy \"", id,
+ "\" which is not known to this version of CMake."));
return false;
}
diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx
index 7e37f32124..8767386cff 100644
--- a/Source/cmConfigureFileCommand.cxx
+++ b/Source/cmConfigureFileCommand.cxx
@@ -2,8 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmConfigureFileCommand.h"
-#include <sstream>
-
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
@@ -26,13 +24,9 @@ bool cmConfigureFileCommand(std::vector<std::string> const& args,
// If the input location is a directory, error out.
if (cmSystemTools::FileIsDirectory(inputFile)) {
- std::ostringstream e;
- /* clang-format off */
- e << "input location\n"
- << " " << inputFile << "\n"
- << "is a directory but a file was expected.";
- /* clang-format on */
- status.SetError(e.str());
+ status.SetError(cmStrCat("input location\n ", inputFile,
+ "\n"
+ "is a directory but a file was expected."));
return false;
}
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 33acd05b1e..4701d29d01 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -274,9 +274,8 @@ bool HandleHashCommand(std::vector<std::string> const& args,
{
#if !defined(CMAKE_BOOTSTRAP)
if (args.size() != 3) {
- std::ostringstream e;
- e << args[0] << " requires a file name and output variable";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat(args[0], " requires a file name and output variable"));
return false;
}
@@ -287,16 +286,12 @@ bool HandleHashCommand(std::vector<std::string> const& args,
status.GetMakefile().AddDefinition(args[2], out);
return true;
}
- std::ostringstream e;
- e << args[0] << " failed to read file \"" << args[1]
- << "\": " << cmSystemTools::GetLastSystemError();
- status.SetError(e.str());
+ status.SetError(cmStrCat(args[0], " failed to read file \"", args[1],
+ "\": ", cmSystemTools::GetLastSystemError()));
}
return false;
#else
- std::ostringstream e;
- e << args[0] << " not available during bootstrap";
- status.SetError(e.str());
+ status.SetError(cmStrCat(args[0], " not available during bootstrap"));
return false;
#endif
}
@@ -376,30 +371,24 @@ bool HandleStringsCommand(std::vector<std::string> const& args,
} else if (arg_mode == arg_limit_input) {
if (sscanf(args[i].c_str(), "%d", &limit_input) != 1 ||
limit_input < 0) {
- std::ostringstream e;
- e << "STRINGS option LIMIT_INPUT value \"" << args[i]
- << "\" is not an unsigned integer.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("STRINGS option LIMIT_INPUT value \"",
+ args[i], "\" is not an unsigned integer."));
return false;
}
arg_mode = arg_none;
} else if (arg_mode == arg_limit_output) {
if (sscanf(args[i].c_str(), "%d", &limit_output) != 1 ||
limit_output < 0) {
- std::ostringstream e;
- e << "STRINGS option LIMIT_OUTPUT value \"" << args[i]
- << "\" is not an unsigned integer.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("STRINGS option LIMIT_OUTPUT value \"",
+ args[i], "\" is not an unsigned integer."));
return false;
}
arg_mode = arg_none;
} else if (arg_mode == arg_limit_count) {
int count;
if (sscanf(args[i].c_str(), "%d", &count) != 1 || count < 0) {
- std::ostringstream e;
- e << "STRINGS option LIMIT_COUNT value \"" << args[i]
- << "\" is not an unsigned integer.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("STRINGS option LIMIT_COUNT value \"",
+ args[i], "\" is not an unsigned integer."));
return false;
}
limit_count = count;
@@ -407,10 +396,8 @@ bool HandleStringsCommand(std::vector<std::string> const& args,
} else if (arg_mode == arg_length_minimum) {
int len;
if (sscanf(args[i].c_str(), "%d", &len) != 1 || len < 0) {
- std::ostringstream e;
- e << "STRINGS option LENGTH_MINIMUM value \"" << args[i]
- << "\" is not an unsigned integer.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("STRINGS option LENGTH_MINIMUM value \"",
+ args[i], "\" is not an unsigned integer."));
return false;
}
minlen = len;
@@ -418,20 +405,16 @@ bool HandleStringsCommand(std::vector<std::string> const& args,
} else if (arg_mode == arg_length_maximum) {
int len;
if (sscanf(args[i].c_str(), "%d", &len) != 1 || len < 0) {
- std::ostringstream e;
- e << "STRINGS option LENGTH_MAXIMUM value \"" << args[i]
- << "\" is not an unsigned integer.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("STRINGS option LENGTH_MAXIMUM value \"",
+ args[i], "\" is not an unsigned integer."));
return false;
}
maxlen = len;
arg_mode = arg_none;
} else if (arg_mode == arg_regex) {
if (!regex.compile(args[i])) {
- std::ostringstream e;
- e << "STRINGS option REGEX value \"" << args[i]
- << "\" could not be compiled.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("STRINGS option REGEX value \"", args[i],
+ "\" could not be compiled."));
return false;
}
have_regex = true;
@@ -448,16 +431,14 @@ bool HandleStringsCommand(std::vector<std::string> const& args,
} else if (args[i] == "UTF-32BE") {
encoding = encoding_utf32be;
} else {
- std::ostringstream e;
- e << "STRINGS option ENCODING \"" << args[i] << "\" not recognized.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("STRINGS option ENCODING \"", args[i],
+ "\" not recognized."));
return false;
}
arg_mode = arg_none;
} else {
- std::ostringstream e;
- e << "STRINGS given unknown argument \"" << args[i] << "\"";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("STRINGS given unknown argument \"", args[i], "\""));
return false;
}
}
@@ -479,9 +460,8 @@ bool HandleStringsCommand(std::vector<std::string> const& args,
cmsys::ifstream fin(fileName.c_str());
#endif
if (!fin) {
- std::ostringstream e;
- e << "STRINGS file \"" << fileName << "\" cannot be read.";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("STRINGS file \"", fileName, "\" cannot be read."));
return false;
}
@@ -963,9 +943,7 @@ bool HandleDifferentCommand(std::vector<std::string> const& args,
file_rhs = args[i].c_str();
doing = DoingNone;
} else {
- std::ostringstream e;
- e << "DIFFERENT given unknown argument " << args[i];
- status.SetError(e.str());
+ status.SetError(cmStrCat("DIFFERENT given unknown argument ", args[i]));
return false;
}
}
@@ -1027,9 +1005,8 @@ bool HandleRPathChangeCommand(std::vector<std::string> const& args,
newRPath = args[i].c_str();
doing = DoingNone;
} else {
- std::ostringstream e;
- e << "RPATH_CHANGE given unknown argument " << args[i];
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("RPATH_CHANGE given unknown argument ", args[i]));
return false;
}
}
@@ -1046,9 +1023,8 @@ bool HandleRPathChangeCommand(std::vector<std::string> const& args,
return false;
}
if (!cmSystemTools::FileExists(file, true)) {
- std::ostringstream e;
- e << "RPATH_CHANGE given FILE \"" << file << "\" that does not exist.";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("RPATH_CHANGE given FILE \"", file, "\" that does not exist."));
return false;
}
bool success = true;
@@ -1058,15 +1034,9 @@ bool HandleRPathChangeCommand(std::vector<std::string> const& args,
if (!cmSystemTools::ChangeRPath(file, oldRPath, newRPath,
removeEnvironmentRPath, &emsg, &changed)) {
- std::ostringstream e;
- /* clang-format off */
- e << "RPATH_CHANGE could not write new RPATH:\n"
- << " " << newRPath << "\n"
- << "to the file:\n"
- << " " << file << "\n"
- << emsg;
- /* clang-format on */
- status.SetError(e.str());
+ status.SetError(cmStrCat("RPATH_CHANGE could not write new RPATH:\n ",
+ newRPath, "\nto the file:\n ", file, "\n",
+ emsg));
success = false;
}
if (success) {
@@ -1098,9 +1068,8 @@ bool HandleRPathRemoveCommand(std::vector<std::string> const& args,
file = args[i];
doing = DoingNone;
} else {
- std::ostringstream e;
- e << "RPATH_REMOVE given unknown argument " << args[i];
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("RPATH_REMOVE given unknown argument ", args[i]));
return false;
}
}
@@ -1109,9 +1078,8 @@ bool HandleRPathRemoveCommand(std::vector<std::string> const& args,
return false;
}
if (!cmSystemTools::FileExists(file, true)) {
- std::ostringstream e;
- e << "RPATH_REMOVE given FILE \"" << file << "\" that does not exist.";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("RPATH_REMOVE given FILE \"", file, "\" that does not exist."));
return false;
}
bool success = true;
@@ -1119,13 +1087,9 @@ bool HandleRPathRemoveCommand(std::vector<std::string> const& args,
std::string emsg;
bool removed;
if (!cmSystemTools::RemoveRPath(file, &emsg, &removed)) {
- std::ostringstream e;
- /* clang-format off */
- e << "RPATH_REMOVE could not remove RPATH from file:\n"
- << " " << file << "\n"
- << emsg;
- /* clang-format on */
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("RPATH_REMOVE could not remove RPATH from file: \n ", file,
+ "\n", emsg));
success = false;
}
if (success) {
@@ -1164,9 +1128,8 @@ bool HandleRPathCheckCommand(std::vector<std::string> const& args,
rpath = args[i].c_str();
doing = DoingNone;
} else {
- std::ostringstream e;
- e << "RPATH_CHECK given unknown argument " << args[i];
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("RPATH_CHECK given unknown argument ", args[i]));
return false;
}
}
@@ -1215,9 +1178,8 @@ bool HandleReadElfCommand(std::vector<std::string> const& args,
Arguments const arguments = parser.Parse(cmMakeRange(args).advance(2));
if (!cmSystemTools::FileExists(fileNameArg, true)) {
- std::ostringstream e;
- e << "READ_ELF given FILE \"" << fileNameArg << "\" that does not exist.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("READ_ELF given FILE \"", fileNameArg,
+ "\" that does not exist."));
return false;
}
@@ -1311,15 +1273,8 @@ bool HandleRename(std::vector<std::string> const& args,
if (!cmSystemTools::RenameFile(oldname, newname)) {
std::string err = cmSystemTools::GetLastSystemError();
- std::ostringstream e;
- /* clang-format off */
- e << "RENAME failed to rename\n"
- << " " << oldname << "\n"
- << "to\n"
- << " " << newname << "\n"
- << "because: " << err << "\n";
- /* clang-format on */
- status.SetError(e.str());
+ status.SetError(cmStrCat("RENAME failed to rename\n ", oldname,
+ "\nto\n ", newname, "\nbecause: ", err, "\n"));
return false;
}
return true;
@@ -1494,10 +1449,8 @@ public:
bool updated = (OldPercentage != this->CurrentPercentage);
if (updated) {
- std::ostringstream oss;
- oss << "[" << this->Text << " " << this->CurrentPercentage
- << "% complete]";
- status = oss.str();
+ status =
+ cmStrCat("[", this->Text, " ", this->CurrentPercentage, "% complete]");
}
return updated;
@@ -1743,9 +1696,7 @@ bool HandleDownloadCommand(std::vector<std::string> const& args,
msg = cmStrCat("returning early; file already exists with expected ",
hashMatchMSG, '"');
if (!statusVar.empty()) {
- std::ostringstream result;
- result << 0 << ";\"" << msg;
- status.GetMakefile().AddDefinition(statusVar, result.str());
+ status.GetMakefile().AddDefinition(statusVar, cmStrCat(0, ";\"", msg));
}
return true;
}
@@ -1891,10 +1842,9 @@ bool HandleDownloadCommand(std::vector<std::string> const& args,
::curl_easy_cleanup(curl);
if (!statusVar.empty()) {
- std::ostringstream result;
- result << static_cast<int>(res) << ";\"" << ::curl_easy_strerror(res)
- << "\"";
- status.GetMakefile().AddDefinition(statusVar, result.str());
+ status.GetMakefile().AddDefinition(
+ statusVar,
+ cmStrCat(static_cast<int>(res), ";\"", ::curl_easy_strerror(res), "\""));
}
::curl_global_cleanup();
@@ -1914,14 +1864,6 @@ bool HandleDownloadCommand(std::vector<std::string> const& args,
}
if (expectedHash != actualHash) {
- std::ostringstream oss;
- oss << "DOWNLOAD HASH mismatch" << std::endl
- << " for file: [" << file << "]" << std::endl
- << " expected hash: [" << expectedHash << "]" << std::endl
- << " actual hash: [" << actualHash << "]" << std::endl
- << " status: [" << static_cast<int>(res) << ";\""
- << ::curl_easy_strerror(res) << "\"]" << std::endl;
-
if (!statusVar.empty() && res == 0) {
status.GetMakefile().AddDefinition(statusVar,
"1;HASH mismatch: "
@@ -1930,7 +1872,19 @@ bool HandleDownloadCommand(std::vector<std::string> const& args,
" actual: " + actualHash);
}
- status.SetError(oss.str());
+ status.SetError(cmStrCat("DOWNLOAD HASH mismatch\n"
+ " for file: [",
+ file,
+ "]\n"
+ " expected hash: [",
+ expectedHash,
+ "]\n"
+ " actual hash: [",
+ actualHash,
+ "]\n"
+ " status: [",
+ static_cast<int>(res), ";\"",
+ ::curl_easy_strerror(res), "\"]\n"));
return false;
}
}
@@ -2180,10 +2134,9 @@ bool HandleUploadCommand(std::vector<std::string> const& args,
::curl_easy_cleanup(curl);
if (!statusVar.empty()) {
- std::ostringstream result;
- result << static_cast<int>(res) << ";\"" << ::curl_easy_strerror(res)
- << "\"";
- status.GetMakefile().AddDefinition(statusVar, result.str());
+ status.GetMakefile().AddDefinition(
+ statusVar,
+ cmStrCat(static_cast<int>(res), ";\"", ::curl_easy_strerror(res), "\""));
}
::curl_global_cleanup();
@@ -2322,9 +2275,9 @@ bool HandleLockCommand(std::vector<std::string> const& args,
} else if (args[i] == "PROCESS") {
guard = GUARD_PROCESS;
} else {
- std::ostringstream e;
- e << merr << ", but got:\n \"" << args[i] << "\".";
- status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat(merr, ", but got:\n \"", args[i], "\"."));
return false;
}
@@ -2346,17 +2299,18 @@ bool HandleLockCommand(std::vector<std::string> const& args,
}
long scanned;
if (!cmStrToLong(args[i], &scanned) || scanned < 0) {
- std::ostringstream e;
- e << "TIMEOUT value \"" << args[i] << "\" is not an unsigned integer.";
- status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("TIMEOUT value \"", args[i],
+ "\" is not an unsigned integer."));
return false;
}
timeout = static_cast<unsigned long>(scanned);
} else {
- std::ostringstream e;
- e << "expected DIRECTORY, RELEASE, GUARD, RESULT_VARIABLE or TIMEOUT\n";
- e << "but got: \"" << args[i] << "\".";
- status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("expected DIRECTORY, RELEASE, GUARD, RESULT_VARIABLE or ",
+ "TIMEOUT\nbut got: \"", args[i], "\"."));
return false;
}
}
@@ -2375,18 +2329,19 @@ bool HandleLockCommand(std::vector<std::string> const& args,
// Create file and directories if needed
std::string parentDir = cmSystemTools::GetParentDirectory(path);
if (!cmSystemTools::MakeDirectory(parentDir)) {
- std::ostringstream e;
- e << "directory\n \"" << parentDir << "\"\ncreation failed ";
- e << "(check permissions).";
- status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("directory\n \"", parentDir,
+ "\"\ncreation failed (check permissions)."));
cmSystemTools::SetFatalErrorOccured();
return false;
}
FILE* file = cmsys::SystemTools::Fopen(path, "w");
if (!file) {
- std::ostringstream e;
- e << "file\n \"" << path << "\"\ncreation failed (check permissions).";
- status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("file\n \"", path,
+ "\"\ncreation failed (check permissions)."));
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -2419,9 +2374,9 @@ bool HandleLockCommand(std::vector<std::string> const& args,
const std::string result = fileLockResult.GetOutputMessage();
if (resultVariable.empty() && !fileLockResult.IsOk()) {
- std::ostringstream e;
- e << "error locking file\n \"" << path << "\"\n" << result << ".";
- status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("error locking file\n \"", path, "\"\n", result, "."));
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -2485,9 +2440,8 @@ bool HandleSizeCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
if (args.size() != 3) {
- std::ostringstream e;
- e << args[0] << " requires a file name and output variable";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat(args[0], " requires a file name and output variable"));
return false;
}
@@ -2498,9 +2452,8 @@ bool HandleSizeCommand(std::vector<std::string> const& args,
const std::string& outputVariable = args[argsIndex++];
if (!cmSystemTools::FileExists(filename, true)) {
- std::ostringstream e;
- e << "SIZE requested of path that is not readable:\n " << filename;
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("SIZE requested of path that is not readable:\n ", filename));
return false;
}
@@ -2514,9 +2467,8 @@ bool HandleReadSymlinkCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
if (args.size() != 3) {
- std::ostringstream e;
- e << args[0] << " requires a file name and output variable";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat(args[0], " requires a file name and output variable"));
return false;
}
@@ -2525,10 +2477,8 @@ bool HandleReadSymlinkCommand(std::vector<std::string> const& args,
std::string result;
if (!cmSystemTools::ReadSymlink(filename, result)) {
- std::ostringstream e;
- e << "READ_SYMLINK requested of path that is not a symlink:\n "
- << filename;
- status.SetError(e.str());
+ status.SetError(cmStrCat(
+ "READ_SYMLINK requested of path that is not a symlink:\n ", filename));
return false;
}
@@ -2655,10 +2605,9 @@ bool HandleGetRuntimeDependenciesCommand(std::vector<std::string> const& args,
std::string platform =
status.GetMakefile().GetSafeDefinition("CMAKE_HOST_SYSTEM_NAME");
if (!supportedPlatforms.count(platform)) {
- std::ostringstream e;
- e << "GET_RUNTIME_DEPENDENCIES is not supported on system \"" << platform
- << "\"";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("GET_RUNTIME_DEPENDENCIES is not supported on system \"",
+ platform, "\""));
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -2718,17 +2667,13 @@ bool HandleGetRuntimeDependenciesCommand(std::vector<std::string> const& args,
&keywordsMissingValues);
auto argIt = unrecognizedArguments.begin();
if (argIt != unrecognizedArguments.end()) {
- std::ostringstream e;
- e << "Unrecognized argument: \"" << *argIt << "\"";
- status.SetError(e.str());
+ status.SetError(cmStrCat("Unrecognized argument: \"", *argIt, "\""));
cmSystemTools::SetFatalErrorOccured();
return false;
}
argIt = keywordsMissingValues.begin();
if (argIt != keywordsMissingValues.end()) {
- std::ostringstream e;
- e << "Keyword missing value: " << *argIt;
- status.SetError(e.str());
+ status.SetError(cmStrCat("Keyword missing value: ", *argIt));
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -2792,9 +2737,7 @@ bool HandleGetRuntimeDependenciesCommand(std::vector<std::string> const& args,
} else {
auto it = archive.GetUnresolvedPaths().begin();
assert(it != archive.GetUnresolvedPaths().end());
- std::ostringstream e;
- e << "Could not resolve file " << *it;
- status.SetError(e.str());
+ status.SetError(cmStrCat("Could not resolve file ", *it));
cmSystemTools::SetFatalErrorOccured();
return false;
}
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 8c8cf1397d..fea7e08b85 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -348,11 +348,10 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
} else if (doing == DoingConfigs) {
if (args[i].find_first_of(":/\\") != std::string::npos ||
cmSystemTools::GetFilenameLastExtension(args[i]) != ".cmake") {
- std::ostringstream e;
- e << "given CONFIGS option followed by invalid file name \"" << args[i]
- << "\". The names given must be file names without "
- << "a path and with a \".cmake\" extension.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(
+ "given CONFIGS option followed by invalid file name \"", args[i],
+ "\". The names given must be file names without "
+ "a path and with a \".cmake\" extension."));
return false;
}
this->Configs.push_back(args[i]);
@@ -360,9 +359,8 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
haveVersion = true;
this->Version = args[i];
} else {
- std::ostringstream e;
- e << "called with invalid argument \"" << args[i] << "\"";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("called with invalid argument \"", args[i], "\""));
return false;
}
}
@@ -372,10 +370,10 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
optionalComponents.begin(), optionalComponents.end(),
std::back_inserter(doubledComponents));
if (!doubledComponents.empty()) {
- std::ostringstream e;
- e << "called with components that are both required and optional:\n";
- e << cmWrap(" ", doubledComponents, "", "\n") << "\n";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("called with components that are both required and "
+ "optional:\n",
+ cmWrap(" ", doubledComponents, "", "\n"), "\n"));
return false;
}
@@ -459,11 +457,10 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
cmStrCat("CMAKE_DISABLE_FIND_PACKAGE_", this->Name);
if (this->Makefile->IsOn(disableFindPackageVar)) {
if (this->Required) {
- std::ostringstream e;
- e << "for module " << this->Name << " called with REQUIRED, but "
- << disableFindPackageVar
- << " is enabled. A REQUIRED package cannot be disabled.";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("for module ", this->Name, " called with REQUIRED, but ",
+ disableFindPackageVar,
+ " is enabled. A REQUIRED package cannot be disabled."));
return false;
}
@@ -701,9 +698,9 @@ bool cmFindPackageCommand::FindModule(bool& found)
this->Makefile->GetPolicyStatus(it->second);
switch (status) {
case cmPolicies::WARN: {
- std::ostringstream e;
- e << cmPolicies::GetPolicyWarning(it->second) << "\n";
- this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, e.str());
+ this->Makefile->IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmStrCat(cmPolicies::GetPolicyWarning(it->second), "\n"));
CM_FALLTHROUGH;
}
case cmPolicies::OLD:
@@ -934,10 +931,10 @@ bool cmFindPackageCommand::HandlePackageMode(
}
// output result if in config mode but not in quiet mode
else if (!this->Quiet) {
- std::ostringstream aw;
- aw << "Could NOT find " << this->Name << " (missing: " << this->Name
- << "_DIR)";
- this->Makefile->DisplayStatus(aw.str(), -1);
+ this->Makefile->DisplayStatus(cmStrCat("Could NOT find ", this->Name,
+ " (missing: ", this->Name,
+ "_DIR)"),
+ -1);
}
}
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index 3c39c466cb..d563a1d711 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -4,7 +4,6 @@
#include <cstdio>
#include <cstdlib>
-#include <sstream>
#include <utility>
#include "cm_memory.hxx"
@@ -146,10 +145,9 @@ bool cmForEachCommand(std::vector<std::string> const& args,
}
if ((start > stop && step > 0) || (start < stop && step < 0) ||
step == 0) {
- std::ostringstream str;
- str << "called with incorrect range specification: start ";
- str << start << ", stop " << stop << ", step " << step;
- status.SetError(str.str());
+ status.SetError(
+ cmStrCat("called with incorrect range specification: start ", start,
+ ", stop ", stop, ", step ", step));
return false;
}
std::vector<std::string> range;
@@ -204,10 +202,9 @@ bool HandleInMode(std::vector<std::string> const& args, cmMakefile& makefile)
cmExpandList(value, fb->Args, true);
}
} else {
- std::ostringstream e;
- e << "Unknown argument:\n"
- << " " << args[i] << "\n";
- makefile.IssueMessage(MessageType::FATAL_ERROR, e.str());
+ makefile.IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Unknown argument:\n", " ", args[i], "\n"));
return true;
}
}
diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx
index e8e87e78b8..947d893db2 100644
--- a/Source/cmGetPropertyCommand.cxx
+++ b/Source/cmGetPropertyCommand.cxx
@@ -2,8 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGetPropertyCommand.h"
-#include <sstream>
-
#include "cmExecutionStatus.h"
#include "cmGlobalGenerator.h"
#include "cmInstalledFile.h"
@@ -99,11 +97,11 @@ bool cmGetPropertyCommand(std::vector<std::string> const& args,
} else if (args[1] == "INSTALL") {
scope = cmProperty::INSTALL;
} else {
- std::ostringstream e;
- e << "given invalid scope " << args[1] << ". "
- << "Valid scopes are "
- << "GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, VARIABLE, CACHE, INSTALL.";
- status.SetError(e.str());
+ status.SetError(cmStrCat(
+ "given invalid scope ", args[1],
+ ". "
+ "Valid scopes are "
+ "GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, VARIABLE, CACHE, INSTALL."));
return false;
}
@@ -138,9 +136,7 @@ bool cmGetPropertyCommand(std::vector<std::string> const& args,
doing = DoingNone;
propertyName = args[i];
} else {
- std::ostringstream e;
- e << "given invalid argument \"" << args[i] << "\".";
- status.SetError(e.str());
+ status.SetError(cmStrCat("given invalid argument \"", args[i], "\"."));
return false;
}
}
@@ -331,10 +327,8 @@ bool HandleTargetMode(cmExecutionStatus& status, const std::string& name,
}
return StoreResult(infoType, status.GetMakefile(), variable, prop_cstr);
}
- std::ostringstream e;
- e << "could not find TARGET " << name
- << ". Perhaps it has not yet been created.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("could not find TARGET ", name,
+ ". Perhaps it has not yet been created."));
return false;
}
@@ -352,9 +346,8 @@ bool HandleSourceMode(cmExecutionStatus& status, const std::string& name,
return StoreResult(infoType, status.GetMakefile(), variable,
sf->GetPropertyForUser(propertyName));
}
- std::ostringstream e;
- e << "given SOURCE name that could not be found or created: " << name;
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("given SOURCE name that could not be found or created: ", name));
return false;
}
@@ -374,9 +367,7 @@ bool HandleTestMode(cmExecutionStatus& status, const std::string& name,
}
// If not found it is an error.
- std::ostringstream e;
- e << "given TEST name that does not exist: " << name;
- status.SetError(e.str());
+ status.SetError(cmStrCat("given TEST name that does not exist: ", name));
return false;
}
@@ -431,9 +422,8 @@ bool HandleInstallMode(cmExecutionStatus& status, const std::string& name,
return StoreResult(infoType, status.GetMakefile(), variable,
isSet ? value.c_str() : nullptr);
}
- std::ostringstream e;
- e << "given INSTALL name that could not be found or created: " << name;
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("given INSTALL name that could not be found or created: ", name));
return false;
}
}
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 9b931f76e5..e7bb1ac325 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -293,9 +293,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
if (!unknownArgs.empty()) {
// Unknown argument.
- std::ostringstream e;
- e << "TARGETS given unknown argument \"" << unknownArgs[0] << "\".";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("TARGETS given unknown argument \"", unknownArgs[0], "\"."));
return false;
}
@@ -391,9 +390,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
for (std::string const& tgt : targetList) {
if (this->Makefile->IsAlias(tgt)) {
- std::ostringstream e;
- e << "TARGETS given target \"" << tgt << "\" which is an alias.";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("TARGETS given target \"", tgt, "\" which is an alias."));
return false;
}
// Lookup this target in the current directory.
@@ -414,19 +412,17 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
target->GetType() != cmStateEnums::MODULE_LIBRARY &&
target->GetType() != cmStateEnums::OBJECT_LIBRARY &&
target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
- std::ostringstream e;
- e << "TARGETS given target \"" << tgt
- << "\" which is not an executable, library, or module.";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("TARGETS given target \"", tgt,
+ "\" which is not an executable, library, or module."));
return false;
}
// Store the target in the list to be installed.
targets.push_back(target);
} else {
// Did not find the target.
- std::ostringstream e;
- e << "TARGETS given target \"" << tgt << "\" which does not exist.";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("TARGETS given target \"", tgt, "\" which does not exist."));
return false;
}
}
@@ -507,11 +503,10 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
frameworkGenerator = CreateInstallTargetGenerator(
target, frameworkArgs, false, this->Makefile->GetBacktrace());
} else {
- std::ostringstream e;
- e << "TARGETS given no FRAMEWORK DESTINATION for shared library "
- "FRAMEWORK target \""
- << target.GetName() << "\".";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("TARGETS given no FRAMEWORK DESTINATION for shared "
+ "library FRAMEWORK target \"",
+ target.GetName(), "\"."));
return false;
}
} else {
@@ -549,11 +544,11 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
frameworkGenerator = CreateInstallTargetGenerator(
target, frameworkArgs, false, this->Makefile->GetBacktrace());
} else {
- std::ostringstream e;
- e << "TARGETS given no FRAMEWORK DESTINATION for static library "
- "FRAMEWORK target \""
- << target.GetName() << "\".";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("TARGETS given no FRAMEWORK DESTINATION for static "
+ "library FRAMEWORK target \"",
+ target.GetName(), "\"."));
+
return false;
}
} else {
@@ -572,10 +567,10 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
namelinkOnly =
(namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly);
} else {
- std::ostringstream e;
- e << "TARGETS given no LIBRARY DESTINATION for module target \""
- << target.GetName() << "\".";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("TARGETS given no LIBRARY DESTINATION for module "
+ "target \"",
+ target.GetName(), "\"."));
return false;
}
} break;
@@ -586,10 +581,9 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
std::string reason;
if (!this->Makefile->GetGlobalGenerator()
->HasKnownObjectFileLocation(&reason)) {
- std::ostringstream e;
- e << "TARGETS given OBJECT library \"" << target.GetName()
- << "\" whose objects may not be installed" << reason << ".";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("TARGETS given OBJECT library \"", target.GetName(),
+ "\" whose objects may not be installed", reason, "."));
return false;
}
@@ -619,11 +613,9 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
}
}
if (!bundleGenerator) {
- std::ostringstream e;
- e << "TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE "
- "executable target \""
- << target.GetName() << "\".";
- this->SetError(e.str());
+ this->SetError(cmStrCat("TARGETS given no BUNDLE DESTINATION for "
+ "MACOSX_BUNDLE executable target \"",
+ target.GetName(), "\"."));
return false;
}
} else {
@@ -708,10 +700,10 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
resourceGenerator = CreateInstallFilesGenerator(
this->Makefile, absFiles, resourceArgs, false);
} else {
- std::ostringstream e;
- e << "INSTALL TARGETS - target " << target.GetName() << " has "
- << "RESOURCE files but no RESOURCE DESTINATION.";
- cmSystemTools::Message(e.str(), "Warning");
+ cmSystemTools::Message(
+ cmStrCat("INSTALL TARGETS - target ", target.GetName(),
+ " has RESOURCE files but no RESOURCE DESTINATION."),
+ "Warning");
}
}
}
@@ -820,17 +812,15 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
if (!unknownArgs.empty()) {
// Unknown argument.
- std::ostringstream e;
- e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat(args[0], " given unknown argument \"", unknownArgs[0], "\"."));
return false;
}
std::string type = ica.GetType();
if (!type.empty() && allowedTypes.count(type) == 0) {
- std::ostringstream e;
- e << args[0] << " given non-type \"" << type << "\" with TYPE argument.";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat(args[0], " given non-type \"", type, "\" with TYPE argument."));
return false;
}
@@ -843,9 +833,8 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
if (!ica.GetRename().empty() && filesVector.size() > 1) {
// The rename option works only with one file.
- std::ostringstream e;
- e << args[0] << " given RENAME option with more than one file.";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat(args[0], " given RENAME option with more than one file."));
return false;
}
@@ -897,20 +886,16 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
}
if (!type.empty() && !ica.GetDestination().empty()) {
- std::ostringstream e;
- e << args[0]
- << " given both TYPE and DESTINATION arguments. You may only specify "
- "one.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0],
+ " given both TYPE and DESTINATION arguments. "
+ "You may only specify one."));
return false;
}
std::string destination = this->GetDestinationForType(&ica, type);
if (destination.empty()) {
// A destination is required.
- std::ostringstream e;
- e << args[0] << " given no DESTINATION!";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " given no DESTINATION!"));
return false;
}
@@ -959,10 +944,8 @@ bool cmInstallCommand::HandleDirectoryMode(
for (unsigned int i = 1; i < args.size(); ++i) {
if (args[i] == "DESTINATION") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -970,10 +953,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingDestination;
} else if (args[i] == "TYPE") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -981,10 +962,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingType;
} else if (args[i] == "OPTIONAL") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -993,10 +972,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingNone;
} else if (args[i] == "MESSAGE_NEVER") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -1014,20 +991,16 @@ bool cmInstallCommand::HandleDirectoryMode(
} else if (args[i] == "EXCLUDE") {
// Add this property to the current match rule.
if (!in_match_mode || doing == DoingPattern || doing == DoingRegex) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" before a PATTERN or REGEX is given.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" before a PATTERN or REGEX is given."));
return false;
}
literal_args += " EXCLUDE";
doing = DoingNone;
} else if (args[i] == "PERMISSIONS") {
if (!in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" before a PATTERN or REGEX is given.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" before a PATTERN or REGEX is given."));
return false;
}
@@ -1036,10 +1009,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingPermsMatch;
} else if (args[i] == "FILE_PERMISSIONS") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -1047,10 +1018,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingPermsFile;
} else if (args[i] == "DIRECTORY_PERMISSIONS") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -1058,10 +1027,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingPermsDir;
} else if (args[i] == "USE_SOURCE_PERMISSIONS") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -1070,10 +1037,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingNone;
} else if (args[i] == "FILES_MATCHING") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -1082,10 +1047,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingNone;
} else if (args[i] == "CONFIGURATIONS") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -1093,10 +1056,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingConfigurations;
} else if (args[i] == "COMPONENT") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -1104,10 +1065,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingComponent;
} else if (args[i] == "EXCLUDE_FROM_ALL") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
exclude_from_all = true;
@@ -1124,10 +1083,8 @@ bool cmInstallCommand::HandleDirectoryMode(
// Make sure the name is a directory.
if (cmSystemTools::FileExists(dir) &&
!cmSystemTools::FileIsDirectory(dir)) {
- std::ostringstream e;
- e << args[0] << " given non-directory \"" << args[i]
- << "\" to install.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " given non-directory \"", args[i],
+ "\" to install."));
return false;
}
@@ -1140,10 +1097,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingNone;
} else if (doing == DoingType) {
if (allowedTypes.count(args[i]) == 0) {
- std::ostringstream e;
- e << args[0] << " given non-type \"" << args[i]
- << "\" with TYPE argument.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " given non-type \"", args[i],
+ "\" with TYPE argument."));
return false;
}
@@ -1179,36 +1134,30 @@ bool cmInstallCommand::HandleDirectoryMode(
// Check the requested permission.
if (!cmInstallCommandArguments::CheckPermissions(args[i],
permissions_file)) {
- std::ostringstream e;
- e << args[0] << " given invalid file permission \"" << args[i]
- << "\".";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " given invalid file permission \"",
+ args[i], "\"."));
return false;
}
} else if (doing == DoingPermsDir) {
// Check the requested permission.
if (!cmInstallCommandArguments::CheckPermissions(args[i],
permissions_dir)) {
- std::ostringstream e;
- e << args[0] << " given invalid directory permission \"" << args[i]
- << "\".";
- this->SetError(e.str());
+ this->SetError(cmStrCat(
+ args[0], " given invalid directory permission \"", args[i], "\"."));
return false;
}
} else if (doing == DoingPermsMatch) {
// Check the requested permission.
if (!cmInstallCommandArguments::CheckPermissions(args[i],
literal_args)) {
- std::ostringstream e;
- e << args[0] << " given invalid permission \"" << args[i] << "\".";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat(args[0], " given invalid permission \"", args[i], "\"."));
return false;
}
} else {
// Unknown argument.
- std::ostringstream e;
- e << args[0] << " given unknown argument \"" << args[i] << "\".";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat(args[0], " given unknown argument \"", args[i], "\"."));
return false;
}
}
@@ -1226,19 +1175,15 @@ bool cmInstallCommand::HandleDirectoryMode(
if (!destination) {
if (type.empty()) {
// A destination is required.
- std::ostringstream e;
- e << args[0] << " given no DESTINATION!";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " given no DESTINATION!"));
return false;
}
destinationStr = this->GetDestinationForType(nullptr, type);
destination = destinationStr.c_str();
} else if (!type.empty()) {
- std::ostringstream e;
- e << args[0]
- << " given both TYPE and DESTINATION arguments. You may only specify "
- "one.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0],
+ " given both TYPE and DESTINATION "
+ "arguments. You may only specify one."));
return false;
}
@@ -1280,9 +1225,8 @@ bool cmInstallCommand::HandleExportAndroidMKMode(
if (!unknownArgs.empty()) {
// Unknown argument.
- std::ostringstream e;
- e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat(args[0], " given unknown argument \"", unknownArgs[0], "\"."));
return false;
}
@@ -1293,39 +1237,35 @@ bool cmInstallCommand::HandleExportAndroidMKMode(
// Make sure there is a destination.
if (ica.GetDestination().empty()) {
// A destination is required.
- std::ostringstream e;
- e << args[0] << " given no DESTINATION!";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " given no DESTINATION!"));
return false;
}
// Check the file name.
std::string fname = filename;
if (fname.find_first_of(":/\\") != std::string::npos) {
- std::ostringstream e;
- e << args[0] << " given invalid export file name \"" << fname << "\". "
- << "The FILE argument may not contain a path. "
- << "Specify the path in the DESTINATION argument.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " given invalid export file name \"",
+ fname,
+ "\". The FILE argument may not contain a path. "
+ "Specify the path in the DESTINATION argument."));
return false;
}
// Check the file extension.
if (!fname.empty() &&
cmSystemTools::GetFilenameLastExtension(fname) != ".mk") {
- std::ostringstream e;
- e << args[0] << " given invalid export file name \"" << fname << "\". "
- << "The FILE argument must specify a name ending in \".mk\".";
- this->SetError(e.str());
+ this->SetError(cmStrCat(
+ args[0], " given invalid export file name \"", fname,
+ R"(". The FILE argument must specify a name ending in ".mk".)"));
return false;
}
if (fname.find_first_of(":/\\") != std::string::npos) {
- std::ostringstream e;
- e << args[0] << " given export name \"" << exp << "\". "
- << "This name cannot be safely converted to a file name. "
- << "Specify a different export name or use the FILE option to set "
- << "a file name explicitly.";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat(args[0], " given export name \"", exp,
+ "\". "
+ "This name cannot be safely converted to a file name. "
+ "Specify a different export name or use the FILE option to set "
+ "a file name explicitly."));
return false;
}
// Use the default name
@@ -1375,9 +1315,8 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
if (!unknownArgs.empty()) {
// Unknown argument.
- std::ostringstream e;
- e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat(args[0], " given unknown argument \"", unknownArgs[0], "\"."));
return false;
}
@@ -1388,30 +1327,28 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
// Make sure there is a destination.
if (ica.GetDestination().empty()) {
// A destination is required.
- std::ostringstream e;
- e << args[0] << " given no DESTINATION!";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " given no DESTINATION!"));
return false;
}
// Check the file name.
std::string fname = filename;
if (fname.find_first_of(":/\\") != std::string::npos) {
- std::ostringstream e;
- e << args[0] << " given invalid export file name \"" << fname << "\". "
- << "The FILE argument may not contain a path. "
- << "Specify the path in the DESTINATION argument.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " given invalid export file name \"",
+ fname,
+ "\". "
+ "The FILE argument may not contain a path. "
+ "Specify the path in the DESTINATION argument."));
return false;
}
// Check the file extension.
if (!fname.empty() &&
cmSystemTools::GetFilenameLastExtension(fname) != ".cmake") {
- std::ostringstream e;
- e << args[0] << " given invalid export file name \"" << fname << "\". "
- << "The FILE argument must specify a name ending in \".cmake\".";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat(args[0], " given invalid export file name \"", fname,
+ "\". "
+ "The FILE argument must specify a name ending in \".cmake\"."));
return false;
}
@@ -1420,12 +1357,12 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
fname = cmStrCat(exp, ".cmake");
if (fname.find_first_of(":/\\") != std::string::npos) {
- std::ostringstream e;
- e << args[0] << " given export name \"" << exp << "\". "
- << "This name cannot be safely converted to a file name. "
- << "Specify a different export name or use the FILE option to set "
- << "a file name explicitly.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(
+ args[0], " given export name \"", exp,
+ "\". "
+ "This name cannot be safely converted to a file name. "
+ "Specify a different export name or use the FILE option to set "
+ "a file name explicitly."));
return false;
}
}
@@ -1441,12 +1378,10 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
tgt->GetPolicyStatusCMP0022() != cmPolicies::OLD);
if (!newCMP0022Behavior) {
- std::ostringstream e;
- e << "INSTALL(EXPORT) given keyword \""
- << "EXPORT_LINK_INTERFACE_LIBRARIES"
- << "\", but target \"" << te->TargetName
- << "\" does not have policy CMP0022 set to NEW.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(
+ "INSTALL(EXPORT) given keyword \""
+ "EXPORT_LINK_INTERFACE_LIBRARIES\", but target \"",
+ te->TargetName, "\" does not have policy CMP0022 set to NEW."));
return false;
}
}
@@ -1480,9 +1415,8 @@ bool cmInstallCommand::MakeFilesFullPath(
// Make sure the file is not a directory.
if (gpos == std::string::npos && cmSystemTools::FileIsDirectory(file)) {
- std::ostringstream e;
- e << modeName << " given directory \"" << relFile << "\" to install.";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat(modeName, " given directory \"", relFile, "\" to install."));
return false;
}
// Store the file for installation.
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index 9487e3b5ec..826abf55be 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -158,10 +158,8 @@ bool HandleGetCommand(std::vector<std::string> const& args,
item = static_cast<int>(nitem) + item;
}
if (item < 0 || nitem <= static_cast<size_t>(item)) {
- std::ostringstream str;
- str << "index: " << item << " out of range (-" << nitem << ", "
- << nitem - 1 << ")";
- status.SetError(str.str());
+ status.SetError(cmStrCat("index: ", item, " out of range (-", nitem,
+ ", ", nitem - 1, ")"));
return false;
}
value += varArgsExpanded[item];
@@ -366,9 +364,7 @@ bool HandleInsertCommand(std::vector<std::string> const& args,
if ((!GetList(varArgsExpanded, listName, status.GetMakefile()) ||
varArgsExpanded.empty()) &&
item != 0) {
- std::ostringstream str;
- str << "index: " << item << " out of range (0, 0)";
- status.SetError(str.str());
+ status.SetError(cmStrCat("index: ", item, " out of range (0, 0)"));
return false;
}
@@ -378,10 +374,9 @@ bool HandleInsertCommand(std::vector<std::string> const& args,
item = static_cast<int>(nitem) + item;
}
if (item < 0 || nitem < static_cast<size_t>(item)) {
- std::ostringstream str;
- str << "index: " << item << " out of range (-" << varArgsExpanded.size()
- << ", " << varArgsExpanded.size() << ")";
- status.SetError(str.str());
+ status.SetError(cmStrCat("index: ", item, " out of range (-",
+ varArgsExpanded.size(), ", ",
+ varArgsExpanded.size(), ")"));
return false;
}
}
@@ -398,10 +393,8 @@ bool HandleJoinCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
if (args.size() != 4) {
- std::ostringstream error;
- error << "sub-command JOIN requires three arguments (" << args.size() - 1
- << " found).";
- status.SetError(error.str());
+ status.SetError(cmStrCat("sub-command JOIN requires three arguments (",
+ args.size() - 1, " found)."));
return false;
}
@@ -596,11 +589,9 @@ protected:
index = static_cast<int>(count) + index;
}
if (index < 0 || count <= static_cast<std::size_t>(index)) {
- std::ostringstream str;
- str << "sub-command TRANSFORM, selector " << this->Tag
- << ", index: " << index << " out of range (-" << count << ", "
- << count - 1 << ").";
- throw transform_error(str.str());
+ throw transform_error(cmStrCat(
+ "sub-command TRANSFORM, selector ", this->Tag, ", index: ", index,
+ " out of range (-", count, ", ", count - 1, ")."));
}
return index;
}
@@ -681,17 +672,14 @@ public:
makefile->ClearMatches();
if (!this->ReplaceHelper.IsRegularExpressionValid()) {
- std::ostringstream error;
- error
- << "sub-command TRANSFORM, action REPLACE: Failed to compile regex \""
- << arguments[0] << "\".";
- throw transform_error(error.str());
+ throw transform_error(
+ cmStrCat("sub-command TRANSFORM, action REPLACE: Failed to compile "
+ "regex \"",
+ arguments[0], "\"."));
}
if (!this->ReplaceHelper.IsReplaceExpressionValid()) {
- std::ostringstream error;
- error << "sub-command TRANSFORM, action REPLACE: "
- << this->ReplaceHelper.GetError() << ".";
- throw transform_error(error.str());
+ throw transform_error(cmStrCat("sub-command TRANSFORM, action REPLACE: ",
+ this->ReplaceHelper.GetError(), "."));
}
}
@@ -701,10 +689,8 @@ public:
std::string output;
if (!this->ReplaceHelper.Replace(input, output)) {
- std::ostringstream error;
- error << "sub-command TRANSFORM, action REPLACE: "
- << this->ReplaceHelper.GetError() << ".";
- throw transform_error(error.str());
+ throw transform_error(cmStrCat("sub-command TRANSFORM, action REPLACE: ",
+ this->ReplaceHelper.GetError(), "."));
}
return output;
@@ -839,19 +825,17 @@ bool HandleTransformCommand(std::vector<std::string> const& args,
auto descriptor = descriptors.find(args[index]);
if (descriptor == descriptors.end()) {
- std::ostringstream error;
- error << " sub-command TRANSFORM, " << args[index] << " invalid action.";
- status.SetError(error.str());
+ status.SetError(
+ cmStrCat(" sub-command TRANSFORM, ", args[index], " invalid action."));
return false;
}
// Action arguments
index += 1;
if (args.size() < index + descriptor->Arity) {
- std::ostringstream error;
- error << "sub-command TRANSFORM, action " << descriptor->Name
- << " expects " << descriptor->Arity << " argument(s).";
- status.SetError(error.str());
+ status.SetError(cmStrCat("sub-command TRANSFORM, action ",
+ descriptor->Name, " expects ", descriptor->Arity,
+ " argument(s)."));
return false;
}
@@ -881,10 +865,10 @@ bool HandleTransformCommand(std::vector<std::string> const& args,
while (args.size() > index) {
if ((args[index] == REGEX || args[index] == AT || args[index] == FOR) &&
command.Selector) {
- std::ostringstream error;
- error << "sub-command TRANSFORM, selector already specified ("
- << command.Selector->Tag << ").";
- status.SetError(error.str());
+ status.SetError(
+ cmStrCat("sub-command TRANSFORM, selector already specified (",
+ command.Selector->Tag, ")."));
+
return false;
}
@@ -898,11 +882,10 @@ bool HandleTransformCommand(std::vector<std::string> const& args,
command.Selector = cm::make_unique<TransformSelectorRegex>(args[index]);
if (!command.Selector->Validate()) {
- std::ostringstream error;
- error << "sub-command TRANSFORM, selector REGEX failed to compile "
- "regex \"";
- error << args[index] << "\".";
- status.SetError(error.str());
+ status.SetError(
+ cmStrCat("sub-command TRANSFORM, selector REGEX failed to compile "
+ "regex \"",
+ args[index], "\"."));
return false;
}
@@ -1020,11 +1003,9 @@ bool HandleTransformCommand(std::vector<std::string> const& args,
continue;
}
- std::ostringstream error;
- error << "sub-command TRANSFORM, '"
- << cmJoin(cmMakeRange(args).advance(index), " ")
- << "': unexpected argument(s).";
- status.SetError(error.str());
+ status.SetError(cmStrCat("sub-command TRANSFORM, '",
+ cmJoin(cmMakeRange(args).advance(index), " "),
+ "': unexpected argument(s)."));
return false;
}
@@ -1261,10 +1242,8 @@ bool HandleSublistCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
if (args.size() != 5) {
- std::ostringstream error;
- error << "sub-command SUBLIST requires four arguments (" << args.size() - 1
- << " found).";
- status.SetError(error.str());
+ status.SetError(cmStrCat("sub-command SUBLIST requires four arguments (",
+ args.size() - 1, " found)."));
return false;
}
@@ -1285,16 +1264,12 @@ bool HandleSublistCommand(std::vector<std::string> const& args,
using size_type = decltype(varArgsExpanded)::size_type;
if (start < 0 || size_type(start) >= varArgsExpanded.size()) {
- std::ostringstream error;
- error << "begin index: " << start << " is out of range 0 - "
- << varArgsExpanded.size() - 1;
- status.SetError(error.str());
+ status.SetError(cmStrCat("begin index: ", start, " is out of range 0 - ",
+ varArgsExpanded.size() - 1));
return false;
}
if (length < -1) {
- std::ostringstream error;
- error << "length: " << length << " should be -1 or greater";
- status.SetError(error.str());
+ status.SetError(cmStrCat("length: ", length, " should be -1 or greater"));
return false;
}
@@ -1344,10 +1319,8 @@ bool HandleRemoveAtCommand(std::vector<std::string> const& args,
item = static_cast<int>(nitem) + item;
}
if (item < 0 || nitem <= static_cast<size_t>(item)) {
- std::ostringstream str;
- str << "index: " << item << " out of range (-" << nitem << ", "
- << nitem - 1 << ")";
- status.SetError(str.str());
+ status.SetError(cmStrCat("index: ", item, " out of range (-", nitem,
+ ", ", nitem - 1, ")"));
return false;
}
removed.push_back(static_cast<size_t>(item));
diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx
index 66fdada3d7..6f5df468a2 100644
--- a/Source/cmLoadCommandCommand.cxx
+++ b/Source/cmLoadCommandCommand.cxx
@@ -7,7 +7,7 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
-#include <sstream>
+
#include <utility>
#include "cm_memory.hxx"
@@ -207,9 +207,8 @@ bool cmLoadCommandCommand(std::vector<std::string> const& args,
// Try to find the program.
std::string fullPath = cmSystemTools::FindFile(moduleName, path);
if (fullPath.empty()) {
- std::ostringstream e;
- e << "Attempt to load command failed from file \"" << moduleName << "\"";
- status.SetError(e.str());
+ status.SetError(cmStrCat("Attempt to load command failed from file \"",
+ moduleName, "\""));
return false;
}
diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx
index a0a098965b..22e59ac43c 100644
--- a/Source/cmOptionCommand.cxx
+++ b/Source/cmOptionCommand.cxx
@@ -2,8 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmOptionCommand.h"
-#include <sstream>
-
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
@@ -74,13 +72,13 @@ bool cmOptionCommand(std::vector<std::string> const& args,
const auto* existsAfterSet =
status.GetMakefile().GetStateSnapshot().GetDefinition(args[0]);
if (!existsAfterSet) {
- std::ostringstream w;
- w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0077)
- << "\n"
- "For compatibility with older versions of CMake, option "
- "is clearing the normal variable '"
- << args[0] << "'.";
- status.GetMakefile().IssueMessage(MessageType::AUTHOR_WARNING, w.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0077),
+ "\n"
+ "For compatibility with older versions of CMake, option "
+ "is clearing the normal variable '",
+ args[0], "'."));
}
}
return true;
diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx
index e1267ec484..916a9f7285 100644
--- a/Source/cmOrderDirectories.cxx
+++ b/Source/cmOrderDirectories.cxx
@@ -465,14 +465,14 @@ void cmOrderDirectories::FindImplicitConflicts()
}
// Warn about the conflicts.
- std::ostringstream w;
- w << "Cannot generate a safe " << this->Purpose << " for target "
- << this->Target->GetName()
- << " because files in some directories may conflict with "
- << " libraries in implicit directories:\n"
- << text << "Some of these libraries may not be found correctly.";
this->GlobalGenerator->GetCMakeInstance()->IssueMessage(
- MessageType::WARNING, w.str(), this->Target->GetBacktrace());
+ MessageType::WARNING,
+ cmStrCat("Cannot generate a safe ", this->Purpose, " for target ",
+ this->Target->GetName(),
+ " because files in some directories may "
+ "conflict with libraries in implicit directories:\n",
+ text, "Some of these libraries may not be found correctly."),
+ this->Target->GetBacktrace());
}
void cmOrderDirectories::OrderDirectories()
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx
index e74fff61eb..5fa6a21ce3 100644
--- a/Source/cmProjectCommand.cxx
+++ b/Source/cmProjectCommand.cxx
@@ -8,7 +8,6 @@
#include <cstdio>
#include <functional>
#include <limits>
-#include <sstream>
#include <utility>
#include "cmMakefile.h"
@@ -320,10 +319,10 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
}
}
if (!vw.empty()) {
- std::ostringstream w;
- w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0048)
- << "\nThe following variable(s) would be set to empty:" << vw;
- this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
+ this->Makefile->IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0048),
+ "\nThe following variable(s) would be set to empty:", vw));
}
}
diff --git a/Source/cmSeparateArgumentsCommand.cxx b/Source/cmSeparateArgumentsCommand.cxx
index 27f45a8653..52bde7c5ca 100644
--- a/Source/cmSeparateArgumentsCommand.cxx
+++ b/Source/cmSeparateArgumentsCommand.cxx
@@ -3,10 +3,10 @@
#include "cmSeparateArgumentsCommand.h"
#include <algorithm>
-#include <sstream>
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
// cmSeparateArgumentsCommand
@@ -56,9 +56,7 @@ bool cmSeparateArgumentsCommand(std::vector<std::string> const& args,
command = arg;
doing = DoingNone;
} else {
- std::ostringstream e;
- e << "given unknown argument " << arg;
- status.SetError(e.str());
+ status.SetError(cmStrCat("given unknown argument ", arg));
return false;
}
}
diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx
index 387c3fc9ba..112d832e63 100644
--- a/Source/cmSetPropertyCommand.cxx
+++ b/Source/cmSetPropertyCommand.cxx
@@ -100,11 +100,10 @@ bool cmSetPropertyCommand(std::vector<std::string> const& args,
} else if (scopeName == "INSTALL") {
scope = cmProperty::INSTALL;
} else {
- std::ostringstream e;
- e << "given invalid scope " << scopeName << ". "
- << "Valid scopes are GLOBAL, DIRECTORY, "
- "TARGET, SOURCE, TEST, CACHE, INSTALL.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("given invalid scope ", scopeName,
+ ". "
+ "Valid scopes are GLOBAL, DIRECTORY, "
+ "TARGET, SOURCE, TEST, CACHE, INSTALL."));
return false;
}
@@ -149,9 +148,7 @@ bool cmSetPropertyCommand(std::vector<std::string> const& args,
propertyValue += arg;
remove = false;
} else {
- std::ostringstream e;
- e << "given invalid argument \"" << arg << "\".";
- status.SetError(e.str());
+ status.SetError(cmStrCat("given invalid argument \"", arg, "\"."));
return false;
}
}
@@ -293,10 +290,8 @@ bool HandleTargetMode(cmExecutionStatus& status,
return false;
}
} else {
- std::ostringstream e;
- e << "could not find TARGET " << name
- << ". Perhaps it has not yet been created.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("could not find TARGET ", name,
+ ". Perhaps it has not yet been created."));
return false;
}
}
@@ -340,9 +335,8 @@ bool HandleSourceMode(cmExecutionStatus& status,
return false;
}
} else {
- std::ostringstream e;
- e << "given SOURCE name that could not be found or created: " << name;
- status.SetError(e.str());
+ status.SetError(cmStrCat(
+ "given SOURCE name that could not be found or created: ", name));
return false;
}
}
@@ -428,26 +422,23 @@ bool HandleCacheMode(cmExecutionStatus& status,
{
if (propertyName == "ADVANCED") {
if (!remove && !cmIsOn(propertyValue) && !cmIsOff(propertyValue)) {
- std::ostringstream e;
- e << "given non-boolean value \"" << propertyValue
- << R"(" for CACHE property "ADVANCED". )";
- status.SetError(e.str());
+ status.SetError(cmStrCat("given non-boolean value \"", propertyValue,
+ R"(" for CACHE property "ADVANCED". )"));
return false;
}
} else if (propertyName == "TYPE") {
if (!cmState::IsCacheEntryType(propertyValue)) {
- std::ostringstream e;
- e << "given invalid CACHE entry TYPE \"" << propertyValue << "\"";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("given invalid CACHE entry TYPE \"", propertyValue, "\""));
return false;
}
} else if (propertyName != "HELPSTRING" && propertyName != "STRINGS" &&
propertyName != "VALUE") {
- std::ostringstream e;
- e << "given invalid CACHE property " << propertyName << ". "
- << "Settable CACHE properties are: "
- << "ADVANCED, HELPSTRING, STRINGS, TYPE, and VALUE.";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("given invalid CACHE property ", propertyName,
+ ". "
+ "Settable CACHE properties are: "
+ "ADVANCED, HELPSTRING, STRINGS, TYPE, and VALUE."));
return false;
}
@@ -462,10 +453,8 @@ bool HandleCacheMode(cmExecutionStatus& status,
return false;
}
} else {
- std::ostringstream e;
- e << "could not find CACHE variable " << name
- << ". Perhaps it has not yet been created.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("could not find CACHE variable ", name,
+ ". Perhaps it has not yet been created."));
return false;
}
}
@@ -511,9 +500,8 @@ bool HandleInstallMode(cmExecutionStatus& status,
return false;
}
} else {
- std::ostringstream e;
- e << "given INSTALL name that could not be found or created: " << name;
- status.SetError(e.str());
+ status.SetError(cmStrCat(
+ "given INSTALL name that could not be found or created: ", name));
return false;
}
}
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index ab670cac7e..809d05e135 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -11,7 +11,6 @@
#include <cstdlib>
#include <iterator>
#include <memory>
-#include <sstream>
#include "cm_static_string_view.hxx"
@@ -46,9 +45,8 @@ bool HandleHashCommand(std::vector<std::string> const& args,
{
#if !defined(CMAKE_BOOTSTRAP)
if (args.size() != 3) {
- std::ostringstream e;
- e << args[0] << " requires an output variable and an input string";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat(args[0], " requires an output variable and an input string"));
return false;
}
@@ -60,9 +58,7 @@ bool HandleHashCommand(std::vector<std::string> const& args,
}
return false;
#else
- std::ostringstream e;
- e << args[0] << " not available during bootstrap";
- status.SetError(e.str().c_str());
+ status.SetError(cmStrCat(args[0], " not available during bootstrap"));
return false;
#endif
}
@@ -148,9 +144,7 @@ bool HandleConfigureCommand(std::vector<std::string> const& args,
} else if (args[i] == "ESCAPE_QUOTES") {
escapeQuotes = true;
} else {
- std::ostringstream err;
- err << "Unrecognized argument \"" << args[i] << "\"";
- status.SetError(err.str());
+ status.SetError(cmStrCat("Unrecognized argument \"", args[i], "\""));
return false;
}
}
@@ -377,9 +371,7 @@ bool HandleFindCommand(std::vector<std::string> const& args,
pos = sstring.rfind(schar);
}
if (std::string::npos != pos) {
- std::ostringstream s;
- s << pos;
- status.GetMakefile().AddDefinition(outvar, s.str());
+ status.GetMakefile().AddDefinition(outvar, std::to_string(pos));
return true;
}
@@ -474,16 +466,12 @@ bool HandleSubstringCommand(std::vector<std::string> const& args,
size_t stringLength = stringValue.size();
int intStringLength = static_cast<int>(stringLength);
if (begin < 0 || begin > intStringLength) {
- std::ostringstream ostr;
- ostr << "begin index: " << begin << " is out of range 0 - "
- << stringLength;
- status.SetError(ostr.str());
+ status.SetError(
+ cmStrCat("begin index: ", begin, " is out of range 0 - ", stringLength));
return false;
}
if (end < -1) {
- std::ostringstream ostr;
- ostr << "end index: " << end << " should be -1 or greater";
- status.SetError(ostr.str());
+ status.SetError(cmStrCat("end index: ", end, " should be -1 or greater"));
return false;
}
@@ -915,9 +903,7 @@ bool HandleUuidCommand(std::vector<std::string> const& args,
status.GetMakefile().AddDefinition(outputVariable, uuid);
return true;
#else
- std::ostringstream e;
- e << args[0] << " not available during bootstrap";
- status.SetError(e.str().c_str());
+ status.SetError(cmStrCat(args[0], " not available during bootstrap"));
return false;
#endif
}
diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx
index b64646ab9f..94e249f22b 100644
--- a/Source/cmTargetCompileDefinitionsCommand.cxx
+++ b/Source/cmTargetCompileDefinitionsCommand.cxx
@@ -2,8 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTargetCompileDefinitionsCommand.h"
-#include <sstream>
-
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmStringAlgorithms.h"
@@ -20,11 +18,10 @@ bool cmTargetCompileDefinitionsCommand::InitialPass(
void cmTargetCompileDefinitionsCommand::HandleMissingTarget(
const std::string& name)
{
- std::ostringstream e;
- e << "Cannot specify compile definitions for target \"" << name
- << "\" "
- "which is not built by this project.";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot specify compile definitions for target \"", name,
+ "\" which is not built by this project."));
}
std::string cmTargetCompileDefinitionsCommand::Join(
diff --git a/Source/cmTargetCompileFeaturesCommand.cxx b/Source/cmTargetCompileFeaturesCommand.cxx
index 976c8cbfbd..a22b94b100 100644
--- a/Source/cmTargetCompileFeaturesCommand.cxx
+++ b/Source/cmTargetCompileFeaturesCommand.cxx
@@ -2,8 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTargetCompileFeaturesCommand.h"
-#include <sstream>
-
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmStringAlgorithms.h"
@@ -20,11 +18,10 @@ bool cmTargetCompileFeaturesCommand::InitialPass(
void cmTargetCompileFeaturesCommand::HandleMissingTarget(
const std::string& name)
{
- std::ostringstream e;
- e << "Cannot specify compile features for target \"" << name
- << "\" "
- "which is not built by this project.";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot specify compile features for target \"", name,
+ "\" which is not built by this project."));
}
std::string cmTargetCompileFeaturesCommand::Join(
diff --git a/Source/cmTargetCompileOptionsCommand.cxx b/Source/cmTargetCompileOptionsCommand.cxx
index 7dadb82de0..ccc215ab6e 100644
--- a/Source/cmTargetCompileOptionsCommand.cxx
+++ b/Source/cmTargetCompileOptionsCommand.cxx
@@ -2,8 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTargetCompileOptionsCommand.h"
-#include <sstream>
-
#include "cmListFileCache.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
@@ -21,10 +19,10 @@ bool cmTargetCompileOptionsCommand::InitialPass(
void cmTargetCompileOptionsCommand::HandleMissingTarget(
const std::string& name)
{
- std::ostringstream e;
- e << "Cannot specify compile options for target \"" << name
- << "\" which is not built by this project.";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot specify compile options for target \"", name,
+ "\" which is not built by this project."));
}
std::string cmTargetCompileOptionsCommand::Join(
diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx
index d099349fc1..7801ee8c3e 100644
--- a/Source/cmTargetIncludeDirectoriesCommand.cxx
+++ b/Source/cmTargetIncludeDirectoriesCommand.cxx
@@ -3,7 +3,6 @@
#include "cmTargetIncludeDirectoriesCommand.h"
#include <set>
-#include <sstream>
#include "cmGeneratorExpression.h"
#include "cmListFileCache.h"
@@ -25,10 +24,10 @@ bool cmTargetIncludeDirectoriesCommand::InitialPass(
void cmTargetIncludeDirectoriesCommand::HandleMissingTarget(
const std::string& name)
{
- std::ostringstream e;
- e << "Cannot specify include directories for target \"" << name
- << "\" which is not built by this project.";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot specify include directories for target \"", name,
+ "\" which is not built by this project."));
}
std::string cmTargetIncludeDirectoriesCommand::Join(
diff --git a/Source/cmTargetLinkDirectoriesCommand.cxx b/Source/cmTargetLinkDirectoriesCommand.cxx
index 435c39282c..c2ef6c1340 100644
--- a/Source/cmTargetLinkDirectoriesCommand.cxx
+++ b/Source/cmTargetLinkDirectoriesCommand.cxx
@@ -2,8 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTargetLinkDirectoriesCommand.h"
-#include <sstream>
-
#include "cmGeneratorExpression.h"
#include "cmListFileCache.h"
#include "cmMakefile.h"
@@ -23,10 +21,10 @@ bool cmTargetLinkDirectoriesCommand::InitialPass(
void cmTargetLinkDirectoriesCommand::HandleMissingTarget(
const std::string& name)
{
- std::ostringstream e;
- e << "Cannot specify link directories for target \"" << name
- << "\" which is not built by this project.";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot specify link directories for target \"", name,
+ "\" which is not built by this project."));
}
std::string cmTargetLinkDirectoriesCommand::Join(
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index 237d90c901..b4325994fe 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -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 /
diff --git a/Source/cmTargetLinkOptionsCommand.cxx b/Source/cmTargetLinkOptionsCommand.cxx
index 2866cf1e26..dbd7bfee96 100644
--- a/Source/cmTargetLinkOptionsCommand.cxx
+++ b/Source/cmTargetLinkOptionsCommand.cxx
@@ -2,8 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTargetLinkOptionsCommand.h"
-#include <sstream>
-
#include "cmListFileCache.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
@@ -20,10 +18,10 @@ bool cmTargetLinkOptionsCommand::InitialPass(
void cmTargetLinkOptionsCommand::HandleMissingTarget(const std::string& name)
{
- std::ostringstream e;
- e << "Cannot specify link options for target \"" << name
- << "\" which is not built by this project.";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot specify link options for target \"", name,
+ "\" which is not built by this project."));
}
std::string cmTargetLinkOptionsCommand::Join(
diff --git a/Source/cmTargetSourcesCommand.cxx b/Source/cmTargetSourcesCommand.cxx
index 2251a6564d..7c9d03c539 100644
--- a/Source/cmTargetSourcesCommand.cxx
+++ b/Source/cmTargetSourcesCommand.cxx
@@ -30,11 +30,10 @@ void cmTargetSourcesCommand::HandleInterfaceContent(
void cmTargetSourcesCommand::HandleMissingTarget(const std::string& name)
{
- std::ostringstream e;
- e << "Cannot specify sources for target \"" << name
- << "\" "
- "which is not built by this project.";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot specify sources for target \"", name,
+ "\" which is not built by this project."));
}
std::string cmTargetSourcesCommand::Join(
diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx
index f9f7d66174..f2c8f3cdb9 100644
--- a/Source/cmVariableWatchCommand.cxx
+++ b/Source/cmVariableWatchCommand.cxx
@@ -3,13 +3,13 @@
#include "cmVariableWatchCommand.h"
#include <memory>
-#include <sstream>
#include <utility>
#include "cmExecutionStatus.h"
#include "cmListFileCache.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmVariableWatch.h"
#include "cmake.h"
@@ -58,22 +58,20 @@ static void cmVariableWatchCommandVariableAccessed(const std::string& variable,
newLFF.Line = 9999;
cmExecutionStatus status(*makefile);
if (!makefile->ExecuteCommand(newLFF, status)) {
- std::ostringstream error;
- error << "Error in cmake code at\nUnknown:0:\n"
- << "A command failed during the invocation of callback \""
- << data->Command << "\".";
- cmSystemTools::Error(error.str());
+ cmSystemTools::Error(
+ cmStrCat("Error in cmake code at\nUnknown:0:\nA command failed "
+ "during the invocation of callback \"",
+ data->Command, "\"."));
data->InCallback = false;
return;
}
processed = true;
}
if (!processed) {
- std::ostringstream msg;
- msg << "Variable \"" << variable << "\" was accessed using "
- << accessString << " with value \"" << (newValue ? newValue : "")
- << "\".";
- makefile->IssueMessage(MessageType::LOG, msg.str());
+ makefile->IssueMessage(
+ MessageType::LOG,
+ cmStrCat("Variable \"", variable, "\" was accessed using ", accessString,
+ " with value \"", (newValue ? newValue : ""), "\"."));
}
data->InCallback = false;
@@ -134,9 +132,7 @@ bool cmVariableWatchCommand(std::vector<std::string> const& args,
command = args[1];
}
if (variable == "CMAKE_CURRENT_LIST_FILE") {
- std::ostringstream ostr;
- ostr << "cannot be set on the variable: " << variable;
- status.SetError(ostr.str());
+ status.SetError(cmStrCat("cannot be set on the variable: ", variable));
return false;
}