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