diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index 1560575ba7..d12d905b34 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -106,7 +106,7 @@ std::vector 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 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 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 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 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; diff --git a/Source/CPack/IFW/cmCPackIFWRepository.cxx b/Source/CPack/IFW/cmCPackIFWRepository.cxx index 67ef536063..b3dbec5f78 100644 --- a/Source/CPack/IFW/cmCPackIFWRepository.cxx +++ b/Source/CPack/IFW/cmCPackIFWRepository.cxx @@ -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")) { diff --git a/Source/CPack/cmCPackAppImageGenerator.cxx b/Source/CPack/cmCPackAppImageGenerator.cxx index 03dffab464..1965d88257 100644 --- a/Source/CPack/cmCPackAppImageGenerator.cxx +++ b/Source/CPack/cmCPackAppImageGenerator.cxx @@ -80,8 +80,9 @@ int cmCPackAppImageGenerator::PackageFiles() cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Found Desktop file: \"" << desktopFile.value() << "\"" << std::endl); - std::string desktopSymLink = this->toplevel + "/" + - cmSystemTools::GetFilenameName(desktopFile.value()); + std::string desktopSymLink = + cmStrCat(this->toplevel, '/', + cmSystemTools::GetFilenameName(desktopFile.value())); cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Desktop file destination: \"" << desktopSymLink << "\"" << std::endl); @@ -139,7 +140,7 @@ int cmCPackAppImageGenerator::PackageFiles() cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Icon file: \"" << *iconFile << "\"" << std::endl); std::string iconSymLink = - this->toplevel + "/" + cmSystemTools::GetFilenameName(*iconFile); + cmStrCat(this->toplevel, '/', cmSystemTools::GetFilenameName(*iconFile)); cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Icon link destination: \"" << iconSymLink << "\"" << std::endl); @@ -239,8 +240,9 @@ int cmCPackAppImageGenerator::PackageFiles() this->AppimagetoolPath, this->toplevel, }; - command.emplace_back("../" + *this->GetOption("CPACK_PACKAGE_FILE_NAME") + - this->GetOutputExtension()); + command.emplace_back(cmStrCat("../", + *this->GetOption("CPACK_PACKAGE_FILE_NAME"), + this->GetOutputExtension())); auto addOptionFlag = [&command, this](std::string const& op, std::string commandFlag) { diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index e937fe01ea..15766e6532 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -286,8 +286,8 @@ std::string cmCPackArchiveGenerator::GetArchiveComponentFileName( std::string componentUpper(cmSystemTools::UpperCase(component)); std::string packageFileName; - if (cmValue v = this->GetOptionIfSet("CPACK_ARCHIVE_" + componentUpper + - "_FILE_NAME")) { + if (cmValue v = this->GetOptionIfSet( + cmStrCat("CPACK_ARCHIVE_", componentUpper, "_FILE_NAME"))) { packageFileName += *v; } else if ((v = this->GetOptionIfSet("CPACK_ARCHIVE_FILE_NAME"))) { packageFileName += @@ -328,8 +328,9 @@ int cmCPackArchiveGenerator::addOneComponentToArchive( cmCPackLogger(cmCPackLog::LOG_VERBOSE, " - packaging component: " << component->Name << std::endl); // Add the files of this component to the archive - std::string localToplevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); - localToplevel += "/" + this->GetSanitizedDirOrFileName(component->Name); + std::string localToplevel( + cmStrCat(this->GetOption("CPACK_TEMPORARY_DIRECTORY"), '/', + this->GetSanitizedDirOrFileName(component->Name))); // Change to local toplevel cmWorkingDirectory workdir(localToplevel); if (workdir.Failed()) { @@ -426,8 +427,9 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup) cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: " << compG.first << std::endl); // Begin the archive for this group - std::string packageFileName = std::string(this->toplevel) + "/" + - this->GetArchiveComponentFileName(compG.first, true); + std::string packageFileName = + cmStrCat(this->toplevel, '/', + this->GetArchiveComponentFileName(compG.first, true)); Deduplicator deduplicator; @@ -455,8 +457,9 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup) << "> does not belong to any group, package it separately." << std::endl); std::string packageFileName = std::string(this->toplevel); - packageFileName += - "/" + this->GetArchiveComponentFileName(comp.first, false); + packageFileName = + cmStrCat(packageFileName, '/', + this->GetArchiveComponentFileName(comp.first, false)); { DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive); @@ -473,8 +476,9 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup) else { for (auto& comp : this->Components) { std::string packageFileName = std::string(this->toplevel); - packageFileName += - "/" + this->GetArchiveComponentFileName(comp.first, false); + packageFileName = + cmStrCat(packageFileName, '/', + this->GetArchiveComponentFileName(comp.first, false)); { DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive); diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 289866b44f..8f3c56ba06 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -520,9 +520,10 @@ bool DebGenerator::generateDeb() const deb.SetUNAMEAndGNAME("root", "root"); if (!deb.Add(tlDir + "debian-binary", tlDir.length()) || - !deb.Add(tlDir + "control.tar" + this->CompressionSuffix, + !deb.Add(cmStrCat(tlDir, "control.tar", this->CompressionSuffix), tlDir.length()) || - !deb.Add(tlDir + "data.tar" + this->CompressionSuffix, tlDir.length())) { + !deb.Add(cmStrCat(tlDir, "data.tar", this->CompressionSuffix), + tlDir.length())) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Error creating debian package:\n" "#top level directory: " @@ -919,8 +920,8 @@ bool cmCPackDebGenerator::createDbgsymDDeb() controlValues["Version"] = *debian_pkg_version; controlValues["Auto-Built-Package"] = "debug-symbols"; controlValues["Depends"] = - *this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_NAME") + std::string(" (= ") + - *debian_pkg_version + ")"; + cmStrCat(*this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_NAME"), + " (= ", *debian_pkg_version, ')'); controlValues["Section"] = "debug"; controlValues["Priority"] = "optional"; controlValues["Architecture"] = @@ -973,8 +974,8 @@ std::string cmCPackDebGenerator::GetComponentInstallSuffix( } // We have to find the name of the COMPONENT GROUP // the current COMPONENT belongs to. - std::string groupVar = - "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP"; + std::string groupVar = cmStrCat( + "CPACK_COMPONENT_", cmSystemTools::UpperCase(componentName), "_GROUP"); if (cmValue v = this->GetOption(groupVar)) { return *v; } diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index bc95f5b444..aaefa96d8a 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -114,7 +114,7 @@ int cmCPackGenerator::PrepareNames() // Determine temporary packaging-directory. std::string tmpDirectory = cmStrCat(topDirectory, '/', pkgBaseFileName); // Determine path to temporary package file. - std::string tmpPkgFilePath = topDirectory + "/" + pkgFileName; + std::string tmpPkgFilePath = cmStrCat(topDirectory, '/', pkgFileName); // Set CPack variables which are not set already. this->SetOptionIfNotSet("CPACK_REMOVE_TOPLEVEL_DIRECTORY", "1"); @@ -620,8 +620,9 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( if (this->SupportsComponentInstallation() && !(this->IsOn("CPACK_MONOLITHIC_INSTALL"))) { // Determine the installation types for this project (if provided). - std::string installTypesVar = "CPACK_" + - cmSystemTools::UpperCase(project.Component) + "_INSTALL_TYPES"; + std::string installTypesVar = + cmStrCat("CPACK_", cmSystemTools::UpperCase(project.Component), + "_INSTALL_TYPES"); cmValue installTypes = this->GetOption(installTypesVar); if (!installTypes.IsEmpty()) { cmList installTypesList{ installTypes }; @@ -837,7 +838,7 @@ int cmCPackGenerator::InstallCMakeProject( if (cmHasPrefix(dir, '/')) { dir = tempInstallDirectory + dir; } else { - dir = tempInstallDirectory + "/" + dir; + dir = cmStrCat(tempInstallDirectory, '/', dir); } /* * We must re-set DESTDIR for each component @@ -987,8 +988,8 @@ int cmCPackGenerator::InstallCMakeProject( // define component specific var if (componentInstall) { std::string absoluteDestFileComponent = - std::string("CPACK_ABSOLUTE_DESTINATION_FILES") + "_" + - this->GetComponentInstallSuffix(component); + cmStrCat("CPACK_ABSOLUTE_DESTINATION_FILES_", + this->GetComponentInstallSuffix(component)); if (cmValue v = this->GetOption(absoluteDestFileComponent)) { std::string absoluteDestFilesListComponent = cmStrCat(*v, ';', *d); this->SetOption(absoluteDestFileComponent, @@ -1665,12 +1666,13 @@ std::string cmCPackGenerator::GetComponentPackageFileName( std::string suffix = "-" + groupOrComponentName; /* check if we should use DISPLAY name */ std::string dispNameVar = - "CPACK_" + this->Name + "_USE_DISPLAY_NAME_IN_FILENAME"; + cmStrCat("CPACK_", this->Name, "_USE_DISPLAY_NAME_IN_FILENAME"); if (this->IsOn(dispNameVar)) { /* the component Group case */ if (isGroupName) { - std::string groupDispVar = "CPACK_COMPONENT_GROUP_" + - cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME"; + std::string groupDispVar = cmStrCat( + "CPACK_COMPONENT_GROUP_", + cmSystemTools::UpperCase(groupOrComponentName), "_DISPLAY_NAME"); cmValue groupDispName = this->GetOption(groupDispVar); if (groupDispName) { suffix = "-" + *groupDispName; @@ -1678,8 +1680,9 @@ std::string cmCPackGenerator::GetComponentPackageFileName( } /* the [single] component case */ else { - std::string dispVar = "CPACK_COMPONENT_" + - cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME"; + std::string dispVar = cmStrCat( + "CPACK_COMPONENT_", cmSystemTools::UpperCase(groupOrComponentName), + "_DISPLAY_NAME"); cmValue dispName = this->GetOption(dispVar); if (dispName) { suffix = "-" + *dispName; diff --git a/Source/CPack/cmCPackInnoSetupGenerator.cxx b/Source/CPack/cmCPackInnoSetupGenerator.cxx index 4b8533bb5e..8afd329d85 100644 --- a/Source/CPack/cmCPackInnoSetupGenerator.cxx +++ b/Source/CPack/cmCPackInnoSetupGenerator.cxx @@ -750,8 +750,8 @@ bool cmCPackInnoSetupGenerator::ProcessComponents() return false; } - codeIncludes.push_back("#include " + QuotePath(componentsScriptTemplate) + - "\n"); + codeIncludes.push_back( + cmStrCat("#include ", QuotePath(componentsScriptTemplate), '\n')); return true; } diff --git a/Source/CPack/cmCPackNuGetGenerator.cxx b/Source/CPack/cmCPackNuGetGenerator.cxx index 079b4c6d59..95aedfe889 100644 --- a/Source/CPack/cmCPackNuGetGenerator.cxx +++ b/Source/CPack/cmCPackNuGetGenerator.cxx @@ -13,6 +13,7 @@ #include "cmCPackComponentGroup.h" #include "cmCPackLog.h" #include "cmList.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmValue.h" @@ -81,7 +82,7 @@ void cmCPackNuGetGenerator::SetupGroupComponentVariables(bool ignoreGroup) end(compG.second.Components), std::back_inserter(components), [](cmCPackComponent const* comp) { return comp->Name; }); - this->SetOption("CPACK_NUGET_" + compGUp + "_GROUP_COMPONENTS", + this->SetOption(cmStrCat("CPACK_NUGET_", compGUp, "_GROUP_COMPONENTS"), cmList::to_string(components)); } if (!groups.empty()) { diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index 2bc60c2746..6d3e1b8ba8 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -82,10 +82,10 @@ int cmCPackRPMGenerator::PackageOnePack(std::string const& initialToplevel, this->GetOption("CPACK_PACKAGE_FILE_NAME"), packageName, true) + this->GetOutputExtension()); - localToplevel += "/" + sanitizedPkgDirName; + localToplevel = cmStrCat(localToplevel, '/', sanitizedPkgDirName); /* replace the TEMP DIRECTORY with the component one */ this->SetOption("CPACK_TEMPORARY_DIRECTORY", localToplevel); - packageFileName += "/" + outputFileName; + packageFileName = cmStrCat(packageFileName, '/', outputFileName); /* replace proposed CPACK_OUTPUT_FILE_NAME */ this->SetOption("CPACK_OUTPUT_FILE_NAME", outputFileName); /* replace the TEMPORARY package file name */ @@ -146,8 +146,10 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup) std::transform(component.begin(), component.end(), component.begin(), cmsysString_toupper); - if (this->IsOn("CPACK_RPM_" + compIt->first + "_DEBUGINFO_PACKAGE") || - this->IsOn("CPACK_RPM_" + component + "_DEBUGINFO_PACKAGE")) { + if (this->IsOn( + cmStrCat("CPACK_RPM_", compIt->first, "_DEBUGINFO_PACKAGE")) || + this->IsOn( + cmStrCat("CPACK_RPM_", component, "_DEBUGINFO_PACKAGE"))) { shouldSet = false; break; } @@ -160,8 +162,10 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup) std::transform(component.begin(), component.end(), component.begin(), cmsysString_toupper); - if (this->IsOn("CPACK_RPM_" + compGIt->first + "_DEBUGINFO_PACKAGE") || - this->IsOn("CPACK_RPM_" + component + "_DEBUGINFO_PACKAGE")) { + if (this->IsOn( + cmStrCat("CPACK_RPM_", compGIt->first, "_DEBUGINFO_PACKAGE")) || + this->IsOn( + cmStrCat("CPACK_RPM_", component, "_DEBUGINFO_PACKAGE"))) { shouldSet = false; break; } @@ -177,9 +181,10 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup) std::transform(component.begin(), component.end(), component.begin(), cmsysString_toupper); - if (this->IsOn("CPACK_RPM_" + compIt->first + - "_DEBUGINFO_PACKAGE") || - this->IsOn("CPACK_RPM_" + component + "_DEBUGINFO_PACKAGE")) { + if (this->IsOn(cmStrCat("CPACK_RPM_", compIt->first, + "_DEBUGINFO_PACKAGE")) || + this->IsOn( + cmStrCat("CPACK_RPM_", component, "_DEBUGINFO_PACKAGE"))) { shouldSet = false; break; } @@ -389,11 +394,11 @@ int cmCPackRPMGenerator::PackageComponentsAllInOne( std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) + this->GetOutputExtension()); // all GROUP in one vs all COMPONENT in one - localToplevel += "/" + compInstDirName; + localToplevel = cmStrCat(localToplevel, '/', compInstDirName); /* replace the TEMP DIRECTORY with the component one */ this->SetOption("CPACK_TEMPORARY_DIRECTORY", localToplevel); - packageFileName += "/" + outputFileName; + packageFileName = cmStrCat(packageFileName, '/', outputFileName); /* replace proposed CPACK_OUTPUT_FILE_NAME */ this->SetOption("CPACK_OUTPUT_FILE_NAME", outputFileName); /* replace the TEMPORARY package file name */ @@ -457,8 +462,8 @@ std::string cmCPackRPMGenerator::GetComponentInstallSuffix( } // We have to find the name of the COMPONENT GROUP // the current COMPONENT belongs to. - std::string groupVar = - "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP"; + std::string groupVar = cmStrCat( + "CPACK_COMPONENT_", cmSystemTools::UpperCase(componentName), "_GROUP"); if (cmValue v = this->GetOption(groupVar)) { return *v; } diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index 38cadf4a93..87da43c65e 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -15,6 +15,7 @@ #include "cmArchiveWrite.h" #include "cmCPackGenerator.h" #include "cmCPackLog.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmValue.h" @@ -77,7 +78,7 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os) cmsys::ifstream ilfs(inLicFile.c_str()); std::string licenseText; while (cmSystemTools::GetLineFromStream(ilfs, line)) { - licenseText += line + "\n"; + licenseText = cmStrCat(licenseText, line, '\n'); } this->SetOptionIfNotSet("CPACK_RESOURCE_FILE_LICENSE_CONTENT", licenseText); @@ -88,7 +89,7 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os) cmsys::ifstream ifs(inFile.c_str()); std::string packageHeaderText; while (cmSystemTools::GetLineFromStream(ifs, line)) { - packageHeaderText += line + "\n"; + packageHeaderText = cmStrCat(packageHeaderText, line, '\n'); } // Configure in the values diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx index 474d24e1e8..81bacaadf6 100644 --- a/Source/CTest/cmCTestBZR.cxx +++ b/Source/CTest/cmCTestBZR.cxx @@ -17,6 +17,7 @@ #include "cmCTest.h" #include "cmCTestVC.h" #include "cmMakefile.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmXMLParser.h" @@ -399,7 +400,7 @@ bool cmCTestBZR::LoadRevisions() std::string revs; if (atoi(this->OldRevision.c_str()) <= atoi(this->NewRevision.c_str())) { // DoRevision takes care of discarding the information about OldRevision - revs = this->OldRevision + ".." + this->NewRevision; + revs = cmStrCat(this->OldRevision, "..", this->NewRevision); } else { return true; } diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 44bc96313b..71e5bda57b 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -1099,7 +1099,8 @@ void cmCTestBuildHandler::ProcessBuffer(char const* data, size_t length, // Copy pre-context to report for (std::string const& pc : this->PreContext) { - errorwarning.PreContext += pc + "\n"; + errorwarning.PreContext = + cmStrCat(errorwarning.PreContext, pc, '\n'); } this->PreContext.clear(); diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx index dadf8026d2..d3a2b2399f 100644 --- a/Source/CTest/cmCTestCVS.cxx +++ b/Source/CTest/cmCTestCVS.cxx @@ -87,7 +87,7 @@ bool cmCTestCVS::UpdateImpl() // Specify the start time for nightly testing. if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) { - args.push_back("-D" + this->GetNightlyTime() + " UTC"); + args.push_back(cmStrCat("-D", this->GetNightlyTime(), " UTC")); } // Run "cvs update" to update the work tree. @@ -241,7 +241,7 @@ void cmCTestCVS::WriteXMLDirectory(cmXMLWriter& xml, std::string const& path, // Load revisions and write an entry for each file in this directory. std::vector revisions; for (auto const& fi : dir) { - std::string full = path + slash + fi.first; + std::string full = cmStrCat(path, slash, fi.first); // Load two real or unknown revisions. revisions.clear(); diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 9c80a85a95..c0931dcadf 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -164,7 +164,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(std::string const& file, } else { checkDir = fSrcDir; } - fFile = checkDir + "/" + relPath; + fFile = cmStrCat(checkDir, '/', relPath); fFile = cmSystemTools::GetFilenamePath(fFile); if (fileDir == fFile) { @@ -492,7 +492,7 @@ int cmCTestCoverageHandler::ProcessHandler() // Handle all the files in the extra coverage globs that have no cov data for (std::string const& u : uncovered) { std::string fileName = cmSystemTools::GetFilenameName(u); - std::string fullPath = cont.SourceDir + "/" + u; + std::string fullPath = cmStrCat(cont.SourceDir, '/', u); covLogXML.StartElement("File"); covLogXML.Attribute("Name", fileName); @@ -1866,11 +1866,11 @@ std::string cmCTestCoverageHandler::FindFile( std::string fileNameNoE = cmSystemTools::GetFilenameWithoutLastExtension(fileName); // First check in source and binary directory - std::string fullName = cont->SourceDir + "/" + fileNameNoE + ".py"; + std::string fullName = cmStrCat(cont->SourceDir, '/', fileNameNoE, ".py"); if (cmSystemTools::FileExists(fullName)) { return fullName; } - fullName = cont->BinaryDir + "/" + fileNameNoE + ".py"; + fullName = cmStrCat(cont->BinaryDir, '/', fileNameNoE, ".py"); if (cmSystemTools::FileExists(fullName)) { return fullName; } @@ -2436,7 +2436,7 @@ std::set cmCTestCoverageHandler::FindUncoveredFiles( cmsys::Glob gl; gl.RecurseOn(); gl.RecurseThroughSymlinksOff(); - std::string glob = cont->SourceDir + "/" + ecg; + std::string glob = cmStrCat(cont->SourceDir, '/', ecg); gl.FindFiles(glob); std::vector files = gl.GetFiles(); for (std::string const& f : files) { diff --git a/Source/CTest/cmCTestDiscoverTests.cxx b/Source/CTest/cmCTestDiscoverTests.cxx index cb1709d326..a871bad44b 100644 --- a/Source/CTest/cmCTestDiscoverTests.cxx +++ b/Source/CTest/cmCTestDiscoverTests.cxx @@ -103,8 +103,8 @@ bool cmCTestDiscoverTests(cmTestDiscoveryArgs const& args, cmsys::RegularExpression re; if (!re.compile(AddAnchors(args.DiscoveryMatch))) { - std::string e = "DISCOVERY_MATCH failed to compile regex \"" + - args.DiscoveryMatch + "\"."; + std::string e = cmStrCat("DISCOVERY_MATCH failed to compile regex \"", + args.DiscoveryMatch, "\"."); status.SetError(e); return false; } diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index fdb0bb74ec..26930b5b75 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -110,7 +110,7 @@ std::string cmCTestGIT::FindGitDir() // Git reports a relative path only when the .git directory is in // the current directory. if (git_dir[0] == '.') { - git_dir = this->SourceDirectory + "/" + git_dir; + git_dir = cmStrCat(this->SourceDirectory, '/', git_dir); } #if defined(_WIN32) && !defined(__CYGWIN__) else if (git_dir[0] == '/') { @@ -602,7 +602,7 @@ char const cmCTestGIT::CommitParser::SectionSep[SectionCount] = { '\n', '\n', bool cmCTestGIT::LoadRevisions() { // Use 'git rev-list ... | git diff-tree ...' to get revisions. - std::string range = this->OldRevision + ".." + this->NewRevision; + std::string range = cmStrCat(this->OldRevision, "..", this->NewRevision); std::string git = this->CommandLineTool; std::vector git_rev_list = { git, "rev-list", "--reverse", range, "--" }; diff --git a/Source/CTest/cmCTestGlobalVC.cxx b/Source/CTest/cmCTestGlobalVC.cxx index 0d36b713a2..04a1a51e51 100644 --- a/Source/CTest/cmCTestGlobalVC.cxx +++ b/Source/CTest/cmCTestGlobalVC.cxx @@ -6,6 +6,7 @@ #include #include "cmCTest.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmXMLWriter.h" @@ -82,7 +83,7 @@ void cmCTestGlobalVC::WriteXMLDirectory(cmXMLWriter& xml, xml.StartElement("Directory"); xml.Element("Name", path); for (auto const& f : dir) { - std::string const full = path + slash + f.first; + std::string const full = cmStrCat(path, slash, f.first); this->WriteXMLEntry(xml, path, f.first, full, f.second); } xml.EndElement(); // Directory diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx index 738cac2e18..04274ea403 100644 --- a/Source/CTest/cmCTestHG.cxx +++ b/Source/CTest/cmCTestHG.cxx @@ -12,6 +12,7 @@ #include "cmCTest.h" #include "cmCTestVC.h" #include "cmMakefile.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmXMLParser.h" @@ -272,7 +273,7 @@ bool cmCTestHG::LoadRevisions() // The "list of strings" templates like {files} will not work when // the project has spaces in the path. Also, they may not have // proper XML escapes. - std::string range = this->OldRevision + ":" + this->NewRevision; + std::string range = cmStrCat(this->OldRevision, ':', this->NewRevision); std::string hg = this->CommandLineTool; std::string hgXMLTemplate = "\n" diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index 3589c6b9d5..593cd4b665 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -249,7 +249,7 @@ bool cmCTestSVN::UpdateImpl() // Specify the start time for nightly testing. if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) { - args.push_back("-r{" + this->GetNightlyTime() + " +0000}"); + args.push_back(cmStrCat("-r{", this->GetNightlyTime(), " +0000}")); } std::vector svn_update; @@ -383,7 +383,7 @@ bool cmCTestSVN::LoadRevisions(SVNInfo& svninfo) // We are interested in every revision included in the update. std::string revs; if (atoi(svninfo.OldRevision.c_str()) < atoi(svninfo.NewRevision.c_str())) { - revs = "-r" + svninfo.OldRevision + ":" + svninfo.NewRevision; + revs = cmStrCat("-r", svninfo.OldRevision, ':', svninfo.NewRevision); } else { revs = "-r" + svninfo.NewRevision; } diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index ce2c26355b..07dd05ff14 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -280,7 +280,8 @@ bool cmCTestDiscoverTestsCommand::InitialPass( } if (!unparsed.empty()) { - status.SetError(" given unknown argument \"" + unparsed.front() + "\"."); + status.SetError( + cmStrCat(" given unknown argument \"", unparsed.front(), "\".")); return false; } @@ -1083,7 +1084,7 @@ void cmCTestTestHandler::ComputeOutOfDateTests() continue; } - std::string const stampFile = stampDir + "/" + tp.GetStampFile(); + std::string const stampFile = cmStrCat(stampDir, '/', tp.GetStampFile()); if (!cmSystemTools::FileExists(stampFile)) { finalList.push_back(tp); @@ -1129,17 +1130,17 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const setupRegExp = this->TestOptions.ExcludeFixtureSetupRegularExpression; } else { setupRegExp.append( - "(" + setupRegExp + ")|(" + - this->TestOptions.ExcludeFixtureSetupRegularExpression + ")"); + cmStrCat('(', setupRegExp, ")|(", + this->TestOptions.ExcludeFixtureSetupRegularExpression, ')')); } } if (!this->TestOptions.ExcludeFixtureCleanupRegularExpression.empty()) { if (cleanupRegExp.empty()) { cleanupRegExp = this->TestOptions.ExcludeFixtureCleanupRegularExpression; } else { - cleanupRegExp.append( - "(" + cleanupRegExp + ")|(" + - this->TestOptions.ExcludeFixtureCleanupRegularExpression + ")"); + cleanupRegExp.append(cmStrCat( + '(', cleanupRegExp, ")|(", + this->TestOptions.ExcludeFixtureCleanupRegularExpression, ')')); } } cmsys::RegularExpression excludeSetupRegex(setupRegExp); @@ -1574,7 +1575,7 @@ void cmCTestTestHandler::GenerateCTestXML(cmXMLWriter& xml) xml.Element("StartTestTime", this->StartTestTime); xml.StartElement("TestList"); for (cmCTestTestResult const& result : this->TestResults) { - std::string testPath = result.Path + "/" + result.Name; + std::string testPath = cmStrCat(result.Path, '/', result.Name); xml.Element("Test", this->CTest->GetShortPathToFile(testPath)); } xml.EndElement(); // TestList @@ -1696,7 +1697,7 @@ void cmCTestTestHandler::WriteTestResultHeader(cmXMLWriter& xml, } else { xml.Attribute("Status", "failed"); } - std::string testPath = result.Path + "/" + result.Name; + std::string testPath = cmStrCat(result.Path, '/', result.Name); xml.Element("Name", result.Name); xml.Element("Path", this->CTest->GetShortPathToFile(result.Path)); xml.Element("FullName", this->CTest->GetShortPathToFile(testPath)); @@ -2128,7 +2129,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed() } std::string lastTestsFailedLog = - this->CTest->GetBinaryDir() + "/Testing/Temporary/" + logName; + cmStrCat(this->CTest->GetBinaryDir(), "/Testing/Temporary/", logName); if (!cmSystemTools::FileExists(lastTestsFailedLog)) { if (!this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels()) { @@ -2210,7 +2211,7 @@ void cmCTestTestHandler::RecordCustomTestMeasurements(cmXMLWriter& xml, xml.StartElement("NamedMeasurement"); xml.Attribute("name", parser.MeasurementName); xml.Attribute("text", "text/string"); - xml.Element("Value", "File " + filename + " not found"); + xml.Element("Value", cmStrCat("File ", filename, " not found")); xml.EndElement(); cmCTestOptionalLog( this->CTest, HANDLER_OUTPUT, @@ -2222,7 +2223,7 @@ void cmCTestTestHandler::RecordCustomTestMeasurements(cmXMLWriter& xml, xml.Attribute("name", parser.MeasurementName); xml.Attribute("type", "text/string"); xml.Attribute("encoding", "none"); - xml.Element("Value", "Image " + filename + " is empty"); + xml.Element("Value", cmStrCat("Image ", filename, " is empty")); xml.EndElement(); } else { if (parser.MeasurementType == "file") { @@ -2328,7 +2329,7 @@ void cmCTestTestHandler::CleanTestOutput(std::string& output, size_t length, } else if (truncate == cmCTestTypes::TruncationMode::Middle) { char const* current = utf8_advance(begin, end, length / 2); output.erase(current - begin, output.size() - length); - output.insert(current - begin, "..." + msg + "..."); + output.insert(current - begin, cmStrCat("...", msg, "...")); } else { // default or "tail" char const* current = utf8_advance(begin, end, length); output.erase(current - begin); diff --git a/Source/CTest/cmCTestUpdateCommand.cxx b/Source/CTest/cmCTestUpdateCommand.cxx index 4d0e8abbc6..397715e3db 100644 --- a/Source/CTest/cmCTestUpdateCommand.cxx +++ b/Source/CTest/cmCTestUpdateCommand.cxx @@ -260,8 +260,8 @@ bool cmCTestUpdateCommand::ExecuteUpdate(UpdateArguments& args, xml.Element("Site", mf.GetSafeDefinition("CTEST_SITE")); xml.Element("BuildName", buildname); xml.Element("BuildStamp", - this->CTest->GetCurrentTag() + "-" + - this->CTest->GetTestGroupString()); + cmStrCat(this->CTest->GetCurrentTag(), '-', + this->CTest->GetTestGroupString())); xml.Element("StartDateTime", start_time); xml.Element("StartTime", start_time_time); xml.Element("UpdateCommand", vc->GetUpdateCommandLine()); diff --git a/Source/CTest/cmCTestUploadCommand.cxx b/Source/CTest/cmCTestUploadCommand.cxx index e93c5362c9..10ab4badb0 100644 --- a/Source/CTest/cmCTestUploadCommand.cxx +++ b/Source/CTest/cmCTestUploadCommand.cxx @@ -16,6 +16,7 @@ #include "cmGeneratedFileStream.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmVersion.h" #include "cmXMLWriter.h" @@ -59,8 +60,8 @@ bool cmCTestUploadCommand::ExecuteUpload(UploadArguments& args, xml.StartElement("Site"); xml.Attribute("BuildName", buildname); xml.Attribute("BuildStamp", - this->CTest->GetCurrentTag() + "-" + - this->CTest->GetTestGroupString()); + cmStrCat(this->CTest->GetCurrentTag(), '-', + this->CTest->GetTestGroupString())); xml.Attribute("Name", mf.GetSafeDefinition("CTEST_SITE")); xml.Attribute("Generator", std::string("ctest-") + cmVersion::GetCMakeVersion()); diff --git a/Source/CTest/cmParseDelphiCoverage.cxx b/Source/CTest/cmParseDelphiCoverage.cxx index a7816734df..d74e02a677 100644 --- a/Source/CTest/cmParseDelphiCoverage.cxx +++ b/Source/CTest/cmParseDelphiCoverage.cxx @@ -8,6 +8,7 @@ #include "cmCTest.h" #include "cmCTestCoverageHandler.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" class cmParseDelphiCoverage::HTMLParser @@ -133,7 +134,7 @@ public: cmsys::Glob gl; gl.RecurseOn(); gl.RecurseThroughSymlinksOff(); - std::string glob = this->Coverage.SourceDir + "*/" + filename; + std::string glob = cmStrCat(this->Coverage.SourceDir, "*/", filename); gl.FindFiles(glob); std::vector const& files = gl.GetFiles(); if (files.empty()) { diff --git a/Source/CTest/cmParseJacocoCoverage.cxx b/Source/CTest/cmParseJacocoCoverage.cxx index 11eb26f706..3411b7a341 100644 --- a/Source/CTest/cmParseJacocoCoverage.cxx +++ b/Source/CTest/cmParseJacocoCoverage.cxx @@ -48,7 +48,7 @@ protected: "Reading file: " << fileName << std::endl, this->Coverage.Quiet); - this->FilePath = this->PackagePath + "/" + fileName; + this->FilePath = cmStrCat(this->PackagePath, '/', fileName); cmsys::ifstream fin(this->FilePath.c_str()); if (!fin) { cmCTestLog(this->CTest, ERROR_MESSAGE, diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 4160669816..b75e82df20 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -456,10 +456,11 @@ void cmCursesMainForm::UpdateProgress(std::string const& msg, float prog) int percentCompleted = static_cast(100 * prog); this->LastProgress = (percentCompleted < 100 ? " " : ""); this->LastProgress += (percentCompleted < 10 ? " " : ""); - this->LastProgress += std::to_string(percentCompleted) + "% ["; + this->LastProgress = + cmStrCat(this->LastProgress, std::to_string(percentCompleted), "% ["); this->LastProgress.append(progressBarCompleted, '#'); this->LastProgress.append(progressBarWidth - progressBarCompleted, ' '); - this->LastProgress += "] " + msg + "..."; + this->LastProgress = cmStrCat(this->LastProgress, "] ", msg, "..."); this->DisplayOutputs(std::string()); } else { this->Outputs.emplace_back(msg); diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx index 4e67ba7c99..8a7e6b8b44 100644 --- a/Source/cmCMakeHostSystemInformationCommand.cxx +++ b/Source/cmCMakeHostSystemInformationCommand.cxx @@ -500,7 +500,7 @@ cm::optional GetDistribValue( std::string vars; for (auto const& kv : *os_release) { auto cmake_var_name = cmStrCat(variable, '_', kv.first); - vars += DELIM[!vars.empty()] + cmake_var_name; + vars = cmStrCat(vars, DELIM[!vars.empty()], cmake_var_name); makefile.AddDefinition(cmake_var_name, kv.second); } return cm::optional(std::move(vars)); diff --git a/Source/cmCMakePkgConfigCommand.cxx b/Source/cmCMakePkgConfigCommand.cxx index e6b1a52e7f..dbbe600b10 100644 --- a/Source/cmCMakePkgConfigCommand.cxx +++ b/Source/cmCMakePkgConfigCommand.cxx @@ -184,7 +184,7 @@ std::vector GetPkgConfSysCflags(cmMakefile& mf) std::string tmp; cmSystemTools::GetEnv(var, tmp); if (!tmp.empty()) { - paths += ";" + tmp; + paths = cmStrCat(paths, ';', tmp); } } }; diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 0c0691802c..7c1f40e6c1 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -707,7 +707,7 @@ bool cmCTest::OpenOutputFile(std::string const& path, std::string const& name, { std::string testingDir = this->Impl->BinaryDir + "/Testing"; if (!path.empty()) { - testingDir += "/" + path; + testingDir = cmStrCat(testingDir, '/', path); } if (cmSystemTools::FileExists(testingDir)) { if (!cmSystemTools::FileIsDirectory(testingDir)) { diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 7610752650..b240c2907f 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -1082,8 +1082,8 @@ cm::optional cmCoreTryCompile::TryCompileCode( if (testLangs.find(LinkerLanguage) == testLangs.end()) { this->Makefile->IssueMessage( MessageType::FATAL_ERROR, - "Linker language '" + LinkerLanguage + - "' must be enabled in project(LANGUAGES)."); + cmStrCat("Linker language '", LinkerLanguage, + "' must be enabled in project(LANGUAGES).")); } fprintf(fout, "set_property(TARGET %s PROPERTY LINKER_LANGUAGE %s)\n", diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index dd5779f436..aa20ff19eb 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -37,7 +37,7 @@ static void cmFortranModuleAppendUpperLower(std::string const& mod, } std::string const& name = mod.substr(0, mod.size() - ext_len); std::string const& ext = mod.substr(mod.size() - ext_len); - mod_upper += cmSystemTools::UpperCase(name) + ext; + mod_upper = cmStrCat(mod_upper, cmSystemTools::UpperCase(name), ext); mod_lower += mod; } diff --git a/Source/cmDiscoverTestsCommand.cxx b/Source/cmDiscoverTestsCommand.cxx index 93dbf63995..6bab2a1925 100644 --- a/Source/cmDiscoverTestsCommand.cxx +++ b/Source/cmDiscoverTestsCommand.cxx @@ -20,6 +20,7 @@ #include "cmMakefile.h" #include "cmPolicies.h" #include "cmScriptGenerator.h" +#include "cmStringAlgorithms.h" #include "cmTestDiscovery.h" #include "cmTestGenerator.h" @@ -119,7 +120,8 @@ bool cmDiscoverTestsCommand(std::vector const& args, } if (!unparsed.empty()) { - status.SetError(" given unknown argument \"" + unparsed.front() + "\"."); + status.SetError( + cmStrCat(" given unknown argument \"", unparsed.front(), "\".")); return false; } diff --git a/Source/cmEnvironment.cxx b/Source/cmEnvironment.cxx index af5a47c295..48ec2b48dc 100644 --- a/Source/cmEnvironment.cxx +++ b/Source/cmEnvironment.cxx @@ -64,7 +64,7 @@ std::vector cmEnvironment::GetVariables() const result.reserve(this->Map.size()); for (auto const& elem : this->Map) { if (elem.second) { - result.push_back(elem.first + '=' + *elem.second); + result.push_back(cmStrCat(elem.first, '=', *elem.second)); } } return result; @@ -208,7 +208,7 @@ void cmEnvironmentModification::ApplyTo(cmEnvironment& env) for (auto const& e : this->Entries) { if (e.Op == "set") { - env.PutEnv(e.Name + "=" + e.Value); + env.PutEnv(cmStrCat(e.Name, '=', e.Value)); } else if (e.Op == "unset") { env.UnPutEnv(e.Name); } else if (e.Op == "string_append") { diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx index 43d4febd33..344bf76469 100644 --- a/Source/cmExecuteProcessCommand.cxx +++ b/Source/cmExecuteProcessCommand.cxx @@ -135,8 +135,8 @@ bool cmExecuteProcessCommand(std::vector const& args, return true; } if (!unparsedArguments.empty()) { - status.SetError(" given unknown argument \"" + unparsedArguments.front() + - "\"."); + status.SetError(cmStrCat(" given unknown argument \"", + unparsedArguments.front(), "\".")); return false; } @@ -159,8 +159,8 @@ bool cmExecuteProcessCommand(std::vector const& args, } if (!status.GetMakefile().CanIWriteThisFile(outputFilename)) { - status.SetError("attempted to output into a file: " + outputFilename + - " into a source directory."); + status.SetError(cmStrCat("attempted to output into a file: ", + outputFilename, " into a source directory.")); cmSystemTools::SetFatalErrorOccurred(); return false; } diff --git a/Source/cmExportBuildCMakeConfigGenerator.cxx b/Source/cmExportBuildCMakeConfigGenerator.cxx index 2495754609..f6d43d8fad 100644 --- a/Source/cmExportBuildCMakeConfigGenerator.cxx +++ b/Source/cmExportBuildCMakeConfigGenerator.cxx @@ -41,7 +41,8 @@ bool cmExportBuildCMakeConfigGenerator::GenerateMainFile(std::ostream& os) std::string sep; bool generatedInterfaceRequired = false; auto visitor = [&](cmGeneratorTarget const* te) { - expectedTargets += sep + this->Namespace + te->GetExportName(); + expectedTargets = + cmStrCat(expectedTargets, sep, this->Namespace, te->GetExportName()); sep = " "; generatedInterfaceRequired |= diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index 02f463a331..e2dd9a6865 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -507,8 +507,8 @@ static bool HandleSetupMode(std::vector const& args, SetupArguments arguments = parser.Parse(args, &unknownArgs); if (!unknownArgs.empty()) { - status.SetError("SETUP given unknown argument: \"" + unknownArgs.front() + - "\"."); + status.SetError(cmStrCat("SETUP given unknown argument: \"", + unknownArgs.front(), "\".")); return false; } diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index c3b0cf8926..3ba8f4d0fe 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -462,7 +462,7 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( } else { this->ResolveTargetsInGeneratorExpression(li, target, lg); } - input += sep + li; + input = cmStrCat(input, sep, li); sep = ";"; } } diff --git a/Source/cmExportInstallCMakeConfigGenerator.cxx b/Source/cmExportInstallCMakeConfigGenerator.cxx index 16b6071c22..ac4615fdb4 100644 --- a/Source/cmExportInstallCMakeConfigGenerator.cxx +++ b/Source/cmExportInstallCMakeConfigGenerator.cxx @@ -49,7 +49,8 @@ bool cmExportInstallCMakeConfigGenerator::GenerateMainFile(std::ostream& os) std::string sep; auto visitor = [&](cmTargetExport const* te) { allTargets.push_back(te); - expectedTargets += sep + this->Namespace + te->Target->GetExportName(); + expectedTargets = cmStrCat(expectedTargets, sep, this->Namespace, + te->Target->GetExportName()); sep = " "; }; diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index c71daca1f8..0d9b365694 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -605,7 +605,7 @@ void cmExportInstallFileGenerator::PopulateIncludeDirectoriesInterface( std::string includes = (input ? *input : ""); char const* const sep = input ? ";" : ""; - includes += sep + exportDirs; + includes = cmStrCat(includes, sep, exportDirs); std::string prepro = cmGeneratorExpression::Preprocess( includes, preprocessRule, this->GetImportPrefixWithSlash()); if (!prepro.empty()) { diff --git a/Source/cmFastbuildNormalTargetGenerator.cxx b/Source/cmFastbuildNormalTargetGenerator.cxx index 6c4eb6d5dd..272da1db49 100644 --- a/Source/cmFastbuildNormalTargetGenerator.cxx +++ b/Source/cmFastbuildNormalTargetGenerator.cxx @@ -573,8 +573,8 @@ void cmFastbuildNormalTargetGenerator::ComputePCH( // Reuse compiler options for PCH options. node.PCHOptions += origCompileOptions; - if (this->Makefile->GetSafeDefinition("CMAKE_" + language + - "_COMPILER_ID") == "MSVC") { + if (this->Makefile->GetSafeDefinition( + cmStrCat("CMAKE_", language, "_COMPILER_ID")) == "MSVC") { cmSystemTools::ReplaceString(node.PCHOptions, FASTBUILD_2_INPUT_PLACEHOLDER, FASTBUILD_3_INPUT_PLACEHOLDER); @@ -1796,8 +1796,9 @@ void cmFastbuildNormalTargetGenerator::AppendExternalObject( else if (target) { if (!linkedDeps.emplace(objLibName + FASTBUILD_OBJECTS_ALIAS_POSTFIX) .second) { - LogMessage("Object Target: " + objLibName + - FASTBUILD_OBJECTS_ALIAS_POSTFIX " already linked"); + LogMessage(cmStrCat("Object Target: ", objLibName, + FASTBUILD_OBJECTS_ALIAS_POSTFIX + " already linked")); continue; } linkerNode.LibrarianAdditionalInputs.emplace_back( @@ -1885,8 +1886,8 @@ void cmFastbuildNormalTargetGenerator::AppendTargetDep( // Skip exported objects. // Tested in "ExportImport" test. if (depType == cm::TargetType::OBJECT_LIBRARY) { - LogMessage("target : " + item.Target->GetName() + - " already linked... Skipping"); + LogMessage(cmStrCat("target : ", item.Target->GetName(), + " already linked... Skipping")); return; } // Tested in "ExportImport" test. diff --git a/Source/cmFastbuildTargetGenerator.cxx b/Source/cmFastbuildTargetGenerator.cxx index 2522cc8cd3..8ed16e8286 100644 --- a/Source/cmFastbuildTargetGenerator.cxx +++ b/Source/cmFastbuildTargetGenerator.cxx @@ -157,7 +157,8 @@ std::string cmFastbuildTargetGenerator::GetCustomCommandTargetName( extras += std::to_string(static_cast(step)); cmCryptoHash hash(cmCryptoHash::AlgoSHA256); - targetName += "-" + hash.HashString(extras).substr(0, 14); + targetName = + cmStrCat(targetName, '-', hash.HashString(extras).substr(0, 14)); return targetName; } @@ -674,8 +675,8 @@ FastbuildExecNodes cmFastbuildTargetGenerator::GenerateCommands( execNode.PreBuildDependencies); for (auto const& util : ccg.GetUtilities()) { auto const& utilTargetName = util.Value.first; - LogMessage("Util: " + utilTargetName + - ", cross: " + std::to_string(util.Value.second)); + LogMessage(cmStrCat("Util: ", utilTargetName, + ", cross: ", std::to_string(util.Value.second))); auto* const target = this->Makefile->FindTargetToUse(utilTargetName); if (target && target->IsImported()) { diff --git a/Source/cmFastbuildUtilityTargetGenerator.cxx b/Source/cmFastbuildUtilityTargetGenerator.cxx index 02c9e604cf..90d53651f9 100644 --- a/Source/cmFastbuildUtilityTargetGenerator.cxx +++ b/Source/cmFastbuildUtilityTargetGenerator.cxx @@ -75,8 +75,8 @@ void cmFastbuildUtilityTargetGenerator::Generate() if (target && target->GetType() == cm::TargetType::INTERFACE_LIBRARY) { for (auto const& dep : target->GetUtilities()) { auto const& depName = this->ConvertToFastbuildPath(dep.Value.first); - LogMessage("Transitively propagating iface dep: " + depName + - ", is cross: " + std::to_string(dep.Value.second)); + LogMessage(cmStrCat("Transitively propagating iface dep: ", depName, + ", is cross: ", std::to_string(dep.Value.second))); nonImportedUtils.emplace_back(depName); addUtilDepToTarget(this->ConvertToFastbuildPath(depName)); } @@ -117,8 +117,8 @@ void cmFastbuildUtilityTargetGenerator::Generate() for (auto& exec : GenerateCommands(FastbuildBuildStep::REST).Nodes) { addUtilDepToTarget(exec.Name); for (auto const& dep : TargetDirectDependencies) { - LogMessage("Direct dep " + dep->GetName() + - "-all propagating to CC: " + exec.Name); + LogMessage(cmStrCat("Direct dep ", dep->GetName(), + "-all propagating to CC: ", exec.Name)); // All custom commands from within the target must be executed AFTER all // the target's deps. exec.PreBuildDependencies.emplace(dep->GetName()); diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 655dbeddcd..3ee629ec5a 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -316,7 +316,7 @@ std::string TargetId(cmGeneratorTarget const* gt, std::string const& topBuild) topBuild, gt->GetLocalGenerator()->GetCurrentBinaryDirectory()); std::string hash = hasher.HashString(path); hash.resize(20, '0'); - return gt->GetName() + CMAKE_DIRECTORY_ID_SEP + hash; + return cmStrCat(gt->GetName(), CMAKE_DIRECTORY_ID_SEP, hash); } struct CompileData @@ -755,7 +755,7 @@ Json::Value CodemodelConfig::DumpTarget(cmGeneratorTarget* gt, std::replace(safeTargetName.begin(), safeTargetName.end(), ':', '_'); std::string prefix = "target-" + safeTargetName; if (!this->Config.empty()) { - prefix += "-" + this->Config; + prefix = cmStrCat(prefix, '-', this->Config); } Json::Value target = this->FileAPI.MaybeJsonFile(t.Dump(), prefix); target["name"] = gt->GetName(); @@ -856,7 +856,7 @@ Json::Value CodemodelConfig::DumpDirectoryObject(Directory& d) } } if (!this->Config.empty()) { - prefix += "-" + this->Config; + prefix = cmStrCat(prefix, '-', this->Config); } DirectoryObject dir(d.LocalGenerator, this->VersionMajor, this->VersionMinor, diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 2ebf38c9c5..a333ed8df7 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -755,7 +755,7 @@ bool HandleGlobImpl(std::vector const& args, bool recurse, expr = status.GetMakefile().GetCurrentSourceDirectory(); // Handle script mode if (!expr.empty()) { - expr += "/" + *i; + expr = cmStrCat(expr, '/', *i); } else { expr = *i; } @@ -2126,10 +2126,10 @@ bool HandleDownloadCommand(std::vector const& args, std::string dir = cmSystemTools::GetFilenamePath(file); if (!dir.empty() && !cmSystemTools::FileExists(dir) && !cmSystemTools::MakeDirectory(dir)) { - std::string errstring = "DOWNLOAD error: cannot create directory '" + - dir + - "' - Specify file by full path name and verify that you " - "have directory creation and file write privileges."; + std::string errstring = + cmStrCat("DOWNLOAD error: cannot create directory '", dir, + "' - Specify file by full path name and verify that you " + "have directory creation and file write privileges."); status.SetError(errstring); return false; } @@ -2358,10 +2358,10 @@ bool HandleDownloadCommand(std::vector const& args, if (expectedHash != actualHash) { if (!statusVar.empty() && res == 0) { status.GetMakefile().AddDefinition(statusVar, - "1;HASH mismatch: " - "expected: " + - expectedHash + - " actual: " + actualHash); + cmStrCat("1;HASH mismatch: " + "expected: ", + expectedHash, + " actual: ", actualHash)); } status.SetError(cmStrCat("DOWNLOAD HASH mismatch\n" @@ -3644,8 +3644,8 @@ bool HandleConfigureCommand(std::vector const& args, cmMakefile& makeFile = status.GetMakefile(); if (!makeFile.CanIWriteThisFile(outputFile)) { - cmSystemTools::Error("Attempt to write file: " + outputFile + - " into a source directory."); + cmSystemTools::Error(cmStrCat("Attempt to write file: ", outputFile, + " into a source directory.")); return false; } diff --git a/Source/cmFileInstaller.cxx b/Source/cmFileInstaller.cxx index c03bc682af..8c8f5e39f9 100644 --- a/Source/cmFileInstaller.cxx +++ b/Source/cmFileInstaller.cxx @@ -447,8 +447,9 @@ bool cmFileInstaller::HandleInstallDestination() if (this->InstallType != cmInstallType_DIRECTORY) { if (!cmSystemTools::FileExists(destination)) { if (!cmSystemTools::MakeDirectory(destination, default_dir_mode)) { - std::string errstring = "cannot create directory: " + destination + - ". Maybe need administrative privileges."; + std::string errstring = + cmStrCat("cannot create directory: ", destination, + ". Maybe need administrative privileges."); this->Status.SetError(errstring); return false; } diff --git a/Source/cmFortranParserImpl.cxx b/Source/cmFortranParserImpl.cxx index 08dab98326..57138f07d0 100644 --- a/Source/cmFortranParserImpl.cxx +++ b/Source/cmFortranParserImpl.cxx @@ -82,7 +82,7 @@ std::string cmFortranParser_s::SModName(std::string const& mod_name, if (this->Compiler.SModSep.empty()) { return sub_name + SModExt; } - return mod_name + this->Compiler.SModSep + sub_name + SModExt; + return cmStrCat(mod_name, this->Compiler.SModSep, sub_name, SModExt); } bool cmFortranParser_FilePush(cmFortranParser* parser, char const* fname) diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index 733d986e98..ff01403eeb 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -167,7 +167,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg) std::string line; std::string sep; while (cmSystemTools::GetLineFromStream(fin, line)) { - inputContent += sep + line; + inputContent = cmStrCat(inputContent, sep, line); sep = "\n"; } inputContent += sep; diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 70002d67bb..51ebc560e7 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -4834,7 +4834,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode std::string linkedTargetsContent = getLinkedTargetsContent( target, interfacePropertyName, eval, &dagChecker, usage); if (!linkedTargetsContent.empty()) { - result += (result.empty() ? "" : ";") + linkedTargetsContent; + result = + cmStrCat(result, (result.empty() ? "" : ";"), linkedTargetsContent); } } return result; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index bdc7a273a7..62d3a2137c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1326,7 +1326,7 @@ std::string cmGeneratorTarget::GetCompilePDBName( *config_name, this->LocalGenerator, config, this); NameComponents const& components = GetFullNameInternalComponents( config, cmStateEnums::RuntimeBinaryArtifact); - return components.prefix + pdbName + ".pdb"; + return cmStrCat(components.prefix, pdbName, ".pdb"); } cmValue name = this->GetProperty("COMPILE_PDB_NAME"); @@ -1335,7 +1335,7 @@ std::string cmGeneratorTarget::GetCompilePDBName( *name, this->LocalGenerator, config, this); NameComponents const& components = GetFullNameInternalComponents( config, cmStateEnums::RuntimeBinaryArtifact); - return components.prefix + pdbName + ".pdb"; + return cmStrCat(components.prefix, pdbName, ".pdb"); } // If the target is PCH-reused or PCH-reuses, we need a stable name for the @@ -3211,8 +3211,8 @@ std::string cmGeneratorTarget::GetPchHeader(std::string const& config, generatorTarget = reuseTarget; } - auto const inserted = - this->PchHeaders.insert(std::make_pair(language + config + arch, "")); + auto const inserted = this->PchHeaders.insert( + std::make_pair(cmStrCat(language, config, arch), "")); if (inserted.second) { std::vector> const headers = this->GetPrecompileHeaders(config, language); @@ -3305,8 +3305,8 @@ std::string cmGeneratorTarget::GetPchSource(std::string const& config, language != "OBJCXX") { return std::string(); } - auto const inserted = - this->PchSources.insert(std::make_pair(language + config + arch, "")); + auto const inserted = this->PchSources.insert( + std::make_pair(cmStrCat(language, config, arch), "")); if (inserted.second) { std::string const pchHeader = this->GetPchHeader(config, language, arch); if (pchHeader.empty()) { @@ -3365,8 +3365,8 @@ std::string cmGeneratorTarget::GetPchFileObject(std::string const& config, language != "OBJCXX") { return std::string(); } - auto const inserted = - this->PchObjectFiles.insert(std::make_pair(language + config + arch, "")); + auto const inserted = this->PchObjectFiles.insert( + std::make_pair(cmStrCat(language, config, arch), "")); if (inserted.second) { std::string const pchSource = this->GetPchSource(config, language, arch); if (pchSource.empty()) { @@ -3388,8 +3388,8 @@ std::string cmGeneratorTarget::GetPchFile(std::string const& config, std::string const& language, std::string const& arch) { - auto const inserted = - this->PchFiles.insert(std::make_pair(language + config + arch, "")); + auto const inserted = this->PchFiles.insert( + std::make_pair(cmStrCat(language, config, arch), "")); if (inserted.second) { std::string& pchFile = inserted.first->second; @@ -3448,7 +3448,7 @@ std::string cmGeneratorTarget::GetPchCreateCompileOptions( std::string const& arch) { auto const inserted = this->PchCreateCompileOptions.insert( - std::make_pair(language + config + arch, "")); + std::make_pair(cmStrCat(language, config, arch), "")); if (inserted.second) { std::string& createOptionList = inserted.first->second; @@ -3496,7 +3496,7 @@ std::string cmGeneratorTarget::GetPchUseCompileOptions( std::string const& arch) { auto const inserted = this->PchUseCompileOptions.insert( - std::make_pair(language + config + arch, "")); + std::make_pair(cmStrCat(language, config, arch), "")); if (inserted.second) { std::string& useOptionList = inserted.first->second; @@ -3944,7 +3944,7 @@ cmGeneratorTarget::Names cmGeneratorTarget::GetExecutableNames( targetNames.Output = components.prefix + targetNames.Base; } else { targetNames.Output = - components.prefix + targetNames.Base + components.suffix; + cmStrCat(components.prefix, targetNames.Base, components.suffix); } // The executable's real name on disk. @@ -3977,7 +3977,7 @@ std::string cmGeneratorTarget::GetFullNameInternal( { NameComponents const& components = this->GetFullNameInternalComponents(config, artifact); - return components.prefix + components.base + components.suffix; + return cmStrCat(components.prefix, components.base, components.suffix); } std::string cmGeneratorTarget::ImportedGetLocation( diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 6d5225fc8c..c48bfc8be7 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -567,7 +567,7 @@ std::string cmGraphVizWriter::ItemNameWithAliases( auto nameWithAliases = itemName; for(auto const& item : items) { - nameWithAliases += "\\n(" + item + ")"; + nameWithAliases = cmStrCat(nameWithAliases, "\\n(" , item , ')'); } return nameWithAliases; @@ -578,10 +578,10 @@ std::string cmGraphVizWriter::GetEdgeStyle(DependencyType dt) std::string style; switch (dt) { case DependencyType::LinkPrivate: - style = "[ style = " + std::string(GRAPHVIZ_EDGE_STYLE_PRIVATE) + " ]"; + style = cmStrCat("[ style = ", GRAPHVIZ_EDGE_STYLE_PRIVATE, " ]"); break; case DependencyType::LinkInterface: - style = "[ style = " + std::string(GRAPHVIZ_EDGE_STYLE_INTERFACE) + " ]"; + style = cmStrCat("[ style = ", GRAPHVIZ_EDGE_STYLE_INTERFACE, " ]"); break; default: break; diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index d23b3aed54..244330d5cb 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -82,8 +82,9 @@ static void FinalAction(cmMakefile& makefile, std::string const& dest, // replace any variables std::string const& temps = *s; if (!cmSystemTools::GetFilenamePath(temps).empty()) { - testf = cmSystemTools::GetFilenamePath(temps) + "/" + - cmSystemTools::GetFilenameWithoutLastExtension(temps) + ext; + testf = + cmStrCat(cmSystemTools::GetFilenamePath(temps), '/', + cmSystemTools::GetFilenameWithoutLastExtension(temps), ext); } else { testf = cmSystemTools::GetFilenameWithoutLastExtension(temps) + ext; } diff --git a/Source/cmInstrumentationCommand.cxx b/Source/cmInstrumentationCommand.cxx index 48715cec9f..f138e40c43 100644 --- a/Source/cmInstrumentationCommand.cxx +++ b/Source/cmInstrumentationCommand.cxx @@ -146,8 +146,8 @@ bool cmInstrumentationCommand(std::vector const& args, return true; } if (!unparsedArguments.empty()) { - status.SetError("given unknown argument \"" + unparsedArguments.front() + - "\"."); + status.SetError( + cmStrCat("given unknown argument \"", unparsedArguments.front(), "\".")); return false; } int apiVersion; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 06ad7a2ba8..14a9f902ca 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -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>& 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()) { diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index eac59f7f92..0d4d42bc5e 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -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; }); } diff --git a/Source/cmMakeDirectoryCommand.cxx b/Source/cmMakeDirectoryCommand.cxx index 4302f4cb41..52ac453c3b 100644 --- a/Source/cmMakeDirectoryCommand.cxx +++ b/Source/cmMakeDirectoryCommand.cxx @@ -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 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; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index db21efce2e..a81dd8a48f 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -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; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 5bbaabe118..0d2e8a9a13 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -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 diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 133e18423d..3a7e3b3454 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -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()); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 4779ab1e34..66ef28d019 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -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(), @@ -2147,7 +2147,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(); @@ -2186,7 +2186,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(); @@ -2253,7 +2253,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 && @@ -2343,9 +2343,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(); @@ -2377,7 +2377,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()) { diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx index 67b5af580a..2bb1289edc 100644 --- a/Source/cmMessageCommand.cxx +++ b/Source/cmMessageCommand.cxx @@ -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( diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index c4c0b3db26..cf9de96e24 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -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)) { @@ -865,8 +865,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); @@ -1310,9 +1310,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 = @@ -1470,7 +1470,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 = diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 118b833253..3cb23db3a4 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -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(); diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 0976d40091..b63c9905a8 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -106,8 +106,8 @@ bool cmProjectCommand(std::vector 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 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 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 const& args, return false; } - if (!IncludeByVariable(status, - "CMAKE_PROJECT_" + projectName + "_INCLUDE")) { + if (!IncludeByVariable( + status, cmStrCat("CMAKE_PROJECT_", projectName, "_INCLUDE"))) { return false; } diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 435fc13286..b925669a38 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -961,7 +961,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); } diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 6721edf2c3..024f2db849 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -1442,7 +1442,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 { @@ -1451,10 +1451,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")); } @@ -2223,8 +2223,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 = diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx index c1c0b68b1c..5c100f4640 100644 --- a/Source/cmRST.cxx +++ b/Source/cmRST.cxx @@ -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) { diff --git a/Source/cmSbomBuilder.cxx b/Source/cmSbomBuilder.cxx index 861c85a93a..a7e7b295a8 100644 --- a/Source/cmSbomBuilder.cxx +++ b/Source/cmSbomBuilder.cxx @@ -655,7 +655,7 @@ void cmSbomBuilder::ResolveTargetsInGeneratorExpressions( } else { this->ResolveTargetsInGeneratorExpression(li, target, lg); } - input += sep + li; + input = cmStrCat(input, sep, li); sep = ";"; } } diff --git a/Source/cmSubdirCommand.cxx b/Source/cmSubdirCommand.cxx index fd87e09bc9..dc9811474d 100644 --- a/Source/cmSubdirCommand.cxx +++ b/Source/cmSubdirCommand.cxx @@ -35,17 +35,17 @@ bool cmSubdirCommand(std::vector 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, diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 5db9545a14..638bd4e9e7 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -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) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 76e9d2f9a3..1e6398e910 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1550,24 +1550,24 @@ std::string cmTarget::GetDebugGeneratorExpressions( std::vector debugConfigs = this->impl->Makefile->GetCMakeInstance()->GetDebugConfigs(); - std::string configString = "$"; + std::string configString = cmStrCat("$'); if (debugConfigs.size() > 1) { for (std::string const& conf : cmMakeRange(debugConfigs).advance(1)) { - configString += ",$"; + configString = cmStrCat(configString, ",$'); } - configString = "$"; + configString = cmStrCat("$'); } if (llt == OPTIMIZED_LibraryType) { - configString = "$"; + configString = cmStrCat("$'); } - return "$<" + configString + ":" + value + ">"; + return cmStrCat("$<", configString, ':', value, '>'); } static std::string targetNameGenex(std::string const& lib) { - return "$"; + return cmStrCat("$'); } 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", - ("$")); + (cmStrCat("$'))); } } } @@ -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; } } diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx index 62c3a4eb19..374e7ffef1 100644 --- a/Source/cmTargetCompileDefinitionsCommand.cxx +++ b/Source/cmTargetCompileDefinitionsCommand.cxx @@ -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 = ";"; } diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index e52590f920..d4623de90d 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -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 = "$"; + configLib = cmStrCat("$'); } this->AppendProperty("INTERFACE_LINK_LIBRARIES", configLib); } diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index cd4c4398c9..9d3845c5ea 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -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); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 74d8cff721..b49cb956c6 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -979,7 +979,7 @@ bool cmake::FindPackage(std::vector const& args) lg->GetStateSnapshot().GetDirectory()); lg->GetTargetFlags(&linkLineComputer, buildType, linkLibs, flags, linkFlags, frameworkPath, linkPath, gtgt); - linkLibs = frameworkPath + linkPath + linkLibs; + linkLibs = cmStrCat(frameworkPath, linkPath, linkLibs); printf("%s\n", linkLibs.c_str()); diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 77b5771c6d..79aa715cab 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -3400,8 +3400,8 @@ int cmVSLink::LinkNonIncremental() } // Run the manifest tool to embed the final manifest in the binary. - std::string mtOut = "/outputresource:" + this->TargetFile + - (this->Type == 1 ? ";#1" : ";#2"); + std::string mtOut = cmStrCat("/outputresource:", this->TargetFile, + (this->Type == 1 ? ";#1" : ";#2")); return this->RunMT(mtOut, false); } diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx index c46ab91fec..a4c0ac9153 100644 --- a/Tests/CMakeLib/run_compile_commands.cxx +++ b/Tests/CMakeLib/run_compile_commands.cxx @@ -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, '.')); } } diff --git a/Tests/CMakeLib/testDebuggerNamedPipe.cxx b/Tests/CMakeLib/testDebuggerNamedPipe.cxx index 69c8de2728..0529d277ac 100644 --- a/Tests/CMakeLib/testDebuggerNamedPipe.cxx +++ b/Tests/CMakeLib/testDebuggerNamedPipe.cxx @@ -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 const& debugger, std::vector 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;