diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2019-08-22 14:34:40 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2019-08-22 14:38:10 (GMT) |
commit | 9b334397f55b70689ff1d8f7d6767a34834e85b6 (patch) | |
tree | bc33e4dc90eef2c351e278219bc9743d40af632c /Source/CPack | |
parent | 130dbe4a5d49baa4404a399860bd3a6182783ece (diff) | |
download | CMake-9b334397f55b70689ff1d8f7d6767a34834e85b6.zip CMake-9b334397f55b70689ff1d8f7d6767a34834e85b6.tar.gz CMake-9b334397f55b70689ff1d8f7d6767a34834e85b6.tar.bz2 |
Source sweep: Use cmStrCat for string concatenation
This patch is generated by a python script that uses regular expressions to
search for string concatenation patterns of the kind
```
std::string str = <ARG0>;
str += <ARG1>;
str += <ARG2>;
...
```
and replaces them with a single `cmStrCat` call
```
std::string str = cmStrCat(<ARG0>, <ARG1>, <ARG2>, ...);
```
If any `<ARGX>` is itself a concatenated string of the kind
```
a + b + c + ...;
```
then `<ARGX>` is split into multiple arguments for the `cmStrCat` call.
If there's a sequence of literals in the `<ARGX>`, then all literals in the
sequence are concatenated and merged into a single literal argument for
the `cmStrCat` call.
Single character strings are converted to single char arguments for
the `cmStrCat` call.
`std::to_string(...)` wrappings are removed from `cmStrCat` arguments,
because it supports numeric types as well as string types.
`arg.substr(x)` arguments to `cmStrCat` are replaced with
`cm::string_view(arg).substr(x)`
Diffstat (limited to 'Source/CPack')
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWGenerator.cxx | 7 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWInstaller.cxx | 4 | ||||
-rw-r--r-- | Source/CPack/WiX/cmCPackWIXGenerator.cxx | 8 | ||||
-rw-r--r-- | Source/CPack/cmCPackArchiveGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/CPack/cmCPackBundleGenerator.cxx | 10 | ||||
-rw-r--r-- | Source/CPack/cmCPackComponentGroup.cxx | 5 | ||||
-rw-r--r-- | Source/CPack/cmCPackCygwinBinaryGenerator.cxx | 10 | ||||
-rw-r--r-- | Source/CPack/cmCPackCygwinSourceGenerator.cxx | 32 | ||||
-rw-r--r-- | Source/CPack/cmCPackDebGenerator.cxx | 28 | ||||
-rw-r--r-- | Source/CPack/cmCPackDragNDropGenerator.cxx | 16 | ||||
-rw-r--r-- | Source/CPack/cmCPackGenerator.cxx | 41 | ||||
-rw-r--r-- | Source/CPack/cmCPackNSISGenerator.cxx | 68 | ||||
-rw-r--r-- | Source/CPack/cmCPackOSXX11Generator.cxx | 42 | ||||
-rw-r--r-- | Source/CPack/cmCPackPKGGenerator.cxx | 46 | ||||
-rw-r--r-- | Source/CPack/cmCPackPackageMakerGenerator.cxx | 48 | ||||
-rw-r--r-- | Source/CPack/cmCPackProductBuildGenerator.cxx | 23 | ||||
-rw-r--r-- | Source/CPack/cmCPackRPMGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/CPack/cpack.cxx | 4 |
18 files changed, 167 insertions, 235 deletions
diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index f0fb37a..234da2f 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -35,8 +35,7 @@ int cmCPackIFWGenerator::PackageFiles() this->Installer.GeneratePackageFiles(); std::string ifwTLD = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - std::string ifwTmpFile = ifwTLD; - ifwTmpFile += "/IFWOutput.log"; + std::string ifwTmpFile = cmStrCat(ifwTLD, "/IFWOutput.log"); // Run repogen if (!this->Installer.RemoteRepositories.empty()) { @@ -117,8 +116,8 @@ int cmCPackIFWGenerator::PackageFiles() // Run binary creator { - std::string ifwCmd = this->BinCreator; - ifwCmd += " -c " + this->toplevel + "/config/config.xml"; + std::string ifwCmd = + cmStrCat(this->BinCreator, " -c ", this->toplevel, "/config/config.xml"); if (!this->Installer.Resources.empty()) { ifwCmd += " -r "; diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index 5313dd0..b4bfea7 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -193,8 +193,8 @@ void cmCPackIFWInstaller::ConfigureFromOptions() this->TargetDir = optIFW_TARGET_DIRECTORY; } else if (const char* optPACKAGE_INSTALL_DIRECTORY = this->GetOption("CPACK_PACKAGE_INSTALL_DIRECTORY")) { - this->TargetDir = "@ApplicationsDir@/"; - this->TargetDir += optPACKAGE_INSTALL_DIRECTORY; + this->TargetDir = + cmStrCat("@ApplicationsDir@/", optPACKAGE_INSTALL_DIRECTORY); } else { this->TargetDir = "@RootDir@/usr/local"; } diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 5b01ae6..e960fab 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -11,6 +11,7 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmUuid.h" +#include "cm_string_view.hxx" #include <algorithm> #include "cmWIXDirectoriesSourceWriter.h" @@ -519,9 +520,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() for (auto const& i : this->Components) { cmCPackComponent const& component = i.second; - std::string componentPath = toplevel; - componentPath += "/"; - componentPath += component.Name; + std::string componentPath = cmStrCat(toplevel, '/', component.Name); std::string const componentFeatureId = "CM_C_" + component.Name; @@ -1087,8 +1086,7 @@ std::string cmCPackWIXGenerator::CreateHashedId( cmCryptoHash sha1(cmCryptoHash::AlgoSHA1); std::string const hash = sha1.HashString(path); - std::string identifier; - identifier += hash.substr(0, 7) + "_"; + std::string identifier = cmStrCat(cm::string_view(hash).substr(0, 7), '_'); const size_t maxFileNameLength = 52; if (normalizedFilename.length() > maxFileNameLength) { diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index 98fb29d..6c9c6b9 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -6,6 +6,7 @@ #include "cmCPackGenerator.h" #include "cmCPackLog.h" #include "cmGeneratedFileStream.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmWorkingDirectory.h" @@ -71,8 +72,7 @@ int cmCPackArchiveGenerator::addOneComponentToArchive( } std::string filePrefix; if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) { - filePrefix = this->GetOption("CPACK_PACKAGE_FILE_NAME"); - filePrefix += "/"; + filePrefix = cmStrCat(this->GetOption("CPACK_PACKAGE_FILE_NAME"), '/'); } const char* installPrefix = this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX"); diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx index 213ce92..f58cc0a 100644 --- a/Source/CPack/cmCPackBundleGenerator.cxx +++ b/Source/CPack/cmCPackBundleGenerator.cxx @@ -41,9 +41,8 @@ int cmCPackBundleGenerator::InitializeInternal() const char* cmCPackBundleGenerator::GetPackagingInstallPrefix() { - this->InstallPrefix = "/"; - this->InstallPrefix += this->GetOption("CPACK_BUNDLE_NAME"); - this->InstallPrefix += ".app/Contents/Resources"; + this->InstallPrefix = cmStrCat('/', this->GetOption("CPACK_BUNDLE_NAME"), + ".app/Contents/Resources"); return this->InstallPrefix.c_str(); } @@ -191,9 +190,8 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir) if (!cpack_apple_cert_app.empty()) { std::string output; std::string bundle_path; - bundle_path = src_dir + "/"; - bundle_path += this->GetOption("CPACK_BUNDLE_NAME"); - bundle_path += ".app"; + bundle_path = + cmStrCat(src_dir, '/', this->GetOption("CPACK_BUNDLE_NAME"), ".app"); // A list of additional files to sign, ie. frameworks and plugins. const std::string sign_parameter = diff --git a/Source/CPack/cmCPackComponentGroup.cxx b/Source/CPack/cmCPackComponentGroup.cxx index f888a5f..9e05d86 100644 --- a/Source/CPack/cmCPackComponentGroup.cxx +++ b/Source/CPack/cmCPackComponentGroup.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackComponentGroup.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include <string> @@ -14,9 +15,7 @@ unsigned long cmCPackComponent::GetInstalledSize( } for (std::string const& file : this->Files) { - std::string path = installDir; - path += '/'; - path += file; + std::string path = cmStrCat(installDir, '/', file); this->TotalSize += cmSystemTools::FileLength(path); } diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx index 49a9f15..553a677 100644 --- a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx +++ b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx @@ -28,13 +28,11 @@ int cmCPackCygwinBinaryGenerator::InitializeInternal() int cmCPackCygwinBinaryGenerator::PackageFiles() { - std::string packageName = this->GetOption("CPACK_PACKAGE_NAME"); - packageName += "-"; - packageName += this->GetOption("CPACK_PACKAGE_VERSION"); + std::string packageName = + cmStrCat(this->GetOption("CPACK_PACKAGE_NAME"), '-', + this->GetOption("CPACK_PACKAGE_VERSION")); packageName = cmsys::SystemTools::LowerCase(packageName); - std::string manifest = "/usr/share/doc/"; - manifest += packageName; - manifest += "/MANIFEST"; + std::string manifest = cmStrCat("/usr/share/doc/", packageName, "/MANIFEST"); std::string manifestFile = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); // Create a MANIFEST file that contains all of the files in // the tar file diff --git a/Source/CPack/cmCPackCygwinSourceGenerator.cxx b/Source/CPack/cmCPackCygwinSourceGenerator.cxx index 889f29a..8cae9b4 100644 --- a/Source/CPack/cmCPackCygwinSourceGenerator.cxx +++ b/Source/CPack/cmCPackCygwinSourceGenerator.cxx @@ -37,8 +37,7 @@ int cmCPackCygwinSourceGenerator::PackageFiles() { // Create a tar file of the sources std::string packageDirFileName = - this->GetOption("CPACK_TEMPORARY_DIRECTORY"); - packageDirFileName += ".tar.bz2"; + cmStrCat(this->GetOption("CPACK_TEMPORARY_DIRECTORY"), ".tar.bz2"); packageFileNames[0] = packageDirFileName; std::string output; // skip one parent up to the cmCPackTarBZip2Generator @@ -94,8 +93,8 @@ int cmCPackCygwinSourceGenerator::PackageFiles() << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n"); return 0; } - std::string outerTarFile = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); - outerTarFile += "-"; + std::string outerTarFile = + cmStrCat(this->GetOption("CPACK_TEMPORARY_DIRECTORY"), '-'); const char* patch = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER"); if (!patch) { cmCPackLogger(cmCPackLog::LOG_WARNING, @@ -106,19 +105,18 @@ int cmCPackCygwinSourceGenerator::PackageFiles() outerTarFile += patch; outerTarFile += "-src.tar.bz2"; std::string tmpDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - std::string buildScript = tmpDir; - buildScript += "/"; - buildScript += cmSystemTools::GetFilenameName( - this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT")); - std::string patchFile = tmpDir; - patchFile += "/"; - patchFile += - cmSystemTools::GetFilenameName(this->GetOption("CPACK_CYGWIN_PATCH_FILE")); + std::string buildScript = + cmStrCat(tmpDir, '/', + cmSystemTools::GetFilenameName( + this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"))); + std::string patchFile = + cmStrCat(tmpDir, '/', + cmSystemTools::GetFilenameName( + this->GetOption("CPACK_CYGWIN_PATCH_FILE"))); std::string file = cmSystemTools::GetFilenameName(compressOutFile); - std::string sourceTar = cmSystemTools::GetFilenamePath(compressOutFile); - sourceTar += "/"; - sourceTar += file; + std::string sourceTar = + cmStrCat(cmSystemTools::GetFilenamePath(compressOutFile), '/', file); /* reset list of file to be packaged */ files.clear(); // a source release in cygwin should have the build script used @@ -140,8 +138,8 @@ int cmCPackCygwinSourceGenerator::PackageFiles() const char* cmCPackCygwinSourceGenerator::GetPackagingInstallPrefix() { - this->InstallPrefix = "/"; - this->InstallPrefix += this->GetOption("CPACK_PACKAGE_FILE_NAME"); + this->InstallPrefix = + cmStrCat('/', this->GetOption("CPACK_PACKAGE_FILE_NAME")); return this->InstallPrefix.c_str(); } diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 7c2f21a..db336b0 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -149,8 +149,7 @@ void DebGenerator::generateControlFile() const unsigned long totalSize = 0; { - std::string dirName = TemporaryDir; - dirName += '/'; + std::string dirName = cmStrCat(TemporaryDir, '/'); for (std::string const& file : PackageFiles) { totalSize += cmSystemTools::FileLength(file); } @@ -248,8 +247,7 @@ std::string DebGenerator::generateMD5File() const cmGeneratedFileStream out(md5filename); - std::string topLevelWithTrailingSlash = TemporaryDir; - topLevelWithTrailingSlash += '/'; + std::string topLevelWithTrailingSlash = cmStrCat(TemporaryDir, '/'); for (std::string const& file : PackageFiles) { // hash only regular files if (cmSystemTools::FileIsDirectory(file) || @@ -469,8 +467,7 @@ int cmCPackDebGenerator::PackageOnePack(std::string const& initialTopLevel, // Tell CPackDeb.cmake the name of the component GROUP. this->SetOption("CPACK_DEB_PACKAGE_COMPONENT", packageName.c_str()); // Tell CPackDeb.cmake the path where the component is. - std::string component_path = "/"; - component_path += packageName; + std::string component_path = cmStrCat('/', packageName); this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH", component_path.c_str()); if (!this->ReadListFile("Internal/CPack/CPackDeb.cmake")) { @@ -500,9 +497,8 @@ int cmCPackDebGenerator::PackageOnePack(std::string const& initialTopLevel, retval = 0; } // add the generated package to package file names list - packageFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - packageFileName += "/"; - packageFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME"); + packageFileName = cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), '/', + this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME")); packageFileNames.push_back(std::move(packageFileName)); if (this->IsOn("GEN_CPACK_DEBIAN_DEBUGINFO_PACKAGE")) { @@ -524,9 +520,9 @@ int cmCPackDebGenerator::PackageOnePack(std::string const& initialTopLevel, retval = 0; } // add the generated package to package file names list - packageFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - packageFileName += "/"; - packageFileName += this->GetOption("GEN_CPACK_DBGSYM_OUTPUT_FILE_NAME"); + packageFileName = + cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), '/', + this->GetOption("GEN_CPACK_DBGSYM_OUTPUT_FILE_NAME")); packageFileNames.push_back(std::move(packageFileName)); } @@ -614,8 +610,7 @@ int cmCPackDebGenerator::PackageComponentsAllInOne( if (!compInstDirName.empty()) { // Tell CPackDeb.cmake the path where the component is. - std::string component_path = "/"; - component_path += compInstDirName; + std::string component_path = cmStrCat('/', compInstDirName); this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH", component_path.c_str()); } @@ -644,9 +639,8 @@ int cmCPackDebGenerator::PackageComponentsAllInOne( retval = 0; } // add the generated package to package file names list - packageFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - packageFileName += "/"; - packageFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME"); + packageFileName = cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), '/', + this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME")); packageFileNames.push_back(std::move(packageFileName)); return retval; } diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 85faa61..2aa0612 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -196,9 +196,7 @@ int cmCPackDragNDropGenerator::PackageFiles() full_package_name += std::string(GetOutputExtension()); packageFileNames.push_back(full_package_name); - std::string src_dir = toplevel; - src_dir += "/"; - src_dir += package_file; + std::string src_dir = cmStrCat(toplevel, '/', package_file); if (0 == this->CreateDMG(src_dir, full_package_name)) { return 0; @@ -409,8 +407,8 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, } // Create a temporary read-write disk image ... - std::string temp_image = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - temp_image += "/temp.dmg"; + std::string temp_image = + cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/temp.dmg"); std::string create_error; std::ostringstream temp_image_command; @@ -522,8 +520,8 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, if (!cpack_license_file.empty() || !slaDirectory.empty()) { // Use old hardcoded style if sla_dir is not set bool oldStyle = slaDirectory.empty(); - std::string sla_r = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - sla_r += "/sla.r"; + std::string sla_r = + cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/sla.r"); std::vector<std::string> languages; if (!oldStyle) { @@ -649,8 +647,8 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, if (temp_image_format != "UDZO") { temp_image_format = "UDZO"; // convert to UDZO to enable unflatten/flatten - std::string temp_udzo = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - temp_udzo += "/temp-udzo.dmg"; + std::string temp_udzo = cmStrCat( + this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/temp-udzo.dmg"); std::ostringstream udco_image_command; udco_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index f3de53c..0e9f1b6 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -73,8 +73,8 @@ int cmCPackGenerator::PrepareNames() } } - std::string tempDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY"); - tempDirectory += "/_CPack_Packages/"; + std::string tempDirectory = + cmStrCat(this->GetOption("CPACK_PACKAGE_DIRECTORY"), "/_CPack_Packages/"); const char* toplevelTag = this->GetOption("CPACK_TOPLEVEL_TAG"); if (toplevelTag) { tempDirectory += toplevelTag; @@ -197,8 +197,7 @@ int cmCPackGenerator::InstallProject() } if (setDestDir) { - std::string destDir = "DESTDIR="; - destDir += tempInstallDirectory; + std::string destDir = cmStrCat("DESTDIR=", tempInstallDirectory); cmSystemTools::PutEnv(destDir); } else { // Make sure there is no destdir @@ -271,8 +270,8 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( (void)setDestDir; const char* installCommands = this->GetOption("CPACK_INSTALL_COMMANDS"); if (installCommands && *installCommands) { - std::string tempInstallDirectoryEnv = "CMAKE_INSTALL_PREFIX="; - tempInstallDirectoryEnv += tempInstallDirectory; + std::string tempInstallDirectoryEnv = + cmStrCat("CMAKE_INSTALL_PREFIX=", tempInstallDirectory); cmSystemTools::PutEnv(tempInstallDirectoryEnv); std::vector<std::string> installCommandsVector; cmExpandList(installCommands, installCommandsVector); @@ -284,8 +283,8 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( ic, &output, &output, &retVal, nullptr, this->GeneratorVerbose, cmDuration::zero()); if (!resB || retVal) { - std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - tmpFile += "/InstallOutput.log"; + std::string tmpFile = cmStrCat( + this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/InstallOutput.log"); cmGeneratedFileStream ofs(tmpFile); ofs << "# Run command: " << ic << std::endl << "# Output:" << std::endl @@ -343,8 +342,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( std::string top = *it; it++; std::string subdir = *it; - std::string findExpr = top; - findExpr += "/*"; + std::string findExpr = cmStrCat(top, "/*"); cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Install directory: " << top << std::endl); gl.RecurseOn(); @@ -372,8 +370,8 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( if (skip) { continue; } - std::string filePath = tempDir; - filePath += "/" + subdir + "/" + cmSystemTools::RelativePath(top, gf); + std::string filePath = cmStrCat(tempDir, '/', subdir, '/', + cmSystemTools::RelativePath(top, gf)); cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: " << inFile << " -> " << filePath << std::endl); @@ -398,8 +396,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( /* rebuild symlinks in the installed tree */ if (!symlinkedFiles.empty()) { std::string curDir = cmSystemTools::GetCurrentWorkingDirectory(); - std::string goToDir = tempDir; - goToDir += "/" + subdir; + std::string goToDir = cmStrCat(tempDir, '/', subdir); cmCPackLogger(cmCPackLog::LOG_DEBUG, "Change dir to: " << goToDir << std::endl); cmWorkingDirectory workdir(goToDir); @@ -662,8 +659,8 @@ int cmCPackGenerator::RunPreinstallTarget( buildCommand, &output, &output, &retVal, installDirectory.c_str(), this->GeneratorVerbose, cmDuration::zero()); if (!resB || retVal) { - std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - tmpFile += "/PreinstallOutput.log"; + std::string tmpFile = cmStrCat( + this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/PreinstallOutput.log"); cmGeneratedFileStream ofs(tmpFile); ofs << "# Run command: " << buildCommand << std::endl << "# Directory: " << installDirectory << std::endl @@ -911,10 +908,8 @@ int cmCPackGenerator::InstallCMakeProject( GetComponentInstallDirNameSuffix(component); if (nullptr != this->GetOption(absoluteDestFileComponent)) { std::string absoluteDestFilesListComponent = - this->GetOption(absoluteDestFileComponent); - absoluteDestFilesListComponent += ";"; - absoluteDestFilesListComponent += - mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"); + cmStrCat(this->GetOption(absoluteDestFileComponent), ';', + mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")); this->SetOption(absoluteDestFileComponent, absoluteDestFilesListComponent.c_str()); } else { @@ -1006,8 +1001,7 @@ int cmCPackGenerator::DoPackage() cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl); cmsys::Glob gl; - std::string findExpr = tempDirectory; - findExpr += "/*"; + std::string findExpr = cmStrCat(tempDirectory, "/*"); gl.RecurseOn(); gl.SetRecurseListDirs(true); gl.SetRecurseThroughSymlinks(false); @@ -1203,8 +1197,7 @@ const char* cmCPackGenerator::GetInstallPath() if (cmsys::SystemTools::GetEnv("ProgramFiles", prgfiles)) { this->InstallPath = prgfiles; } else if (cmsys::SystemTools::GetEnv("SystemDrive", sysDrive)) { - this->InstallPath = sysDrive; - this->InstallPath += "/Program Files"; + this->InstallPath = cmStrCat(sysDrive, "/Program Files"); } else { this->InstallPath = "c:/Program Files"; } diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 7ca343a..41ffa0e 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -56,8 +56,7 @@ int cmCPackNSISGenerator::PackageFiles() } std::string nsisFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - std::string tmpFile = nsisFileName; - tmpFile += "/NSISOutput.log"; + std::string tmpFile = cmStrCat(nsisFileName, "/NSISOutput.log"); std::string nsisInstallOptions = nsisFileName + "/NSIS.InstallOptions.ini"; nsisFileName += "/project.nsi"; std::ostringstream str; @@ -142,39 +141,34 @@ int cmCPackNSISGenerator::PackageFiles() installerIconCode.c_str()); } if (this->IsSet("CPACK_PACKAGE_ICON")) { - std::string installerIconCode = "!define MUI_HEADERIMAGE_BITMAP \""; - installerIconCode += this->GetOption("CPACK_PACKAGE_ICON"); - installerIconCode += "\"\n"; + std::string installerIconCode = + cmStrCat("!define MUI_HEADERIMAGE_BITMAP \"", + this->GetOption("CPACK_PACKAGE_ICON"), "\"\n"); this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_ICON_CODE", installerIconCode.c_str()); } if (this->IsSet("CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP")) { - std::string installerBitmapCode = - "!define MUI_WELCOMEFINISHPAGE_BITMAP \""; - installerBitmapCode += - this->GetOption("CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP"); - installerBitmapCode += "\"\n"; + std::string installerBitmapCode = cmStrCat( + "!define MUI_WELCOMEFINISHPAGE_BITMAP \"", + this->GetOption("CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP"), "\"\n"); this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_WELCOMEFINISH_CODE", installerBitmapCode.c_str()); } if (this->IsSet("CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP")) { - std::string installerBitmapCode = - "!define MUI_UNWELCOMEFINISHPAGE_BITMAP \""; - installerBitmapCode += - this->GetOption("CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP"); - installerBitmapCode += "\"\n"; + std::string installerBitmapCode = cmStrCat( + "!define MUI_UNWELCOMEFINISHPAGE_BITMAP \"", + this->GetOption("CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP"), "\"\n"); this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_UNWELCOMEFINISH_CODE", installerBitmapCode.c_str()); } if (this->IsSet("CPACK_NSIS_MUI_FINISHPAGE_RUN")) { - std::string installerRunCode = "!define MUI_FINISHPAGE_RUN \"$INSTDIR\\"; - installerRunCode += this->GetOption("CPACK_NSIS_EXECUTABLES_DIRECTORY"); - installerRunCode += "\\"; - installerRunCode += this->GetOption("CPACK_NSIS_MUI_FINISHPAGE_RUN"); - installerRunCode += "\"\n"; + std::string installerRunCode = + cmStrCat("!define MUI_FINISHPAGE_RUN \"$INSTDIR\\", + this->GetOption("CPACK_NSIS_EXECUTABLES_DIRECTORY"), '\\', + this->GetOption("CPACK_NSIS_MUI_FINISHPAGE_RUN"), "\"\n"); this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_FINISHPAGE_RUN_CODE", installerRunCode.c_str()); } @@ -297,9 +291,9 @@ int cmCPackNSISGenerator::PackageFiles() this->ConfigureFile(nsisInInstallOptions, nsisInstallOptions); this->ConfigureFile(nsisInFileName, nsisFileName); - std::string nsisCmd = "\""; - nsisCmd += this->GetOption("CPACK_INSTALLER_PROGRAM"); - nsisCmd += "\" \"" + nsisFileName + "\""; + std::string nsisCmd = + cmStrCat('"', this->GetOption("CPACK_INSTALLER_PROGRAM"), "\" \"", + nsisFileName, '"'); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << nsisCmd << std::endl); std::string output; int retVal = 1; @@ -415,8 +409,7 @@ int cmCPackNSISGenerator::InitializeInternal() if (!resS || retVal || (!versionRex.find(output) && !versionRexCVS.find(output))) { const char* topDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - std::string tmpFile = topDir ? topDir : "."; - tmpFile += "/NSISOutput.log"; + std::string tmpFile = cmStrCat(topDir ? topDir : ".", "/NSISOutput.log"); cmGeneratedFileStream ofs(tmpFile); ofs << "# Run command: " << nsisCmd << std::endl << "# Output:" << std::endl @@ -573,8 +566,7 @@ void cmCPackNSISGenerator::CreateMenuLinks(std::ostream& str, } // see if CPACK_CREATE_DESKTOP_LINK_ExeName is on // if so add a desktop link - std::string desktop = "CPACK_CREATE_DESKTOP_LINK_"; - desktop += linkName; + std::string desktop = cmStrCat("CPACK_CREATE_DESKTOP_LINK_", linkName); if (this->IsSet(desktop)) { str << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n"; str << " CreateShortCut \"$DESKTOP\\" << linkName @@ -656,8 +648,8 @@ std::string cmCPackNSISGenerator::CreateComponentDescription( if (component->IsDownloaded) { if (component->ArchiveFile.empty()) { // Compute the name of the archive. - std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); - packagesDir += ".dummy"; + std::string packagesDir = + cmStrCat(this->GetOption("CPACK_TEMPORARY_DIRECTORY"), ".dummy"); std::ostringstream out; out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) << "-" << component->Name << ".zip"; @@ -671,8 +663,8 @@ std::string cmCPackNSISGenerator::CreateComponentDescription( if (userUploadDirectory && *userUploadDirectory) { uploadDirectory = userUploadDirectory; } else { - uploadDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY"); - uploadDirectory += "/CPackUploads"; + uploadDirectory = + cmStrCat(this->GetOption("CPACK_PACKAGE_DIRECTORY"), "/CPackUploads"); } if (!cmSystemTools::FileExists(uploadDirectory)) { if (!cmSystemTools::MakeDirectory(uploadDirectory)) { @@ -709,15 +701,13 @@ std::string cmCPackNSISGenerator::CreateComponentDescription( } // The directory where this component's files reside - std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); - dirName += '/'; - dirName += component->Name; - dirName += '/'; + std::string dirName = cmStrCat( + this->GetOption("CPACK_TEMPORARY_DIRECTORY"), '/', component->Name, '/'); // Build the list of files to go into this archive, and determine the // size of the installed component. - std::string zipListFileName = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); - zipListFileName += "/winZip.filelist"; + std::string zipListFileName = cmStrCat( + this->GetOption("CPACK_TEMPORARY_DIRECTORY"), "/winZip.filelist"); bool needQuotesInFile = cmIsOn(this->GetOption("CPACK_ZIP_NEED_QUOTES")); unsigned long totalSize = 0; { // the scope is needed for cmGeneratedFileStream @@ -747,8 +737,8 @@ std::string cmCPackNSISGenerator::CreateComponentDescription( cmd, &output, &output, &retVal, dirName.c_str(), cmSystemTools::OUTPUT_NONE, cmDuration::zero()); if (!res || retVal) { - std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - tmpFile += "/CompressZip.log"; + std::string tmpFile = cmStrCat( + this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/CompressZip.log"); cmGeneratedFileStream ofs(tmpFile); ofs << "# Run command: " << cmd << std::endl << "# Output:" << std::endl diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index 7cc48f4..ffa8a42 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -55,16 +55,14 @@ int cmCPackOSXX11Generator::PackageFiles() diskImageDirectory + "/.background"; // App bundle directories - std::string packageDirFileName = toplevel; - packageDirFileName += "/"; - packageDirFileName += this->GetOption("CPACK_PACKAGE_FILE_NAME"); - packageDirFileName += ".app"; + std::string packageDirFileName = cmStrCat( + toplevel, '/', this->GetOption("CPACK_PACKAGE_FILE_NAME"), ".app"); std::string contentsDirectory = packageDirFileName + "/Contents"; std::string resourcesDirectory = contentsDirectory + "/Resources"; std::string appDirectory = contentsDirectory + "/MacOS"; std::string scriptDirectory = resourcesDirectory + "/Scripts"; - std::string resourceFileName = this->GetOption("CPACK_PACKAGE_FILE_NAME"); - resourceFileName += ".rsrc"; + std::string resourceFileName = + cmStrCat(this->GetOption("CPACK_PACKAGE_FILE_NAME"), ".rsrc"); const char* dir = resourcesDirectory.c_str(); const char* appdir = appDirectory.c_str(); @@ -113,13 +111,10 @@ int cmCPackOSXX11Generator::PackageFiles() } // Two of the files need to have execute permission, so ensure they do: - std::string runTimeScript = dir; - runTimeScript += "/"; - runTimeScript += "RuntimeScript"; + std::string runTimeScript = cmStrCat(dir, "/RuntimeScript"); - std::string appScriptName = appdir; - appScriptName += "/"; - appScriptName += this->GetOption("CPACK_PACKAGE_FILE_NAME"); + std::string appScriptName = + cmStrCat(appdir, '/', this->GetOption("CPACK_PACKAGE_FILE_NAME")); mode_t mode; if (cmsys::SystemTools::GetPermissions(runTimeScript.c_str(), mode)) { @@ -139,8 +134,8 @@ int cmCPackOSXX11Generator::PackageFiles() } std::string output; - std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - tmpFile += "/hdiutilOutput.log"; + std::string tmpFile = cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), + "/hdiutilOutput.log"); std::ostringstream dmgCmd; dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE") << "\" create -ov -fs HFS+ -format UDZO -srcfolder \"" @@ -228,9 +223,8 @@ bool cmCPackOSXX11Generator::CopyCreateResourceFile(const std::string& name) return false; } - std::string destFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - destFileName += "/Resources/"; - destFileName += name + ext; + std::string destFileName = cmStrCat( +this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/Resources/", name, ext ); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " @@ -245,9 +239,7 @@ bool cmCPackOSXX11Generator::CopyResourcePlistFile( const std::string& name, const std::string& dir, const char* outputFileName /* = 0 */, bool copyOnly /* = false */) { - std::string inFName = "Internal/CPack/CPack."; - inFName += name; - inFName += ".in"; + std::string inFName = cmStrCat("Internal/CPack/CPack.", name, ".in"); std::string inFileName = this->FindTemplate(inFName.c_str()); if (inFileName.empty()) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -259,9 +251,7 @@ bool cmCPackOSXX11Generator::CopyResourcePlistFile( outputFileName = name.c_str(); } - std::string destFileName = dir; - destFileName += "/"; - destFileName += outputFileName; + std::string destFileName = cmStrCat(dir, '/', outputFileName); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << inFileName << " to " << destFileName @@ -272,8 +262,8 @@ bool cmCPackOSXX11Generator::CopyResourcePlistFile( const char* cmCPackOSXX11Generator::GetPackagingInstallPrefix() { - this->InstallPrefix = "/"; - this->InstallPrefix += this->GetOption("CPACK_PACKAGE_FILE_NAME"); - this->InstallPrefix += ".app/Contents/Resources"; + this->InstallPrefix = + cmStrCat('/', this->GetOption("CPACK_PACKAGE_FILE_NAME"), + ".app/Contents/Resources"); return this->InstallPrefix.c_str(); } diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx index d361921..3e1a51b 100644 --- a/Source/CPack/cmCPackPKGGenerator.cxx +++ b/Source/CPack/cmCPackPKGGenerator.cxx @@ -7,6 +7,7 @@ #include "cmCPackComponentGroup.h" #include "cmCPackGenerator.h" #include "cmCPackLog.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmXMLWriter.h" @@ -34,8 +35,8 @@ std::string cmCPackPKGGenerator::GetPackageName( const cmCPackComponent& component) { if (component.ArchiveFile.empty()) { - std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); - packagesDir += ".dummy"; + std::string packagesDir = + cmStrCat(this->GetOption("CPACK_TEMPORARY_DIRECTORY"), ".dummy"); std::ostringstream out; out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) << "-" << component.Name << ".pkg"; @@ -56,8 +57,8 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile) return; } - std::string distributionFile = metapackageFile; - distributionFile += "/Contents/distribution.dist"; + std::string distributionFile = + cmStrCat(metapackageFile, "/Contents/distribution.dist"); // Create the choice outline, which provides a tree-based view of // the components in their groups. @@ -144,12 +145,9 @@ void cmCPackPKGGenerator::CreateChoice(const cmCPackComponentGroup& group, void cmCPackPKGGenerator::CreateChoice(const cmCPackComponent& component, cmXMLWriter& xout) { - std::string packageId = "com."; - packageId += this->GetOption("CPACK_PACKAGE_VENDOR"); - packageId += '.'; - packageId += this->GetOption("CPACK_PACKAGE_NAME"); - packageId += '.'; - packageId += component.Name; + std::string packageId = + cmStrCat("com.", this->GetOption("CPACK_PACKAGE_VENDOR"), '.', + this->GetOption("CPACK_PACKAGE_NAME"), '.', component.Name); xout.StartElement("choice"); xout.Attribute("id", component.Name + "Choice"); @@ -192,14 +190,13 @@ void cmCPackPKGGenerator::CreateChoice(const cmCPackComponent& component, // Create a description of the package associated with this // component. - std::string relativePackageLocation = "Contents/Packages/"; - relativePackageLocation += this->GetPackageName(component); + std::string relativePackageLocation = + cmStrCat("Contents/Packages/", this->GetPackageName(component)); // Determine the installed size of the package. - std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); - dirName += '/'; - dirName += component.Name; - dirName += this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX"); + std::string dirName = + cmStrCat(this->GetOption("CPACK_TEMPORARY_DIRECTORY"), '/', component.Name, + this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX")); unsigned long installedSize = component.GetInstalledSizeInKbytes(dirName); xout.StartElement("pkg-ref"); @@ -282,9 +279,7 @@ bool cmCPackPKGGenerator::CopyCreateResourceFile(const std::string& name, return false; } - std::string destFileName = dirName; - destFileName += '/'; - destFileName += name + ext; + std::string destFileName = cmStrCat(dirName, '/', name, ext); // Set this so that distribution.dist gets the right name (without // the path). @@ -305,9 +300,7 @@ bool cmCPackPKGGenerator::CopyResourcePlistFile(const std::string& name, outName = name.c_str(); } - std::string inFName = "Internal/CPack/CPack."; - inFName += name; - inFName += ".in"; + std::string inFName = cmStrCat("Internal/CPack/CPack.", name, ".in"); std::string inFileName = this->FindTemplate(inFName.c_str()); if (inFileName.empty()) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -315,9 +308,8 @@ bool cmCPackPKGGenerator::CopyResourcePlistFile(const std::string& name, return false; } - std::string destFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - destFileName += "/"; - destFileName += outName; + std::string destFileName = + cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), '/', outName); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << inFileName << " to " << destFileName @@ -330,9 +322,7 @@ int cmCPackPKGGenerator::CopyInstallScript(const std::string& resdir, const std::string& script, const std::string& name) { - std::string dst = resdir; - dst += "/"; - dst += name; + std::string dst = cmStrCat(resdir, '/', name); cmSystemTools::CopyFileAlways(script, dst); cmSystemTools::SetPermissions(dst.c_str(), 0777); cmCPackLogger(cmCPackLog::LOG_VERBOSE, diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index 3d93c48..5dc36ab 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -15,6 +15,7 @@ #include "cmCPackLog.h" #include "cmDuration.h" #include "cmGeneratedFileStream.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmXMLWriter.h" @@ -47,8 +48,8 @@ int cmCPackPackageMakerGenerator::PackageFiles() this->GetOption("CPACK_TEMPORARY_DIRECTORY"); if (this->Components.empty()) { packageDirFileName += ".pkg"; - resDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - resDir += "/Resources"; + resDir = + cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/Resources"); } else { packageDirFileName += ".mpkg"; if (!cmsys::SystemTools::MakeDirectory(packageDirFileName.c_str())) { @@ -58,8 +59,7 @@ int cmCPackPackageMakerGenerator::PackageFiles() return 0; } - resDir = packageDirFileName; - resDir += "/Contents"; + resDir = cmStrCat(packageDirFileName, "/Contents"); if (!cmsys::SystemTools::MakeDirectory(resDir.c_str())) { cmCPackLogger(cmCPackLog::LOG_ERROR, "unable to create package subdirectory " << resDir @@ -155,8 +155,8 @@ int cmCPackPackageMakerGenerator::PackageFiles() if (!this->Components.empty()) { // Create the directory where component packages will be built. - std::string basePackageDir = packageDirFileName; - basePackageDir += "/Contents/Packages"; + std::string basePackageDir = + cmStrCat(packageDirFileName, "/Contents/Packages"); if (!cmsys::SystemTools::MakeDirectory(basePackageDir.c_str())) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem creating component packages directory: " @@ -172,8 +172,8 @@ int cmCPackPackageMakerGenerator::PackageFiles() if (userUploadDirectory && *userUploadDirectory) { uploadDirectory = userUploadDirectory; } else { - uploadDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY"); - uploadDirectory += "/CPackUploads"; + uploadDirectory = + cmStrCat(this->GetOption("CPACK_PACKAGE_DIRECTORY"), "/CPackUploads"); } // Create packages for each component @@ -232,9 +232,7 @@ int cmCPackPackageMakerGenerator::PackageFiles() packageFile += '/'; packageFile += GetPackageName(compIt->second); - std::string packageDir = toplevel; - packageDir += '/'; - packageDir += compIt->first; + std::string packageDir = cmStrCat(toplevel, '/', compIt->first); if (!this->GenerateComponentPackage( packageFile.c_str(), packageDir.c_str(), compIt->second)) { return 0; @@ -283,8 +281,8 @@ int cmCPackPackageMakerGenerator::PackageFiles() WriteDistributionFile(packageDirFileName.c_str()); } - std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - tmpFile += "/hdiutilOutput.log"; + std::string tmpFile = cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), + "/hdiutilOutput.log"); std::ostringstream dmgCmd; dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE") << "\" create -ov -fs HFS+ -format UDZO -srcfolder \"" @@ -461,8 +459,8 @@ int cmCPackPackageMakerGenerator::InitializeInternal() bool cmCPackPackageMakerGenerator::RunPackageMaker(const char* command, const char* packageFile) { - std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - tmpFile += "/PackageMakerOutput.log"; + std::string tmpFile = cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), + "/PackageMakerOutput.log"); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << command << std::endl); std::string output; @@ -517,8 +515,9 @@ bool cmCPackPackageMakerGenerator::GenerateComponentPackage( this->PackageMakerVersion < 3.0) { // Create Description.plist and Info.plist files for normal Mac OS // X packages, which work on Mac OS X 10.3 and newer. - std::string descriptionFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - descriptionFile += '/' + component.Name + "-Description.plist"; + std::string descriptionFile = + cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), '/', + component.Name, "-Description.plist"); cmsys::ofstream out(descriptionFile.c_str()); cmXMLWriter xout(out); xout.StartDocument(); @@ -539,12 +538,10 @@ bool cmCPackPackageMakerGenerator::GenerateComponentPackage( out.close(); // Create the Info.plist file for this component - std::string moduleVersionSuffix = "."; - moduleVersionSuffix += component.Name; + std::string moduleVersionSuffix = cmStrCat('.', component.Name); this->SetOption("CPACK_MODULE_VERSION_SUFFIX", moduleVersionSuffix.c_str()); - std::string infoFileName = component.Name; - infoFileName += "-Info.plist"; + std::string infoFileName = cmStrCat(component.Name, "-Info.plist"); if (!this->CopyResourcePlistFile("Info.plist", infoFileName.c_str())) { return false; } @@ -561,12 +558,9 @@ bool cmCPackPackageMakerGenerator::GenerateComponentPackage( // like normal packages, and can be downloaded by the installer // on-the-fly in Mac OS X 10.5 or newer. Thus, we need to create // flat packages when the packages will be downloaded on the fly. - std::string pkgId = "com."; - pkgId += this->GetOption("CPACK_PACKAGE_VENDOR"); - pkgId += '.'; - pkgId += this->GetOption("CPACK_PACKAGE_NAME"); - pkgId += '.'; - pkgId += component.Name; + std::string pkgId = + cmStrCat("com.", this->GetOption("CPACK_PACKAGE_VENDOR"), '.', + this->GetOption("CPACK_PACKAGE_NAME"), '.', component.Name); pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM") << "\" --root \"" << packageDir << "\"" diff --git a/Source/CPack/cmCPackProductBuildGenerator.cxx b/Source/CPack/cmCPackProductBuildGenerator.cxx index 94b5b5f..800af28 100644 --- a/Source/CPack/cmCPackProductBuildGenerator.cxx +++ b/Source/CPack/cmCPackProductBuildGenerator.cxx @@ -10,6 +10,7 @@ #include "cmCPackLog.h" #include "cmDuration.h" #include "cmGeneratedFileStream.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" cmCPackProductBuildGenerator::cmCPackProductBuildGenerator() @@ -28,8 +29,8 @@ int cmCPackProductBuildGenerator::PackageFiles() this->GetOption("CPACK_TEMPORARY_DIRECTORY"); // Create the directory where component packages will be built. - std::string basePackageDir = packageDirFileName; - basePackageDir += "/Contents/Packages"; + std::string basePackageDir = + cmStrCat(packageDirFileName, "/Contents/Packages"); if (!cmsys::SystemTools::MakeDirectory(basePackageDir.c_str())) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem creating component packages directory: " @@ -41,9 +42,7 @@ int cmCPackProductBuildGenerator::PackageFiles() std::map<std::string, cmCPackComponent>::iterator compIt; for (compIt = this->Components.begin(); compIt != this->Components.end(); ++compIt) { - std::string packageDir = toplevel; - packageDir += '/'; - packageDir += compIt->first; + std::string packageDir = cmStrCat(toplevel, '/', compIt->first); if (!this->GenerateComponentPackage(basePackageDir, GetPackageName(compIt->second), packageDir, &compIt->second)) { @@ -138,8 +137,8 @@ int cmCPackProductBuildGenerator::InitializeInternal() bool cmCPackProductBuildGenerator::RunProductBuild(const std::string& command) { - std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - tmpFile += "/ProductBuildOutput.log"; + std::string tmpFile = cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), + "/ProductBuildOutput.log"); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << command << std::endl); std::string output; @@ -166,9 +165,7 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage( const std::string& packageFileDir, const std::string& packageFileName, const std::string& packageDir, const cmCPackComponent* component) { - std::string packageFile = packageFileDir; - packageFile += '/'; - packageFile += packageFileName; + std::string packageFile = cmStrCat(packageFileDir, '/', packageFileName); cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Building component package: " << packageFile @@ -206,10 +203,8 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage( // The command that will be used to run ProductBuild std::ostringstream pkgCmd; - std::string pkgId = "com."; - pkgId += this->GetOption("CPACK_PACKAGE_VENDOR"); - pkgId += '.'; - pkgId += this->GetOption("CPACK_PACKAGE_NAME"); + std::string pkgId = cmStrCat("com.", this->GetOption("CPACK_PACKAGE_VENDOR"), + '.', this->GetOption("CPACK_PACKAGE_NAME")); if (component) { pkgId += '.'; pkgId += component->Name; diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index 9ffebf5..0f621cc 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -82,8 +82,7 @@ int cmCPackRPMGenerator::PackageOnePack(std::string const& initialToplevel, // Tell CPackRPM.cmake the name of the component NAME. this->SetOption("CPACK_RPM_PACKAGE_COMPONENT", packageName.c_str()); // Tell CPackRPM.cmake the path where the component is. - std::string component_path = "/"; - component_path += packageName; + std::string component_path = cmStrCat('/', packageName); this->SetOption("CPACK_RPM_PACKAGE_COMPONENT_PART_PATH", component_path.c_str()); if (!this->ReadListFile("Internal/CPack/CPackRPM.cmake")) { @@ -376,8 +375,7 @@ int cmCPackRPMGenerator::PackageComponentsAllInOne( if (!compInstDirName.empty()) { // Tell CPackRPM.cmake the path where the component is. - std::string component_path = "/"; - component_path += compInstDirName; + std::string component_path = cmStrCat('/', compInstDirName); this->SetOption("CPACK_RPM_PACKAGE_COMPONENT_PART_PATH", component_path.c_str()); } diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 5abf0ab..a98fabc 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -230,8 +230,8 @@ int main(int argc, char const* const* argv) bool cpackConfigFileSpecified = true; if (cpackConfigFile.empty()) { - cpackConfigFile = cmSystemTools::GetCurrentWorkingDirectory(); - cpackConfigFile += "/CPackConfig.cmake"; + cpackConfigFile = cmStrCat(cmSystemTools::GetCurrentWorkingDirectory(), + "/CPackConfig.cmake"); cpackConfigFileSpecified = false; } |