diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2023-07-26 19:39:34 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2023-07-30 22:33:07 (GMT) |
commit | f5d04b5bf0c1b610ab80209f313996f050cd5979 (patch) | |
tree | a08a71d1c54231d6edc20ad881d4fd6ec216f9b0 /Source/CPack | |
parent | 3af822cd8f2197d176fa918f08f10e22dc3d4730 (diff) | |
download | CMake-f5d04b5bf0c1b610ab80209f313996f050cd5979.zip CMake-f5d04b5bf0c1b610ab80209f313996f050cd5979.tar.gz CMake-f5d04b5bf0c1b610ab80209f313996f050cd5979.tar.bz2 |
cmStrCat: use where possible in Apple-specific sources
Diffstat (limited to 'Source/CPack')
-rw-r--r-- | Source/CPack/cmCPackDragNDropGenerator.cxx | 28 | ||||
-rw-r--r-- | Source/CPack/cmCPackPKGGenerator.cxx | 27 | ||||
-rw-r--r-- | Source/CPack/cmCPackProductBuildGenerator.cxx | 26 |
3 files changed, 45 insertions, 36 deletions
diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index bd92839..82f58a2 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -136,8 +136,10 @@ int cmCPackDragNDropGenerator::InitializeInternal() return 0; } for (auto const& language : languages) { - std::string license = slaDirectory + "/" + language + ".license.txt"; - std::string license_rtf = slaDirectory + "/" + language + ".license.rtf"; + std::string license = + cmStrCat(slaDirectory, "/", language, ".license.txt"); + std::string license_rtf = + cmStrCat(slaDirectory, "/", language, ".license.rtf"); if (!singleLicense) { if (!cmSystemTools::FileExists(license) && !cmSystemTools::FileExists(license_rtf)) { @@ -148,7 +150,7 @@ int cmCPackDragNDropGenerator::InitializeInternal() return 0; } } - std::string menu = slaDirectory + "/" + language + ".menu.txt"; + std::string menu = cmStrCat(slaDirectory, "/", language, ".menu.txt"); if (!cmSystemTools::FileExists(menu)) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Missing menu file " << language << ".menu.txt" @@ -192,7 +194,7 @@ int cmCPackDragNDropGenerator::PackageFiles() // loop to create dmg files packageFileNames.clear(); for (auto const& package_file : package_files) { - std::string full_package_name = std::string(toplevel) + std::string("/"); + std::string full_package_name = cmStrCat(toplevel, "/"); if (package_file == "ALL_IN_ONE") { full_package_name += this->GetOption("CPACK_PACKAGE_FILE_NAME"); } else { @@ -711,8 +713,8 @@ std::string cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix( if (this->componentPackageMethod == ONE_PACKAGE_PER_GROUP) { // 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"); cmValue _groupName = this->GetOption(groupVar); if (_groupName) { std::string groupName = _groupName; @@ -723,8 +725,8 @@ std::string cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix( } } - std::string componentFileName = - "CPACK_DMG_" + cmSystemTools::UpperCase(componentName) + "_FILE_NAME"; + std::string componentFileName = cmStrCat( + "CPACK_DMG_", cmSystemTools::UpperCase(componentName), "_FILE_NAME"); if (this->IsSet(componentFileName)) { return this->GetOption(componentFileName); } @@ -808,12 +810,12 @@ bool cmCPackDragNDropGenerator::WriteLicense(RezDoc& rez, size_t licenseNumber, actual_license = licenseFile; } else { std::string license_wo_ext = - slaDirectory + "/" + licenseLanguage + ".license"; - if (cmSystemTools::FileExists(license_wo_ext + ".txt")) { - actual_license = license_wo_ext + ".txt"; + cmStrCat(slaDirectory, "/", licenseLanguage, ".license"); + if (cmSystemTools::FileExists(cmStrCat(license_wo_ext, ".txt"))) { + actual_license = cmStrCat(license_wo_ext, ".txt"); } else { licenseArray = &rez.RTF; - actual_license = license_wo_ext + ".rtf"; + actual_license = cmStrCat(license_wo_ext, ".rtf"); } } @@ -836,7 +838,7 @@ bool cmCPackDragNDropGenerator::WriteLicense(RezDoc& rez, size_t licenseNumber, } else { std::vector<std::string> lines; std::string actual_menu = - slaDirectory + "/" + licenseLanguage + ".menu.txt"; + cmStrCat(slaDirectory, "/", licenseLanguage, ".menu.txt"); if (!this->ReadFile(actual_menu, lines, error)) { return false; } diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx index 554cfcd..f113ff4 100644 --- a/Source/CPack/cmCPackPKGGenerator.cxx +++ b/Source/CPack/cmCPackPKGGenerator.cxx @@ -38,13 +38,12 @@ std::string cmCPackPKGGenerator::GetPackageName( if (component.ArchiveFile.empty()) { std::string packagesDir = cmStrCat(this->GetOption("CPACK_TEMPORARY_DIRECTORY"), ".dummy"); - std::ostringstream out; - out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) << "-" - << component.Name << ".pkg"; - return out.str(); + return cmStrCat( + cmSystemTools::GetFilenameWithoutLastExtension(packagesDir), "-", + component.Name, ".pkg"); } - return component.ArchiveFile + ".pkg"; + return cmStrCat(component.ArchiveFile, ".pkg"); } void cmCPackPKGGenerator::CreateBackground(const char* themeName, @@ -160,14 +159,15 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile, for (auto const& comp : this->Components) { if (!comp.second.Group) { xChoiceOut.StartElement("line"); - xChoiceOut.Attribute("choice", comp.first + "Choice"); + xChoiceOut.Attribute("choice", cmStrCat(comp.first, "Choice")); xChoiceOut.Content(""); // Avoid self-closing tag. xChoiceOut.EndElement(); } } if (!this->PostFlightComponent.Name.empty()) { xChoiceOut.StartElement("line"); - xChoiceOut.Attribute("choice", PostFlightComponent.Name + "Choice"); + xChoiceOut.Attribute("choice", + cmStrCat(PostFlightComponent.Name, "Choice")); xChoiceOut.Content(""); // Avoid self-closing tag. xChoiceOut.EndElement(); } @@ -207,14 +207,14 @@ void cmCPackPKGGenerator::CreateChoiceOutline( const cmCPackComponentGroup& group, cmXMLWriter& xout) { xout.StartElement("line"); - xout.Attribute("choice", group.Name + "Choice"); + xout.Attribute("choice", cmStrCat(group.Name, "Choice")); for (cmCPackComponentGroup* subgroup : group.Subgroups) { CreateChoiceOutline(*subgroup, xout); } for (cmCPackComponent* comp : group.Components) { xout.StartElement("line"); - xout.Attribute("choice", comp->Name + "Choice"); + xout.Attribute("choice", cmStrCat(comp->Name, "Choice")); xout.Content(""); // Avoid self-closing tag. xout.EndElement(); } @@ -225,7 +225,7 @@ void cmCPackPKGGenerator::CreateChoice(const cmCPackComponentGroup& group, cmXMLWriter& xout) { xout.StartElement("choice"); - xout.Attribute("id", group.Name + "Choice"); + xout.Attribute("id", cmStrCat(group.Name, "Choice")); xout.Attribute("title", group.DisplayName); xout.Attribute("start_selected", "true"); xout.Attribute("start_enabled", "true"); @@ -249,7 +249,7 @@ void cmCPackPKGGenerator::CreateChoice(const cmCPackComponent& component, } xout.StartElement("choice"); - xout.Attribute("id", component.Name + "Choice"); + xout.Attribute("id", cmStrCat(component.Name, "Choice")); xout.Attribute("title", component.DisplayName); xout.Attribute( "start_selected", @@ -381,7 +381,7 @@ bool cmCPackPKGGenerator::CopyCreateResourceFile(const std::string& name, const std::string& dirName) { std::string uname = cmSystemTools::UpperCase(name); - std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname; + std::string cpackVar = cmStrCat("CPACK_RESOURCE_FILE_", uname); cmValue inFileName = this->GetOption(cpackVar); if (!inFileName) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -413,7 +413,8 @@ bool cmCPackPKGGenerator::CopyCreateResourceFile(const std::string& name, // Set this so that distribution.dist gets the right name (without // the path). - this->SetOption("CPACK_RESOURCE_FILE_" + uname + "_NOPATH", (name + ext)); + this->SetOption(cmStrCat("CPACK_RESOURCE_FILE_", uname, "_NOPATH"), + cmStrCat(name, ext)); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << (inFileName ? *inFileName : "(NULL)") diff --git a/Source/CPack/cmCPackProductBuildGenerator.cxx b/Source/CPack/cmCPackProductBuildGenerator.cxx index 4ad616d..843219d 100644 --- a/Source/CPack/cmCPackProductBuildGenerator.cxx +++ b/Source/CPack/cmCPackProductBuildGenerator.cxx @@ -58,7 +58,7 @@ int cmCPackProductBuildGenerator::PackageFiles() } } - std::string resDir = packageDirFileName + "/Contents"; + std::string resDir = cmStrCat(packageDirFileName, "/Contents"); if (this->IsSet("CPACK_PRODUCTBUILD_RESOURCES_DIR")) { std::string userResDir = @@ -106,10 +106,14 @@ int cmCPackProductBuildGenerator::PackageFiles() << "\"" << " --resources \"" << resDir << "\"" << " --version \"" << version << "\"" - << (identifier.empty() ? "" : " --identifier \"" + identifier + "\"") - << (identityName.empty() ? "" : " --sign \"" + identityName + "\"") - << (keychainPath.empty() ? "" - : " --keychain \"" + keychainPath + "\"") + << (identifier.empty() + ? std::string{} + : cmStrCat(" --identifier \"", identifier, '"')) + << (identityName.empty() ? std::string{} + : cmStrCat(" --sign \"", identityName, '"')) + << (keychainPath.empty() + ? std::string{} + : cmStrCat(" --keychain \"", keychainPath, '"')) << " \"" << packageFileNames[0] << "\""; // Run ProductBuild @@ -187,7 +191,7 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage( resDir += "/"; resDir += component->Name; } - std::string scriptDir = resDir + "/scripts"; + std::string scriptDir = cmStrCat(resDir, "/scripts"); if (!cmsys::SystemTools::MakeDirectory(scriptDir.c_str())) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -237,9 +241,11 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage( << " --scripts \"" << scriptDir << "\"" << " --version \"" << version << "\"" << " --install-location \"/\"" - << (identityName.empty() ? "" : " --sign \"" + identityName + "\"") - << (keychainPath.empty() ? "" - : " --keychain \"" + keychainPath + "\"") + << (identityName.empty() ? std::string{} + : cmStrCat(" --sign \"", identityName, "\"")) + << (keychainPath.empty() + ? std::string{} + : cmStrCat(" --keychain \"", keychainPath, "\"")) << " \"" << packageFile << "\""; if (component && !component->Plist.empty()) { @@ -253,7 +259,7 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage( cmValue cmCPackProductBuildGenerator::GetComponentScript( const char* script, const char* component_name) { - std::string scriptname = std::string("CPACK_") + script + "_"; + std::string scriptname = cmStrCat("CPACK_", script, "_"); if (component_name) { scriptname += cmSystemTools::UpperCase(component_name); scriptname += "_"; |