Source: reduce string reallocations

This commit is contained in:
AJIOB
2026-07-08 09:40:55 -04:00
committed by Brad King
parent b3dd0aa7c8
commit ce9ac00844
7 changed files with 129 additions and 120 deletions
+2 -2
View File
@@ -39,8 +39,8 @@ std::string GeneratorExpressionContent::ProcessArbitraryContent(
if (node->RequiresLiteralInput()) {
if (pExprEval->GetType() != cmGeneratorExpressionEvaluator::Text) {
reportError(eval, this->GetOriginalExpression(),
"$<" + identifier +
"> expression requires literal input.");
cmStrCat("$<", identifier,
"> expression requires literal input."));
return std::string();
}
}
+8 -8
View File
@@ -492,8 +492,8 @@ static const struct EqualNode : public cmGeneratorExpressionNode
for (int i = 0; i < 2; ++i) {
if (!ParameterToLong(parameters[i].c_str(), &numbers[i])) {
reportError(eval, content->GetOriginalExpression(),
"$<EQUAL> parameter " + parameters[i] +
" is not a valid integer.");
cmStrCat("$<EQUAL> parameter ", parameters[i],
" is not a valid integer."));
return {};
}
}
@@ -2998,8 +2998,8 @@ struct CompilerIdNode : public cmGeneratorExpressionNode
std::string const& lang) const
{
std::string const& compilerId =
eval->Context.LG->GetMakefile()->GetSafeDefinition("CMAKE_" + lang +
"_COMPILER_ID");
eval->Context.LG->GetMakefile()->GetSafeDefinition(
cmStrCat("CMAKE_", lang, "_COMPILER_ID"));
if (parameters.empty()) {
return compilerId;
}
@@ -3063,8 +3063,8 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode
std::string const& lang) const
{
std::string const& compilerVersion =
eval->Context.LG->GetMakefile()->GetSafeDefinition("CMAKE_" + lang +
"_COMPILER_VERSION");
eval->Context.LG->GetMakefile()->GetSafeDefinition(
cmStrCat("CMAKE_", lang, "_COMPILER_VERSION"));
if (parameters.empty()) {
return compilerVersion;
}
@@ -3627,8 +3627,8 @@ struct LinkerId
std::string const& lang)
{
std::string const& linkerId =
eval->Context.LG->GetMakefile()->GetSafeDefinition("CMAKE_" + lang +
"_COMPILER_ID");
eval->Context.LG->GetMakefile()->GetSafeDefinition(
cmStrCat("CMAKE_", lang, "_COMPILER_ID"));
if (parameters.empty()) {
return linkerId;
}
+56 -55
View File
@@ -836,10 +836,11 @@ bool cmGeneratorTarget::IsIPOEnabled(std::string const& lang,
// Note: check consistency with messages from CheckIPOSupported
char const* message = nullptr;
if (!this->Makefile->IsOn("_CMAKE_" + lang + "_IPO_SUPPORTED_BY_CMAKE")) {
if (!this->Makefile->IsOn(
cmStrCat("_CMAKE_", lang, "_IPO_SUPPORTED_BY_CMAKE"))) {
message = "CMake doesn't support IPO for current compiler";
} else if (!this->Makefile->IsOn("_CMAKE_" + lang +
"_IPO_MAY_BE_SUPPORTED_BY_COMPILER")) {
} else if (!this->Makefile->IsOn(cmStrCat(
"_CMAKE_", lang, "_IPO_MAY_BE_SUPPORTED_BY_COMPILER"))) {
message = "Compiler doesn't support IPO";
} else if (!this->GlobalGenerator->IsIPOSupported()) {
message = "CMake doesn't support IPO for current generator";
@@ -1219,19 +1220,18 @@ std::string const& cmGeneratorTarget::GetLocationForBuild() const
location = this->GetDirectory(noConfig);
cmValue cfgid = this->Makefile->GetDefinition("CMAKE_CFG_INTDIR");
if (cfgid && (*cfgid != ".")) {
location += "/";
location += *cfgid;
location = cmStrCat(std::move(location), '/', *cfgid);
}
if (this->IsAppBundleOnApple()) {
std::string macdir = this->BuildBundleDirectory("", "", FullLevel);
if (!macdir.empty()) {
location += "/";
location += macdir;
location = cmStrCat(std::move(location), '/', macdir);
}
}
location += "/";
location += this->GetFullName("", cmStateEnums::RuntimeBinaryArtifact);
location =
cmStrCat(std::move(location), '/',
this->GetFullName("", cmStateEnums::RuntimeBinaryArtifact));
return location;
}
@@ -1359,7 +1359,7 @@ std::string cmGeneratorTarget::GetCompilePDBPath(
dir = this->GetPDBDirectory(config);
}
if (!dir.empty()) {
dir += "/";
dir += '/';
}
return dir + name;
}
@@ -1768,8 +1768,8 @@ std::string cmGeneratorTarget::GetFrameworkDirectory(
fpath += (ext ? *ext : "framework");
if (shouldAddFullLevel(level) &&
!this->Makefile->PlatformIsAppleEmbedded()) {
fpath += "/Versions/";
fpath += this->GetFrameworkVersion();
fpath =
cmStrCat(std::move(fpath), "/Versions/", this->GetFrameworkVersion());
}
return fpath;
}
@@ -1804,7 +1804,7 @@ std::string cmGeneratorTarget::GetInstallNameDirForBuildTree(
} else {
dir = this->GetDirectory(config);
}
dir += "/";
dir += '/';
return dir;
}
}
@@ -2702,8 +2702,8 @@ void cmGeneratorTarget::AddCUDAArchitectureFlags(cmBuildStep compileOrLink,
default:
this->Makefile->IssueMessage(
MessageType::FATAL_ERROR,
"CUDA_ARCHITECTURES is empty for target \"" + this->GetName() +
"\".");
cmStrCat("CUDA_ARCHITECTURES is empty for target \"",
this->GetName(), "\"."));
}
}
@@ -2795,8 +2795,8 @@ void cmGeneratorTarget::AddCUDAArchitectureFlagsImpl(cmBuildStep compileOrLink,
} else {
this->Makefile->IssueMessage(
MessageType::FATAL_ERROR,
"Unknown CUDA architecture specifier \"" + std::string(specifier) +
"\".");
cmStrCat("Unknown CUDA architecture specifier \"", specifier,
"\"."));
}
}
@@ -2907,7 +2907,7 @@ void cmGeneratorTarget::AddHIPArchitectureFlags(cmBuildStep compileOrLink,
cmList options(arch);
for (std::string& option : options) {
flags += " --offload-arch=" + option;
flags = cmStrCat(std::move(flags), " --offload-arch=", option);
}
}
@@ -2915,7 +2915,7 @@ void cmGeneratorTarget::AddRustTargetFlags(std::string& flags) const
{
cmValue const edition = this->GetProperty("Rust_EDITION");
if (edition && !edition->empty()) {
flags += " --edition=" + *edition;
flags = cmStrCat(std::move(flags), " --edition=", *edition);
}
}
@@ -2926,7 +2926,7 @@ void cmGeneratorTarget::AddSwiftTargetFlags(std::string& flags) const
cmSystemTools::OP_GREATER_EQUAL,
this->Makefile->GetDefinition("CMAKE_Swift_COMPILER_VERSION"),
"4.2")) {
flags += " -swift-version " + *version;
flags = cmStrCat(std::move(flags), " -swift-version ", *version);
}
}
@@ -2942,7 +2942,7 @@ void cmGeneratorTarget::AddSwiftTargetFlags(std::string& flags) const
std::string const packageFlag =
this->Makefile->GetSafeDefinition("CMAKE_Swift_PACKAGE_NAME_FLAG");
// Add the package name to the flags
flags += " " + packageFlag + " " + packageName;
flags = cmStrCat(std::move(flags), ' ', packageFlag, ' ', packageName);
}
}
}
@@ -2962,9 +2962,9 @@ void cmGeneratorTarget::AddCUDAToolkitFlags(std::string& flags) const
this->Makefile->GetSafeDefinition("CMAKE_CUDA_COMPILER_LIBRARY_ROOT");
if (!toolkitRoot.empty()) {
flags += " --cuda-path=" +
this->LocalGenerator->ConvertToOutputFormat(toolkitRoot,
cmOutputConverter::SHELL);
flags = cmStrCat(std::move(flags), " --cuda-path=",
this->LocalGenerator->ConvertToOutputFormat(
toolkitRoot, cmOutputConverter::SHELL));
}
}
}
@@ -3812,17 +3812,18 @@ cmGeneratorTarget::Names cmGeneratorTarget::GetLibraryNames(
if (this->IsFrameworkOnApple()) {
targetNames.Real = components.prefix;
if (!this->Makefile->PlatformIsAppleEmbedded()) {
targetNames.Real +=
cmStrCat("Versions/", this->GetFrameworkVersion(), '/');
targetNames.Real = cmStrCat(std::move(targetNames.Real), "Versions/",
this->GetFrameworkVersion(), '/');
}
targetNames.Real += cmStrCat(targetNames.Base, components.suffix);
targetNames.Real = cmStrCat(std::move(targetNames.Real), targetNames.Base,
components.suffix);
targetNames.SharedObject = targetNames.Real;
} else if (this->IsArchivedAIXSharedLibrary()) {
targetNames.SharedObject =
cmStrCat(components.prefix, targetNames.Base, ".so");
if (soversion) {
targetNames.SharedObject += ".";
targetNames.SharedObject += *soversion;
targetNames.SharedObject =
cmStrCat(std::move(targetNames.SharedObject), '.', *soversion);
}
targetNames.Real = targetNames.Output;
} else {
@@ -3849,11 +3850,13 @@ cmGeneratorTarget::Names cmGeneratorTarget::GetLibraryNames(
if (this->IsFrameworkOnApple() && this->IsSharedLibraryWithExports()) {
targetNames.ImportReal = components.prefix;
if (!this->Makefile->PlatformIsAppleEmbedded()) {
targetNames.ImportReal +=
cmStrCat("Versions/", this->GetFrameworkVersion(), '/');
targetNames.ImportReal =
cmStrCat(std::move(targetNames.ImportReal), "Versions/",
this->GetFrameworkVersion(), '/');
}
targetNames.ImportReal +=
cmStrCat(importComponents.base, importComponents.suffix);
targetNames.ImportReal =
cmStrCat(std::move(targetNames.ImportReal), importComponents.base,
importComponents.suffix);
targetNames.ImportLibrary = targetNames.ImportOutput;
} else {
// The import library's soname.
@@ -3922,8 +3925,7 @@ cmGeneratorTarget::Names cmGeneratorTarget::GetExecutableNames(
targetNames.Real = targetNames.Output;
#endif
if (version) {
targetNames.Real += "-";
targetNames.Real += *version;
targetNames.Real = cmStrCat(std::move(targetNames.Real), '-', *version);
}
#if defined(__CYGWIN__)
targetNames.Real += components.suffix;
@@ -4063,8 +4065,7 @@ cmGeneratorTarget::GetFullNameInternalComponents(
(dllProp.IsOn() ||
(!dllProp.IsSet() &&
this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")))) {
outBase += "-";
outBase += *soversion;
outBase = cmStrCat(std::move(outBase), '-', *soversion);
}
}
@@ -4619,10 +4620,11 @@ std::string cmGeneratorTarget::ComputeVersionedName(std::string const& prefix,
{
std::string vName = this->IsApple() ? (prefix + base) : name;
if (version) {
vName += ".";
vName += *version;
vName = cmStrCat(std::move(vName), '.', *version);
}
if (this->IsApple()) {
vName += suffix;
}
vName += this->IsApple() ? suffix : std::string();
return vName;
}
@@ -5122,31 +5124,30 @@ bool cmGeneratorTarget::GetConfigCommonSourceFilesForXcode(
std::string firstConfigFiles;
char const* sep = "";
for (cmSourceFile* f : files) {
firstConfigFiles += sep;
firstConfigFiles += f->ResolveFullPath();
firstConfigFiles =
cmStrCat(std::move(firstConfigFiles), sep, f->ResolveFullPath());
sep = "\n ";
}
std::string thisConfigFiles;
sep = "";
for (cmSourceFile* f : configFiles) {
thisConfigFiles += sep;
thisConfigFiles += f->ResolveFullPath();
thisConfigFiles =
cmStrCat(std::move(thisConfigFiles), sep, f->ResolveFullPath());
sep = "\n ";
}
std::ostringstream e;
/* clang-format off */
e << "Target \"" << this->GetName()
<< "\" has source files which vary by "
"configuration. This is not supported by the \""
<< this->GlobalGenerator->GetName()
<< "\" generator.\n"
"Config \"" << firstConfig << "\":\n"
" " << firstConfigFiles << "\n"
"Config \"" << *it << "\":\n"
" " << thisConfigFiles << "\n";
std::string e = cmStrCat("Target \"", this->GetName(),
"\" has source files which vary by "
"configuration. This is not supported by the \"",
this->GlobalGenerator->GetName(),
"\" generator.\n"
"Config \"", firstConfig, "\":\n"
" ", firstConfigFiles, "\n"
"Config \"", *it, "\":\n"
" ", thisConfigFiles, '\n');
/* clang-format on */
this->LocalGenerator->IssueMessage(MessageType::FATAL_ERROR, e.str());
this->LocalGenerator->IssueMessage(MessageType::FATAL_ERROR, e);
return false;
}
}
+38 -31
View File
@@ -165,7 +165,7 @@ void FastbuildTarget::GenerateAliases()
linkerNode.Type == FastbuildLinkerNode::EXECUTABLE) {
std::string postfix = FASTBUILD_LINK_ARTIFACTS_ALIAS_POSTFIX;
if (!linkerNode.Arch.empty()) {
postfix += cmStrCat('-', linkerNode.Arch);
postfix = cmStrCat(std::move(postfix), '-', linkerNode.Arch);
}
#ifdef _WIN32
// On Windows DLL and Executables must be linked via Import Lib file
@@ -326,10 +326,10 @@ bool cmGlobalFastbuildGenerator::FindMakeProgram(cmMakefile* mf)
nullptr,
cmSystemTools::OUTPUT_NONE)) {
mf->IssueMessage(MessageType::FATAL_ERROR,
"Running\n '" + cmJoin(command, "' '") +
"'\n"
"failed with:\n " +
error);
cmStrCat("Running\n '", cmJoin(command, "' '"),
"'\n"
"failed with:\n ",
error));
cmSystemTools::SetFatalErrorOccurred();
return false;
}
@@ -427,7 +427,7 @@ void cmGlobalFastbuildGenerator::AppendDirectoryForConfig(
std::string const& suffix, std::string& dir)
{
if (!config.empty() && this->IsMultiConfig()) {
dir += cmStrCat(prefix, config, suffix);
dir = cmStrCat(std::move(dir), prefix, config, suffix);
}
}
@@ -633,7 +633,8 @@ void cmGlobalFastbuildGenerator::WriteVariable(std::string const& key,
int indent)
{
Indent(indent);
*this->BuildFileStream << "." << key << " " + op + (value.empty() ? "" : " ")
*this->BuildFileStream << "." << key
<< cmStrCat(" ", op, (value.empty() ? "" : " "))
<< value << "\n";
}
@@ -697,7 +698,7 @@ std::string cmGlobalFastbuildGenerator::Quote(std::string const& str,
std::string result = str;
cmSystemTools::ReplaceString(result, quotation, "^" + quotation);
cmSystemTools::ReplaceString(result, FASTBUILD_DOLLAR_TAG, "$");
return quotation + result + quotation;
return cmStrCat(quotation, result, quotation);
}
std::string cmGlobalFastbuildGenerator::QuoteIfHasSpaces(std::string str)
{
@@ -722,7 +723,7 @@ struct WrapHelper
cmSystemTools::ReplaceString(in, "\r", "\\r");
// Escaping of single quotes tested in "RunCMake.CompilerArgs" test.
cmSystemTools::ReplaceString(in, "'", "^'");
std::string result = Prefix + in + Suffix;
std::string result = cmStrCat(Prefix, in, Suffix);
if (EscapeDollar) {
cmSystemTools::ReplaceString(result, "$", "^$");
cmSystemTools::ReplaceString(result, FASTBUILD_DOLLAR_TAG, "$");
@@ -840,9 +841,11 @@ void cmGlobalFastbuildGenerator::TopologicalSort(
void cmGlobalFastbuildGenerator::WriteDisclaimer()
{
*this->BuildFileStream << "// CMAKE generated file: DO NOT EDIT!\n"
<< "// Generated by \"" << this->GetName() << "\""
<< " Generator, CMake Version "
<< cmVersion::GetMajorVersion() << "."
"// Generated by \""
<< this->GetName()
<< "\""
" Generator, CMake Version "
<< cmVersion::GetMajorVersion() << '.'
<< cmVersion::GetMinorVersion() << "\n\n";
}
@@ -850,9 +853,8 @@ void cmGlobalFastbuildGenerator::OpenBuildFileStream()
{
// Compute Fastbuild's build file path.
std::string buildFilePath =
this->GetCMakeInstance()->GetHomeOutputDirectory();
buildFilePath += "/";
buildFilePath += FASTBUILD_BUILD_FILE;
this->GetCMakeInstance()->GetHomeOutputDirectory() +
"/" FASTBUILD_BUILD_FILE;
// Get a stream where to generate things.
if (!this->BuildFileStream) {
@@ -1085,7 +1087,8 @@ void cmGlobalFastbuildGenerator::AddCompiler(std::string const& language,
compilerDef.ExtraFiles.emplace_back("$Root$/mspft140.dll");
compilerDef.ExtraFiles.emplace_back("$Root$/msvcp140.dll");
compilerDef.ExtraFiles.emplace_back("$Root$/vcruntime140.dll");
compilerDef.ExtraFiles.emplace_back("$Root$/" + i18nNum + "/clui.dll");
compilerDef.ExtraFiles.emplace_back(
cmStrCat("$Root$/", i18nNum, "/clui.dll"));
}
}
// TODO: Handle Intel compiler
@@ -1704,7 +1707,9 @@ void cmGlobalFastbuildGenerator::WriteSolution()
*this->BuildFileStream << "{\n";
WriteVariable("SolutionOutput",
Quote(cmJoin({ "VisualStudio", solutionName + ".sln" }, "/")),
Quote(cmStrCat("VisualStudio"
"/",
solutionName, ".sln")),
1);
auto const& configs = IDEProjects.begin()->second.first.ProjectConfigs;
@@ -1773,11 +1778,14 @@ void cmGlobalFastbuildGenerator::WriteXCodeTopLevelProject()
WriteCommand("XCodeProject", Quote("xcode"));
*this->BuildFileStream << "{\n";
WriteVariable(
"ProjectOutput",
Quote(
cmJoin({ "XCode", projectName + ".xcodeproj", "project.pbxproj" }, "/")),
1);
WriteVariable("ProjectOutput",
Quote(cmStrCat("XCode"
"/",
projectName,
".xcodeproj"
"/"
"project.pbxproj")),
1);
WriteVariable("ProjectBasePath", Quote(FASTBUILD_XCODE_BASE_PATH), 1);
auto const& configs = IDEProjects.begin()->second.second.ProjectConfigs;
@@ -1951,9 +1959,8 @@ std::string cmGlobalFastbuildGenerator::GetTargetName(
cmGeneratorTarget const* GeneratorTarget) const
{
std::string targetName =
GeneratorTarget->GetLocalGenerator()->GetCurrentBinaryDirectory();
targetName += "/";
targetName += GeneratorTarget->GetName();
cmStrCat(GeneratorTarget->GetLocalGenerator()->GetCurrentBinaryDirectory(),
'/', GeneratorTarget->GetName());
targetName = this->ConvertToFastbuildPath(targetName);
return targetName;
}
@@ -1981,8 +1988,8 @@ void cmGlobalFastbuildGenerator::AddIDEProject(
{
auto const& configs = GetConfigNames();
if (std::find(configs.begin(), configs.end(), config) == configs.end()) {
LogMessage("Config " + config + " doesn't exist, IDE project for " +
target.Name + " won't be generated");
LogMessage(cmStrCat("Config ", config, " doesn't exist, IDE project for ",
target.Name, " won't be generated"));
return;
}
auto& IDEProject = IDEProjects[target.BaseName];
@@ -1992,7 +1999,7 @@ void cmGlobalFastbuildGenerator::AddIDEProject(
auto& VSProject = IDEProject.first;
VSProject.Alias = cmStrCat(target.BaseName, FASTBUILD_VS_PROJECT_SUFFIX);
VSProject.ProjectOutput = cmStrCat("VisualStudio/Projects/", relativeSubdir,
'/', target.BaseName + ".vcxproj");
'/', target.BaseName, ".vcxproj");
VSProject.ProjectBasePath = target.BasePath;
VSProject.folder = relativeSubdir;
VSProject.deps = target.PreBuildDependencies;
@@ -2000,8 +2007,8 @@ void cmGlobalFastbuildGenerator::AddIDEProject(
auto& XCodeProject = IDEProject.second;
XCodeProject.Alias = target.BaseName + "-xcodeproj";
XCodeProject.ProjectOutput =
cmStrCat("XCode/Projects/", relativeSubdir, '/',
target.BaseName + ".xcodeproj/project.pbxproj");
cmStrCat("XCode/Projects/", relativeSubdir, '/', target.BaseName,
".xcodeproj/project.pbxproj");
XCodeProject.ProjectBasePath = target.BasePath;
IDEProjectConfig VSConfig;
@@ -2031,7 +2038,7 @@ bool cmGlobalFastbuildGenerator::Open(std::string const& bindir,
bool dryRun)
{
#ifdef _WIN32
std::string sln = bindir + "/VisualStudio/" + projectName + ".sln";
std::string sln = cmStrCat(bindir, "/VisualStudio/", projectName, ".sln");
if (dryRun) {
return cmSystemTools::FileExists(sln, true);
+10 -11
View File
@@ -94,7 +94,8 @@ std::string GeneratedMakeCommand::QuotedPrintable() const
flags |= cmOutputConverter::Shell_Flag_IsUnix;
#endif
for (auto const& arg : this->PrimaryCommand) {
output += cmStrCat(sep, cmOutputConverter::EscapeForShell(arg, flags));
output = cmStrCat(std::move(output), sep,
cmOutputConverter::EscapeForShell(arg, flags));
sep = " ";
}
return output;
@@ -285,7 +286,6 @@ void cmGlobalGenerator::ResolveLanguageCompiler(std::string const& lang,
cname = cmValue(cnameArgList.front());
}
std::string changeVars;
if (cname && !optional) {
cmCMakePath cachedPath;
if (!cmSystemTools::FileIsFullPath(*cname)) {
@@ -661,17 +661,18 @@ void cmGlobalGenerator::EnableLanguage(
bool fatalError = false;
mf->AddDefinitionBool("RUN_CONFIGURE", true);
std::string rootBin =
cmStrCat(this->CMakeInstance->GetHomeOutputDirectory(), "/CMakeFiles");
std::string rootBin;
// If the configuration files path has been set,
// then we are in a try compile and need to copy the enable language
// files from the parent cmake bin dir, into the try compile bin dir
if (!this->ConfiguredFilesPath.empty()) {
rootBin = this->ConfiguredFilesPath;
} else {
rootBin =
cmStrCat(this->CMakeInstance->GetHomeOutputDirectory(), "/CMakeFiles");
}
rootBin += '/';
rootBin += cmVersion::GetCMakeVersion();
rootBin = cmStrCat(std::move(rootBin), '/', cmVersion::GetCMakeVersion());
// set the dir for parent files so they can be used by modules
mf->AddDefinition("CMAKE_PLATFORM_INFO_DIR", rootBin);
@@ -2436,9 +2437,8 @@ void cmGlobalGenerator::CheckTargetProperties()
if (!notFoundMap.empty()) {
std::string notFoundVars;
for (auto const& notFound : notFoundMap) {
notFoundVars += notFound.first;
notFoundVars += notFound.second;
notFoundVars += '\n';
notFoundVars = cmStrCat(std::move(notFoundVars), notFound.first,
notFound.second, '\n');
}
cmSystemTools::Error(
cmStrCat("The following variables are used in this project, "
@@ -4166,8 +4166,7 @@ std::string cmGlobalGenerator::EscapeJSON(std::string const& s)
switch (i) {
case '"':
case '\\':
result += '\\';
result += i;
result = cmStrCat(std::move(result), '\\', i);
break;
case '\n':
result += "\\n";
+14 -12
View File
@@ -96,8 +96,8 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts,
}
/* set the build tool to use */
std::string gbuild(tsp + ((tsp.back() == '/') ? "" : "/") +
DEFAULT_BUILD_PROGRAM);
std::string gbuild =
cmStrCat(tsp, ((tsp.back() == '/') ? "" : "/"), DEFAULT_BUILD_PROGRAM);
cmValue prevTool = mf->GetDefinition("CMAKE_MAKE_PROGRAM");
/* check if the toolset changed from last generate */
@@ -177,7 +177,7 @@ void cmGlobalGhsMultiGenerator::GetToolset(cmMakefile* mf, std::string& tsp,
// Make sure root exists...
if (!cmSystemTools::PathExists(root)) {
std::string msg =
"GHS_TOOLSET_ROOT directory \"" + root + "\" does not exist.";
cmStrCat("GHS_TOOLSET_ROOT directory \"", root, "\" does not exist.");
mf->IssueMessage(MessageType::FATAL_ERROR, msg);
tsp = "";
return;
@@ -185,7 +185,7 @@ void cmGlobalGhsMultiGenerator::GetToolset(cmMakefile* mf, std::string& tsp,
// Add a directory separator
if (root.back() != '/') {
root += "/";
root += '/';
}
// Get all compiler directories in toolset root
@@ -194,7 +194,7 @@ void cmGlobalGhsMultiGenerator::GetToolset(cmMakefile* mf, std::string& tsp,
if (output.empty()) {
// No compiler directories found
std::string msg =
"No GHS toolsets found in GHS_TOOLSET_ROOT \"" + root + "\".";
cmStrCat("No GHS toolsets found in GHS_TOOLSET_ROOT \"", root, "\".");
mf->IssueMessage(MessageType::FATAL_ERROR, msg);
tsp = "";
} else {
@@ -210,7 +210,8 @@ void cmGlobalGhsMultiGenerator::GetToolset(cmMakefile* mf, std::string& tsp,
// or relative path.
tryPath = cmSystemTools::CollapseFullPath(ts, root);
if (!cmSystemTools::FileExists(tryPath)) {
std::string msg = "GHS toolset \"" + tryPath + "\" does not exist.";
std::string msg =
cmStrCat("GHS toolset \"", tryPath, "\" does not exist.");
mf->IssueMessage(MessageType::FATAL_ERROR, msg);
tsp = "";
} else {
@@ -343,7 +344,8 @@ void cmGlobalGhsMultiGenerator::WriteSubProjects(std::ostream& fout,
predefinedTargets.find(target->GetName()) != predefinedTargets.end();
if ((filterPredefined && predefinedTarget) ||
(!filterPredefined && !predefinedTarget)) {
fout << target->GetName() + ".tgt" + FILE_EXTENSION << " [Project]\n";
fout << cmStrCat(target->GetName(), ".tgt", FILE_EXTENSION)
<< " [Project]\n";
}
}
}
@@ -483,12 +485,12 @@ cmGlobalGhsMultiGenerator::GenerateBuildCommand(
if (jobs == cmake::DEFAULT_BUILD_PARALLEL_LEVEL) {
makeCommand.Add("-parallel");
} else {
makeCommand.Add(std::string("-parallel=") + std::to_string(jobs));
makeCommand.Add("-parallel=" + std::to_string(jobs));
}
}
/* determine the top-project file in the project directory */
std::string proj = projectName + ".top" + FILE_EXTENSION;
std::string proj = cmStrCat(projectName, ".top", FILE_EXTENSION);
std::vector<std::string> files;
cmSystemTools::Glob(projectDir, ".*\\.top\\.gpj", files);
if (!files.empty()) {
@@ -517,7 +519,7 @@ cmGlobalGhsMultiGenerator::GenerateBuildCommand(
if (build_all) {
/* transform name to default build */;
std::string all = std::string(this->GetAllTargetName()) + ".tgt.gpj";
std::string all = cmStrCat(this->GetAllTargetName(), ".tgt.gpj");
makeCommand.Add(all);
}
@@ -660,8 +662,8 @@ bool cmGlobalGhsMultiGenerator::AddCheckTarget()
cm::static_reference_cast<cmLocalGhsMultiGenerator>(generators[0]);
// The name of the output file for the custom command.
this->StampFile = lg.GetBinaryDirectory() + std::string("/CMakeFiles/") +
CHECK_BUILD_SYSTEM_TARGET;
this->StampFile = cmStrCat(lg.GetBinaryDirectory(), "/CMakeFiles/",
CHECK_BUILD_SYSTEM_TARGET);
// Add a custom rule to re-run CMake if any input files changed.
{
+1 -1
View File
@@ -258,7 +258,7 @@ int main()
cmSystemTools::ReplaceString(rest, "/nologo ", " ");
std::string clrest = rest;
if (haveNologo) {
rest = "/nologo " + rest;
rest = cmStrCat("/nologo ", std::move(rest));
}
// rc /fo X.dir\x.rc.res => cl -FoX.dir\x.rc.res.obj