Source: Reduce string allocations, part 4

This commit is contained in:
AJIOB
2026-09-22 11:37:41 +03:00
parent 1d2f0120be
commit 0aa1eaf506
25 changed files with 169 additions and 150 deletions
+22 -18
View File
@@ -106,7 +106,7 @@ std::vector<std::string> cmCPackIFWGenerator::BuildRepogenCommand()
std::string ifwArg = (*it)->Name;
++it;
while (it != this->DownloadedPackages.end()) {
ifwArg += "," + (*it)->Name;
ifwArg = cmStrCat(ifwArg, ',', (*it)->Name);
++it;
}
ifwCmd.emplace_back(ifwArg);
@@ -200,7 +200,7 @@ std::vector<std::string> cmCPackIFWGenerator::BuildBinaryCreatorCommand()
ifwArg = path + *it;
++it;
while (it != this->Installer.Resources.end()) {
ifwArg += "," + path + *it;
ifwArg = cmStrCat(ifwArg, ',', path, *it);
++it;
}
ifwCmd.emplace_back(ifwArg);
@@ -241,7 +241,7 @@ std::vector<std::string> cmCPackIFWGenerator::BuildBinaryCreatorCommand()
ifwArg = (*it)->Name;
++it;
while (it != this->DownloadedPackages.end()) {
ifwArg += "," + (*it)->Name;
ifwArg = cmStrCat(ifwArg, ',', (*it)->Name);
++it;
}
ifwCmd.emplace_back(ifwArg);
@@ -251,7 +251,7 @@ std::vector<std::string> cmCPackIFWGenerator::BuildBinaryCreatorCommand()
// Binary
auto bit = this->BinaryPackages.begin();
while (bit != this->BinaryPackages.end()) {
ifwArg += (*bit)->Name + ",";
ifwArg = cmStrCat(ifwArg, (*bit)->Name, ',');
++bit;
}
// Depend
@@ -259,7 +259,7 @@ std::vector<std::string> cmCPackIFWGenerator::BuildBinaryCreatorCommand()
ifwArg += it->second.Name;
++it;
while (it != this->DependentPackages.end()) {
ifwArg += "," + it->second.Name;
ifwArg = cmStrCat(ifwArg, ',', it->second.Name);
++it;
}
ifwCmd.emplace_back(ifwArg);
@@ -310,7 +310,8 @@ char const* cmCPackIFWGenerator::GetPackagingInstallPrefix()
std::string tmpPref = defPrefix ? defPrefix : "";
if (this->Components.empty()) {
tmpPref += "packages/" + this->GetRootPackageName() + "/data";
tmpPref =
cmStrCat(tmpPref, "packages/", this->GetRootPackageName(), "/data");
}
this->SetOption("CPACK_IFW_PACKAGING_INSTALL_PREFIX", tmpPref);
@@ -471,8 +472,9 @@ std::string cmCPackIFWGenerator::GetComponentInstallSuffix(
return cmStrCat(prefix, this->GetRootPackageName(), suffix);
}
return prefix +
this->GetComponentPackageName(&this->Components[componentName]) + suffix;
return cmStrCat(
prefix, this->GetComponentPackageName(&this->Components[componentName]),
suffix);
}
std::string cmCPackIFWGenerator::GetComponentInstallDirNameSuffix(
@@ -485,10 +487,11 @@ std::string cmCPackIFWGenerator::GetComponentInstallDirNameSuffix(
return cmStrCat(prefix, this->GetRootPackageName(), suffix);
}
return prefix +
return cmStrCat(
prefix,
this->GetSanitizedDirOrFileName(
this->GetComponentPackageName(&this->Components[componentName])) +
suffix;
this->GetComponentPackageName(&this->Components[componentName])),
suffix);
}
cmCPackComponent* cmCPackIFWGenerator::GetComponent(
@@ -624,15 +627,15 @@ std::string cmCPackIFWGenerator::GetGroupPackageName(
if (cmCPackIFWPackage* package = this->GetGroupPackage(group)) {
return package->Name;
}
cmValue option =
this->GetOption("CPACK_IFW_COMPONENT_GROUP_" +
cmsys::SystemTools::UpperCase(group->Name) + "_NAME");
cmValue option = this->GetOption(
cmStrCat("CPACK_IFW_COMPONENT_GROUP_",
cmsys::SystemTools::UpperCase(group->Name), "_NAME"));
name = option ? *option : group->Name;
if (group->ParentGroup) {
cmCPackIFWPackage* package = this->GetGroupPackage(group->ParentGroup);
bool dot = !this->ResolveDuplicateNames;
if (dot && !cmHasPrefix(name, package->Name)) {
name = package->Name + "." + name;
name = cmStrCat(package->Name, '.', name);
}
}
return name;
@@ -648,8 +651,9 @@ std::string cmCPackIFWGenerator::GetComponentPackageName(
if (cmCPackIFWPackage* package = this->GetComponentPackage(component)) {
return package->Name;
}
std::string prefix = "CPACK_IFW_COMPONENT_" +
cmsys::SystemTools::UpperCase(component->Name) + "_";
std::string prefix =
cmStrCat("CPACK_IFW_COMPONENT_",
cmsys::SystemTools::UpperCase(component->Name), '_');
cmValue option = this->GetOption(prefix + "NAME");
name = option ? *option : component->Name;
if (component->Group) {
@@ -661,7 +665,7 @@ std::string cmCPackIFWGenerator::GetComponentPackageName(
}
bool dot = !this->ResolveDuplicateNames;
if (dot && !cmHasPrefix(name, package->Name)) {
name = package->Name + "." + name;
name = cmStrCat(package->Name, '.', name);
}
}
return name;
+3 -2
View File
@@ -6,6 +6,7 @@
#include "cmCPackIFWGenerator.h"
#include "cmGeneratedFileStream.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmValue.h"
#include "cmXMLParser.h"
@@ -41,8 +42,8 @@ bool cmCPackIFWRepository::ConfigureFromOptions()
return false;
}
std::string prefix =
"CPACK_IFW_REPOSITORY_" + cmsys::SystemTools::UpperCase(this->Name) + "_";
std::string prefix = cmStrCat(
"CPACK_IFW_REPOSITORY_", cmsys::SystemTools::UpperCase(this->Name), '_');
// Update
if (this->IsOn(prefix + "ADD")) {
+43 -37
View File
@@ -182,21 +182,23 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile)
if (lang == "NONE") {
continue;
}
this->Compilers["CMAKE_" + lang + "_COMPILER"] = lang;
this->Compilers[cmStrCat("CMAKE_", lang, "_COMPILER")] = lang;
this->VariableMappings["CMAKE_" + lang + "_COMPILER"] =
this->Makefile->GetSafeDefinition("CMAKE_" + lang + "_COMPILER");
this->VariableMappings[cmStrCat("CMAKE_", lang, "_COMPILER")] =
this->Makefile->GetSafeDefinition(cmStrCat("CMAKE_", lang, "_COMPILER"));
std::string const& compilerArg1 = "CMAKE_" + lang + "_COMPILER_ARG1";
std::string const& compilerTarget = "CMAKE_" + lang + "_COMPILER_TARGET";
std::string const& compilerArg1 =
cmStrCat("CMAKE_", lang, "_COMPILER_ARG1");
std::string const& compilerTarget =
cmStrCat("CMAKE_", lang, "_COMPILER_TARGET");
std::string const& compilerOptionTarget =
"CMAKE_" + lang + "_COMPILE_OPTIONS_TARGET";
cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_TARGET");
std::string const& compilerExternalToolchain =
"CMAKE_" + lang + "_COMPILER_EXTERNAL_TOOLCHAIN";
cmStrCat("CMAKE_", lang, "_COMPILER_EXTERNAL_TOOLCHAIN");
std::string const& compilerOptionExternalToolchain =
"CMAKE_" + lang + "_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN";
cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN");
std::string const& compilerOptionSysroot =
"CMAKE_" + lang + "_COMPILE_OPTIONS_SYSROOT";
cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_SYSROOT");
this->VariableMappings[compilerArg1] =
this->Makefile->GetSafeDefinition(compilerArg1);
@@ -1204,7 +1206,7 @@ void cmLocalGenerator::AddCompileOptions(std::vector<BT<std::string>>& flags,
// Add compile flag for the MSVC compiler only.
cmMakefile* mf = this->GetMakefile();
if (cmValue jmc =
mf->GetDefinition("CMAKE_" + lang + "_COMPILE_OPTIONS_JMC")) {
mf->GetDefinition(cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_JMC"))) {
// Handle Just My Code debugging flags, /JMC.
// If the target is a Managed C++ one, /JMC is not compatible.
@@ -1709,7 +1711,8 @@ void cmLocalGenerator::GetTargetFlags(
}
if (this->Makefile->IsOn("BUILD_SHARED_LIBS")) {
std::string sFlagVar = "CMAKE_SHARED_BUILD_" + linkLanguage + "_FLAGS";
std::string sFlagVar =
cmStrCat("CMAKE_SHARED_BUILD_", linkLanguage, "_FLAGS");
exeFlags += this->Makefile->GetSafeDefinition(sFlagVar);
exeFlags += " ";
}
@@ -2002,7 +2005,7 @@ void cmLocalGenerator::OutputLinkLibraries(
std::string libPathFlag;
if (cmValue value = this->Makefile->GetDefinition(
"CMAKE_" + cli.GetLinkLanguage() + "_LIBRARY_PATH_FLAG")) {
cmStrCat("CMAKE_", cli.GetLinkLanguage(), "_LIBRARY_PATH_FLAG"))) {
libPathFlag = *value;
} else {
libPathFlag =
@@ -2010,8 +2013,8 @@ void cmLocalGenerator::OutputLinkLibraries(
}
std::string libPathTerminator;
if (cmValue value = this->Makefile->GetDefinition(
"CMAKE_" + cli.GetLinkLanguage() + "_LIBRARY_PATH_TERMINATOR")) {
if (cmValue value = this->Makefile->GetDefinition(cmStrCat(
"CMAKE_", cli.GetLinkLanguage(), "_LIBRARY_PATH_TERMINATOR"))) {
libPathTerminator = *value;
} else {
libPathTerminator =
@@ -2099,7 +2102,7 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
if (sysroot && *sysroot == "/") {
sysroot = nullptr;
}
std::string sysrootFlagVar = "CMAKE_" + lang + "_SYSROOT_FLAG";
std::string sysrootFlagVar = cmStrCat("CMAKE_", lang, "_SYSROOT_FLAG");
cmValue sysrootFlag = this->Makefile->GetDefinition(sysrootFlagVar);
if (cmNonempty(sysrootFlag)) {
if (!this->AppleArchSysroots.empty() &&
@@ -2110,7 +2113,7 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
continue;
}
if (filterArch.empty() || filterArch == arch) {
flags += " -Xarch_" + arch + " ";
flags = cmStrCat(flags, " -Xarch_", arch, " ");
// Combine sysroot flag and path to work with -Xarch
std::string arch_sysroot = *sysrootFlag + archSysroot;
flags += this->ConvertToOutputFormat(arch_sysroot, SHELL);
@@ -2128,7 +2131,7 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET");
if (cmNonempty(deploymentTarget)) {
std::string deploymentTargetFlagVar =
"CMAKE_" + lang + "_OSX_DEPLOYMENT_TARGET_FLAG";
cmStrCat("CMAKE_", lang, "_OSX_DEPLOYMENT_TARGET_FLAG");
cmValue deploymentTargetFlag =
this->Makefile->GetDefinition(deploymentTargetFlagVar);
if (cmNonempty(deploymentTargetFlag) &&
@@ -2272,16 +2275,16 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
*msvcRuntimeLibraryValue, this, config, target);
if (!msvcRuntimeLibrary.empty()) {
if (cmValue msvcRuntimeLibraryOptions = this->Makefile->GetDefinition(
"CMAKE_" + lang + "_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_" +
msvcRuntimeLibrary)) {
cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_",
msvcRuntimeLibrary))) {
this->AppendCompileOptions(flags, *msvcRuntimeLibraryOptions);
} else if (compilerTargetsMsvcABI &&
!cmSystemTools::GetErrorOccurredFlag()) {
// The compiler uses the MSVC ABI so it needs a known runtime library.
this->IssueMessage(MessageType::FATAL_ERROR,
"MSVC_RUNTIME_LIBRARY value '" +
msvcRuntimeLibrary + "' not known for this " +
lang + " compiler.");
this->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("MSVC_RUNTIME_LIBRARY value '", msvcRuntimeLibrary,
"' not known for this ", lang, " compiler."));
}
}
}
@@ -2299,18 +2302,19 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
std::string const watcomRuntimeLibrary = cmGeneratorExpression::Evaluate(
*watcomRuntimeLibraryValue, this, config, target);
if (!watcomRuntimeLibrary.empty()) {
if (cmValue watcomRuntimeLibraryOptions = this->Makefile->GetDefinition(
"CMAKE_" + lang + "_COMPILE_OPTIONS_WATCOM_RUNTIME_LIBRARY_" +
watcomRuntimeLibrary)) {
if (cmValue watcomRuntimeLibraryOptions =
this->Makefile->GetDefinition(cmStrCat(
"CMAKE_", lang, "_COMPILE_OPTIONS_WATCOM_RUNTIME_LIBRARY_",
watcomRuntimeLibrary))) {
this->AppendCompileOptions(flags, *watcomRuntimeLibraryOptions);
} else if (compilerTargetsWatcomABI &&
!cmSystemTools::GetErrorOccurredFlag()) {
// The compiler uses the Watcom ABI so it needs a known runtime
// library.
this->IssueMessage(MessageType::FATAL_ERROR,
"WATCOM_RUNTIME_LIBRARY value '" +
watcomRuntimeLibrary + "' not known for this " +
lang + " compiler.");
this->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("WATCOM_RUNTIME_LIBRARY value '", watcomRuntimeLibrary,
"' not known for this ", lang, " compiler."));
}
}
}
@@ -2526,7 +2530,8 @@ static void AddVisibilityCompileOption(std::string& flags,
cmLocalGenerator* lg,
std::string const& lang)
{
std::string compileOption = "CMAKE_" + lang + "_COMPILE_OPTIONS_VISIBILITY";
std::string compileOption =
cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_VISIBILITY");
cmValue opt = lg->GetMakefile()->GetDefinition(compileOption);
if (!opt) {
return;
@@ -3482,9 +3487,9 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target)
filename_base, pathMode);
} else {
// unity mode is set to an unsupported value
std::string e("Invalid UNITY_BUILD_MODE value of " + *unityMode +
" assigned to target " + target->GetName() +
". Acceptable values are BATCH and GROUP.");
std::string e(cmStrCat("Invalid UNITY_BUILD_MODE value of ", *unityMode,
" assigned to target ", target->GetName(),
". Acceptable values are BATCH and GROUP."));
this->IssueMessage(MessageType::FATAL_ERROR, e);
}
@@ -3719,7 +3724,7 @@ void cmLocalGenerator::AppendIPOLinkerFlags(std::string& flags,
return;
}
std::string const name = "CMAKE_" + lang + "_LINK_OPTIONS_IPO";
std::string const name = cmStrCat("CMAKE_", lang, "_LINK_OPTIONS_IPO");
cmValue rawFlagsList = this->Makefile->GetDefinition(name);
if (!rawFlagsList) {
return;
@@ -3752,12 +3757,13 @@ void cmLocalGenerator::AppendPositionIndependentLinkerFlags(
std::string const mode = cmIsOn(PICValue) ? "PIE" : "NO_PIE";
std::string supported = "CMAKE_" + lang + "_LINK_" + mode + "_SUPPORTED";
std::string supported =
cmStrCat("CMAKE_", lang, "_LINK_", mode, "_SUPPORTED");
if (this->Makefile->GetDefinition(supported).IsOff()) {
return;
}
std::string name = "CMAKE_" + lang + "_LINK_OPTIONS_" + mode;
std::string name = cmStrCat("CMAKE_", lang, "_LINK_OPTIONS_", mode);
auto pieFlags = this->Makefile->GetSafeDefinition(name);
if (pieFlags.empty()) {
+3 -3
View File
@@ -1441,11 +1441,11 @@ std::string cmLocalUnixMakefileGenerator3::CreateMakeVariable(
char buffer[12];
int ni = 0;
snprintf(buffer, sizeof(buffer), "%04d", ni);
ret = str1 + str2 + buffer;
ret = cmStrCat(str1, str2, buffer);
while (this->ShortMakeVariableMap.count(ret) && ni < 1000) {
++ni;
snprintf(buffer, sizeof(buffer), "%04d", ni);
ret = str1 + str2 + buffer;
ret = cmStrCat(str1, str2, buffer);
}
if (ni == 1000) {
cmSystemTools::Error("Borland makefile variable length too long");
@@ -2385,7 +2385,7 @@ void cmLocalUnixMakefileGenerator3::CreateCDCommand(
// directory and build because make resets the directory between
// each command.
std::string outputForExisting = this->ConvertToOutputForExisting(tgtDir);
std::string prefix = cd_cmd + outputForExisting + " && ";
std::string prefix = cmStrCat(cd_cmd, outputForExisting, " && ");
std::transform(commands.begin(), commands.end(), commands.begin(),
[&prefix](std::string const& s) { return prefix + s; });
}
+3 -2
View File
@@ -5,6 +5,7 @@
#include "cmDiagnostics.h"
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
// cmMakeDirectoryCommand
@@ -22,8 +23,8 @@ bool cmMakeDirectoryCommand(std::vector<std::string> const& args,
return false;
}
if (!mf.CanIWriteThisFile(args[0])) {
std::string e = "attempted to create a directory: " + args[0] +
" into a source directory.";
std::string e = cmStrCat("attempted to create a directory: ", args[0],
" into a source directory.");
status.SetError(e);
cmSystemTools::SetFatalErrorOccurred();
return false;
+7 -7
View File
@@ -2845,10 +2845,10 @@ MessageType cmMakefile::ExpandVariablesInStringImpl(
lookup.domain = CACHE;
} else {
if (this->cmNamedCurly.find(next)) {
errorstr = "Syntax $" +
std::string(next, this->cmNamedCurly.end()) +
"{} is not supported. Only ${}, $ENV{}, "
"and $CACHE{} are allowed.";
errorstr = cmStrCat("Syntax $",
std::string(next, this->cmNamedCurly.end()),
"{} is not supported. Only ${}, $ENV{}, "
"and $CACHE{} are allowed.");
mtype = MessageType::FATAL_ERROR;
error = true;
}
@@ -3424,9 +3424,9 @@ int cmMakefile::TryCompile(std::string const& srcdir,
auto gg = cm.CreateGlobalGenerator(this->GetGlobalGenerator()->GetName());
if (!gg) {
this->IssueMessage(MessageType::INTERNAL_ERROR,
"Global generator '" +
this->GetGlobalGenerator()->GetName() +
"' could not be created.");
cmStrCat("Global generator '",
this->GetGlobalGenerator()->GetName(),
"' could not be created."));
cmSystemTools::SetFatalErrorOccurred();
this->IsSourceFileTryCompile = false;
return 1;
+10 -9
View File
@@ -99,8 +99,8 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule(
// Get the name of the device object to generate.
std::string const& objExt =
this->Makefile->GetSafeDefinition("CMAKE_CUDA_OUTPUT_EXTENSION");
std::string const targetOutput =
this->GeneratorTarget->ObjectDirectory + "cmake_device_link" + objExt;
std::string const targetOutput = cmStrCat(
this->GeneratorTarget->ObjectDirectory, "cmake_device_link", objExt);
this->DeviceLinkObject = targetOutput;
this->NumberOfProgressActions++;
@@ -347,8 +347,9 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Make sure we have a link language.
if (linkLanguage.empty()) {
cmSystemTools::Error("Cannot determine link language for target \"" +
this->GeneratorTarget->GetName() + "\".");
cmSystemTools::Error(
cmStrCat("Cannot determine link language for target \"",
this->GeneratorTarget->GetName(), "\"."));
return;
}
@@ -528,11 +529,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
this->CreateObjectLists(useLinkScript, false, useResponseFileForObjects,
buildObjs, depends, useWatcomQuote, linkLanguage);
if (!this->DeviceLinkObject.empty()) {
buildObjs += " " +
this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->MaybeRelativeToCurBinDir(
this->DeviceLinkObject),
cmOutputConverter::SHELL);
buildObjs = cmStrCat(buildObjs, ' ',
this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->MaybeRelativeToCurBinDir(
this->DeviceLinkObject),
cmOutputConverter::SHELL));
}
// maybe create .def file from list of objects
+10 -9
View File
@@ -270,8 +270,8 @@ void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules(
this->Makefile->GetSafeDefinition("CMAKE_CUDA_OUTPUT_EXTENSION");
// Get the name of the device object to generate.
std::string const targetOutput =
this->GeneratorTarget->ObjectDirectory + "cmake_device_link" + objExt;
std::string const targetOutput = cmStrCat(
this->GeneratorTarget->ObjectDirectory, "cmake_device_link", objExt);
this->DeviceLinkObject = targetOutput;
this->NumberOfProgressActions++;
@@ -466,8 +466,9 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
// Make sure we have a link language.
if (linkLanguage.empty()) {
cmSystemTools::Error("Cannot determine link language for target \"" +
this->GeneratorTarget->GetName() + "\".");
cmSystemTools::Error(
cmStrCat("Cannot determine link language for target \"",
this->GeneratorTarget->GetName(), "\"."));
return;
}
@@ -764,11 +765,11 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
useResponseFileForObjects, buildObjs, depends,
useWatcomQuote, linkLanguage, responseMode);
if (!this->DeviceLinkObject.empty()) {
buildObjs += " " +
this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->MaybeRelativeToCurBinDir(
this->DeviceLinkObject),
cmOutputConverter::SHELL);
buildObjs = cmStrCat(buildObjs, ' ',
this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->MaybeRelativeToCurBinDir(
this->DeviceLinkObject),
cmOutputConverter::SHELL));
}
std::string const& aixExports = this->GetAIXExports(this->GetConfigName());
+11 -11
View File
@@ -990,7 +990,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
std::string includesString = this->LocalGenerator->GetIncludeFlags(
includes, this->GeneratorTarget, lang, config);
this->LocalGenerator->AppendFlags(includesString,
"$(" + lang + "_INCLUDES)");
cmStrCat("$(", lang, "_INCLUDES)"));
vars.Includes = includesString.c_str();
std::string dependencyTarget;
@@ -1061,7 +1061,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
cmList compileCommands;
std::string const& compileRule = this->Makefile->GetRequiredDefinition(
"CMAKE_" + lang + "_COMPILE_OBJECT");
cmStrCat("CMAKE_", lang, "_COMPILE_OBJECT"));
compileCommands.assign(compileRule);
if (this->GeneratorTarget->GetPropertyAsBool("EXPORT_COMPILE_COMMANDS") &&
@@ -1078,13 +1078,13 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
compileCommand.replace(lfPos, langFlags.size(),
this->GetFlags(lang, this->GetConfigName()));
}
std::string const langDefines = std::string("$(") + lang + "_DEFINES)";
std::string const langDefines = cmStrCat("$(", lang, "_DEFINES)");
std::string::size_type const ldPos = compileCommand.find(langDefines);
if (ldPos != std::string::npos) {
compileCommand.replace(ldPos, langDefines.size(),
this->GetDefines(lang, this->GetConfigName()));
}
std::string const langIncludes = std::string("$(") + lang + "_INCLUDES)";
std::string const langIncludes = cmStrCat("$(", lang, "_INCLUDES)");
std::string::size_type const liPos = compileCommand.find(langIncludes);
if (liPos != std::string::npos) {
compileCommand.replace(liPos, langIncludes.size(),
@@ -2154,7 +2154,7 @@ bool cmMakefileTargetGenerator::CheckUseResponseFileForObjects(
{
// Check for an explicit setting one way or the other.
std::string const responseVar =
"CMAKE_" + l + "_USE_RESPONSE_FILE_FOR_OBJECTS";
cmStrCat("CMAKE_", l, "_USE_RESPONSE_FILE_FOR_OBJECTS");
if (cmValue val = this->Makefile->GetDefinition(responseVar)) {
if (!val->empty()) {
return val.IsOn();
@@ -2193,7 +2193,7 @@ bool cmMakefileTargetGenerator::CheckUseResponseFileForLibraries(
{
// Check for an explicit setting one way or the other.
std::string const responseVar =
"CMAKE_" + l + "_USE_RESPONSE_FILE_FOR_LIBRARIES";
cmStrCat("CMAKE_", l, "_USE_RESPONSE_FILE_FOR_LIBRARIES");
if (cmValue val = this->Makefile->GetDefinition(responseVar)) {
if (!val->empty()) {
return val.IsOn();
@@ -2260,7 +2260,7 @@ void cmMakefileTargetGenerator::CreateLinkLibs(
std::string linkPath;
this->LocalGenerator->OutputLinkLibraries(pcli, linkLineComputer, linkLibs,
frameworkPath, linkPath);
linkLibs = frameworkPath + linkPath + linkLibs;
linkLibs = cmStrCat(frameworkPath, linkPath, linkLibs);
}
if (useResponseFile &&
@@ -2350,9 +2350,9 @@ bool cmMakefileTargetGenerator::CreateRustLinkArguments(
this->GeneratorTarget->GetRustMainCrateRoot(this->GetConfigName());
if (!mainCrateRoot) {
this->Makefile->IssueMessage(MessageType::FATAL_ERROR,
"Target " +
this->GeneratorTarget->GetName() +
" has no main crate root.");
cmStrCat("Target ",
this->GeneratorTarget->GetName(),
" has no main crate root."));
return false;
}
rustMainCrateRootPath = mainCrateRoot->GetFullPath();
@@ -2384,7 +2384,7 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
if (useResponseFile) {
std::string const responseFlagVar =
"CMAKE_" + lang + "_RESPONSE_FILE_FLAG";
cmStrCat("CMAKE_", lang, "_RESPONSE_FILE_FLAG");
std::string responseFlag =
this->Makefile->GetSafeDefinition(responseFlagVar);
if (responseFlag.empty()) {
+2 -2
View File
@@ -55,8 +55,8 @@ void ReportCheckResult(cm::string_view what, std::string result,
cmMakefile& mf)
{
if (mf.GetCMakeInstance()->HasCheckInProgress()) {
auto text = mf.GetCMakeInstance()->GetTopCheckInProgressMessage() + " - " +
std::move(result);
auto text = cmStrCat(mf.GetCMakeInstance()->GetTopCheckInProgressMessage(),
" - ", std::move(result));
mf.DisplayStatus(IndentText(std::move(text), mf), -1);
} else {
mf.GetMessenger()->DisplayMessage(
+8 -7
View File
@@ -268,7 +268,7 @@ bool cmNinjaNormalTargetGenerator::CheckUseResponseFileForLibraries(
{
// Check for an explicit setting one way or the other.
std::string const responseVar =
"CMAKE_" + l + "_USE_RESPONSE_FILE_FOR_LIBRARIES";
cmStrCat("CMAKE_", l, "_USE_RESPONSE_FILE_FOR_LIBRARIES");
// If the option is defined, read it's value
if (cmValue val = this->Makefile->GetDefinition(responseVar)) {
@@ -864,8 +864,8 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement(
globalGen->ConfigDirectory(config), '/'));
targetOutputDir = globalGen->ExpandCFGIntDir(targetOutputDir, config);
std::string targetOutputReal =
this->ConvertToNinjaPath(targetOutputDir + "cmake_device_link" + objExt);
std::string targetOutputReal = this->ConvertToNinjaPath(
cmStrCat(targetOutputDir, "cmake_device_link", objExt));
if (firstForConfig) {
globalGen->GetByproductsForCleanTarget(config).push_back(targetOutputReal);
@@ -1309,9 +1309,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
// step.
cmSourceFile const* mainCrateRoot = gt->GetRustMainCrateRoot(config);
if (!mainCrateRoot) {
this->Makefile->IssueMessage(MessageType::FATAL_ERROR,
"Target " + gt->GetName() +
" has no main crate root.");
this->Makefile->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Target ", gt->GetName(), " has no main crate root."));
return;
}
std::string mainCrateRootPath =
@@ -1469,7 +1469,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
if (cmValue d = mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX")) {
dbg_suffix = *d;
}
vars["TARGET_PDB"] = components.base + components.suffix + dbg_suffix;
vars["TARGET_PDB"] =
cmStrCat(components.base, components.suffix, dbg_suffix);
}
std::string const objPath =
+3 -2
View File
@@ -72,8 +72,9 @@ void cmOSXBundleGenerator::CreateFramework(
this->GT->GetFrameworkDirectory(config, cmGeneratorTarget::ContentLevel),
'/');
std::string newoutpath = outpath + "/" +
this->GT->GetFrameworkDirectory(config, cmGeneratorTarget::FullLevel);
std::string newoutpath = cmStrCat(
outpath, '/',
this->GT->GetFrameworkDirectory(config, cmGeneratorTarget::FullLevel));
std::string frameworkVersion = this->GT->GetFrameworkVersion();
+7 -7
View File
@@ -106,8 +106,8 @@ bool cmProjectCommand(std::vector<std::string> const& args,
return false;
}
if (!IncludeByVariable(status,
"CMAKE_PROJECT_" + projectName + "_INCLUDE_BEFORE")) {
if (!IncludeByVariable(
status, cmStrCat("CMAKE_PROJECT_", projectName, "_INCLUDE_BEFORE"))) {
return false;
}
@@ -202,7 +202,7 @@ bool cmProjectCommand(std::vector<std::string> const& args,
if (prArgs.Version) {
if (!vx.find(*prArgs.Version)) {
std::string e =
R"(VERSION ")" + *prArgs.Version + R"(" format invalid.)";
cmStrCat(R"(VERSION ")", *prArgs.Version, R"(" format invalid.)");
mf.IssueMessage(MessageType::FATAL_ERROR, e);
cmSystemTools::SetFatalErrorOccurred();
return true;
@@ -242,8 +242,8 @@ bool cmProjectCommand(std::vector<std::string> const& args,
if (prArgs.CompatVersion) {
if (!vx.find(*prArgs.CompatVersion)) {
std::string e =
R"(COMPAT_VERSION ")" + *prArgs.CompatVersion + R"(" format invalid.)";
std::string e = cmStrCat(R"(COMPAT_VERSION ")", *prArgs.CompatVersion,
R"(" format invalid.)");
mf.IssueMessage(MessageType::FATAL_ERROR, e);
cmSystemTools::SetFatalErrorOccurred();
return true;
@@ -319,8 +319,8 @@ bool cmProjectCommand(std::vector<std::string> const& args,
return false;
}
if (!IncludeByVariable(status,
"CMAKE_PROJECT_" + projectName + "_INCLUDE")) {
if (!IncludeByVariable(
status, cmStrCat("CMAKE_PROJECT_", projectName, "_INCLUDE"))) {
return false;
}
+1 -1
View File
@@ -952,7 +952,7 @@ bool cmQtAutoGenInitializer::InitRcc()
this->GenTarget->GetSafeProperty(kw.AUTORCC_OPTIONS);
std::string const nozstd = "--no-zstd";
if (rccOptions.find(nozstd) == std::string::npos) {
rccOptions.append(";" + nozstd + ";");
rccOptions.append(cmStrCat(';', nozstd, ';'));
}
this->GenTarget->Target->SetProperty(kw.AUTORCC_OPTIONS, rccOptions);
}
+6 -5
View File
@@ -1438,7 +1438,7 @@ bool cmQtAutoMocUicT::JobEvalCacheMocT::EvalSource(
this->MocConst().MacrosString(),
" macro.\nRunning moc on the header\n ",
this->MessagePath(headerHandle->FileName), "!\nBetter include ",
this->MessagePath("moc_" + incKey.Base + ".cpp"),
this->MessagePath(cmStrCat("moc_", incKey.Base, ".cpp")),
" for a compatibility with regular mode.\n"
"This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n"));
} else {
@@ -1447,10 +1447,10 @@ bool cmQtAutoMocUicT::JobEvalCacheMocT::EvalSource(
cmStrCat(
this->MessagePath(sourceFile.FileName), "\nincludes the moc file ",
this->MessagePath(incKey.Key), " instead of ",
this->MessagePath("moc_" + incKey.Base + ".cpp"),
this->MessagePath(cmStrCat("moc_", incKey.Base, ".cpp")),
".\nRunning moc on the header\n ",
this->MessagePath(headerHandle->FileName), "!\nBetter include ",
this->MessagePath("moc_" + incKey.Base + ".cpp"),
this->MessagePath(cmStrCat("moc_", incKey.Base, ".cpp")),
" for compatibility with regular mode.\n"
"This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n"));
}
@@ -2219,8 +2219,9 @@ void cmQtAutoMocUicT::JobCompileMocT::Process()
}
if (!cmSystemTools::FileExists(depfile)) {
this->Log().Warning(GenT::MOC,
"Dependency file " + this->MessagePath(depfile) +
" does not exist.");
cmStrCat("Dependency file ",
this->MessagePath(depfile),
" does not exist."));
return;
}
this->CacheEntry->Moc.Depends =
+2 -2
View File
@@ -115,7 +115,7 @@ void cmRST::ProcessModule(std::istream& is)
if (line == "#.rst:") {
rst = "#";
} else if (this->ModuleRST.find(line)) {
rst = "]" + this->ModuleRST.match(1) + "]";
rst = cmStrCat(']', this->ModuleRST.match(1), ']');
}
}
}
@@ -403,7 +403,7 @@ bool cmRST::ProcessInclude(std::string file, Include type)
if (file[0] == '/') {
file = this->DocRoot + file;
} else {
file = this->DocDir + "/" + file;
file = cmStrCat(this->DocDir, '/', file);
}
found = r.ProcessFile(file, type == Include::Module);
if (type == Include::TocTree) {
+1 -1
View File
@@ -655,7 +655,7 @@ void cmSbomBuilder::ResolveTargetsInGeneratorExpressions(
} else {
this->ResolveTargetsInGeneratorExpression(li, target, lg);
}
input += sep + li;
input = cmStrCat(input, sep, li);
sep = ";";
}
}
+4 -4
View File
@@ -35,17 +35,17 @@ bool cmSubdirCommand(std::vector<std::string> const& args,
}
// if they specified a relative path then compute the full
std::string srcPath = mf.GetCurrentSourceDirectory() + "/" + i;
std::string srcPath = cmStrCat(mf.GetCurrentSourceDirectory(), '/', i);
if (cmSystemTools::FileIsDirectory(srcPath)) {
std::string binPath = mf.GetCurrentBinaryDirectory() + "/" + i;
std::string binPath = cmStrCat(mf.GetCurrentBinaryDirectory(), '/', i);
mf.AddSubDirectory(srcPath, binPath, excludeFromAll, false, false);
}
// otherwise it is a full path
else if (cmSystemTools::FileIsDirectory(i)) {
// we must compute the binPath from the srcPath, we just take the last
// element from the source path and use that
std::string binPath = mf.GetCurrentBinaryDirectory() + "/" +
cmSystemTools::GetFilenameName(i);
std::string binPath = cmStrCat(mf.GetCurrentBinaryDirectory(), '/',
cmSystemTools::GetFilenameName(i));
mf.AddSubDirectory(i, binPath, excludeFromAll, false, false);
} else {
status.SetError(cmStrCat("Incorrect SUBDIRS command. Directory: ", i,
+1 -2
View File
@@ -2726,8 +2726,7 @@ bool extract_tar(std::string const& arFileName,
while ((ar = archive_match_path_unmatched_inclusions_next(matching, &p)) ==
ARCHIVE_OK) {
cmSystemTools::Error("tar: " + std::string(p) +
": Not found in archive");
cmSystemTools::Error(cmStrCat("tar: ", p, ": Not found in archive"));
error_occurred = true;
}
if (error_occurred) {
+12 -12
View File
@@ -1550,24 +1550,24 @@ std::string cmTarget::GetDebugGeneratorExpressions(
std::vector<std::string> debugConfigs =
this->impl->Makefile->GetCMakeInstance()->GetDebugConfigs();
std::string configString = "$<CONFIG:" + debugConfigs[0] + ">";
std::string configString = cmStrCat("$<CONFIG:", debugConfigs[0], '>');
if (debugConfigs.size() > 1) {
for (std::string const& conf : cmMakeRange(debugConfigs).advance(1)) {
configString += ",$<CONFIG:" + conf + ">";
configString = cmStrCat(configString, ",$<CONFIG:", conf, '>');
}
configString = "$<OR:" + configString + ">";
configString = cmStrCat("$<OR:", configString, '>');
}
if (llt == OPTIMIZED_LibraryType) {
configString = "$<NOT:" + configString + ">";
configString = cmStrCat("$<NOT:", configString, '>');
}
return "$<" + configString + ":" + value + ">";
return cmStrCat("$<", configString, ':', value, '>');
}
static std::string targetNameGenex(std::string const& lib)
{
return "$<TARGET_NAME:" + lib + ">";
return cmStrCat("$<TARGET_NAME:", lib, '>');
}
bool cmTarget::PushTLLCommandTrace(TLLSignature signature,
@@ -2528,7 +2528,7 @@ void cmTarget::AppendBuildInterfaceIncludes()
dirs += this->impl->Makefile->GetCurrentSourceDirectory();
if (!dirs.empty()) {
this->AppendProperty("INTERFACE_INCLUDE_DIRECTORIES",
("$<BUILD_INTERFACE:" + dirs + ">"));
(cmStrCat("$<BUILD_INTERFACE:", dirs, '>')));
}
}
}
@@ -3525,16 +3525,16 @@ bool cmTargetInternals::CheckImportedLibName(std::string const& prop,
if (!value.empty()) {
if (value[0] == '-') {
this->Makefile->IssueMessage(MessageType::FATAL_ERROR,
prop + " property value\n " + value +
"\nmay not start with '-'.");
cmStrCat(prop, " property value\n ", value,
"\nmay not start with '-'."));
return false;
}
std::string::size_type bad = value.find_first_of(":/\\;");
if (bad != std::string::npos) {
this->Makefile->IssueMessage(MessageType::FATAL_ERROR,
prop + " property value\n " + value +
"\nmay not contain '" +
value.substr(bad, 1) + "'.");
cmStrCat(prop, " property value\n ", value,
"\nmay not contain '",
value.substr(bad, 1), "'."));
return false;
}
}
+2 -2
View File
@@ -42,9 +42,9 @@ private:
std::string sep;
for (std::string const& it : content) {
if (cmHasLiteralPrefix(it, "-D")) {
defs += sep + it.substr(2);
defs = cmStrCat(defs, sep, it.substr(2));
} else {
defs += sep + it;
defs = cmStrCat(defs, sep, it);
}
sep = ";";
}
+1 -1
View File
@@ -462,7 +462,7 @@ bool TLL::HandleLibrary(ProcessingState currentProcessingState,
this->Target->GetDebugGeneratorExpressions(lib, llt);
if (cmGeneratorExpression::IsValidTargetName(lib) ||
cmGeneratorExpression::Find(lib) != std::string::npos) {
configLib = "$<LINK_ONLY:" + configLib + ">";
configLib = cmStrCat("$<LINK_ONLY:", configLib, '>');
}
this->AppendProperty("INTERFACE_LINK_LIBRARIES", configLib);
}
+2 -1
View File
@@ -518,7 +518,8 @@ void TryRunCommandImpl::DoNotRunExecutable(
"appropriately:\n ",
this->RunResultVariable, " (advanced)\n");
if (out) {
errorMessage += " " + internalRunOutputName + " (advanced)\n";
errorMessage =
cmStrCat(errorMessage, " ", internalRunOutputName, " (advanced)\n");
}
errorMessage += detailsString;
cmSystemTools::Error(errorMessage);
+2 -1
View File
@@ -9,6 +9,7 @@
#include "cmsys/FStream.hxx"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
class CompileCommandParser
@@ -102,7 +103,7 @@ private:
void ExpectOrDie(char c, std::string const& message)
{
if (!this->Expect(c)) {
this->ErrorExit(std::string("'") + c + "' expected " + message + ".");
this->ErrorExit(cmStrCat('\'', c, "' expected ", message, '.'));
}
}
+3 -2
View File
@@ -25,6 +25,7 @@
# include "cmDebuggerPosixPipeConnection.h"
#endif
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#ifdef _WIN32
@@ -36,8 +37,8 @@ static void sendCommands(std::shared_ptr<dap::ReaderWriter> const& debugger,
std::vector<std::string> const& initCommands)
{
for (auto const& command : initCommands) {
std::string contentLength = "Content-Length:";
contentLength += std::to_string(command.size()) + "\r\n\r\n";
std::string contentLength =
cmStrCat("Content-Length:", command.size(), "\r\n\r\n");
debugger->write(contentLength.c_str(), contentLength.size());
if (!debugger->write(command.c_str(), command.size())) {
std::cout << "debugger write error" << std::endl;