From 241304190ffdf9cc7d4ede0601da370b111468cc Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Tue, 25 Apr 2023 19:54:23 +0200 Subject: CMake code rely on cmList class for CMake lists management (part. 2) --- Source/CPack/IFW/cmCPackIFWInstaller.cxx | 1 + Source/CPack/IFW/cmCPackIFWPackage.cxx | 8 ++++---- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 8 ++++---- Source/CPack/WiX/cmWIXAccessControlList.cxx | 5 ++--- Source/CPack/WiX/cmWIXShortcut.cxx | 5 ++--- Source/CPack/cmCPackDragNDropGenerator.cxx | 6 +++--- Source/CPack/cmCPackExternalGenerator.cxx | 4 ++-- Source/CPack/cmCPackGenerator.cxx | 25 ++++++++++++------------- Source/CPack/cmCPackNSISGenerator.cxx | 14 ++++++-------- 9 files changed, 36 insertions(+), 40 deletions(-) (limited to 'Source/CPack') diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index 69440d9748..a77c22fa81 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -12,6 +12,7 @@ #include "cmCPackIFWRepository.h" #include "cmCPackLog.h" // IWYU pragma: keep #include "cmGeneratedFileStream.h" +#include "cmList.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmValue.h" diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index b759eff46e..083f1ef7b1 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -428,16 +428,16 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix) } // QtIFW dependencies - std::vector deps; + cmList deps; option = prefix + "DEPENDS"; if (cmValue value = this->GetOption(option)) { - cmExpandList(value, deps); + deps.assign(value); } option = prefix + "DEPENDENCIES"; if (cmValue value = this->GetOption(option)) { - cmExpandList(value, deps); + deps.append(value); } - for (std::string const& d : deps) { + for (auto const& d : deps) { DependenceStruct dep(d); if (this->Generator->Packages.count(dep.Name)) { cmCPackIFWPackage& depPkg = this->Generator->Packages[dep.Name]; diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 1ce346f48e..1ea78fdc3d 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -681,10 +681,10 @@ bool cmCPackWIXGenerator::AddComponentsToFeature( featureDefinitions.BeginElement("FeatureRef"); featureDefinitions.AddAttribute("Id", featureId); - std::vector cpackPackageExecutablesList; + cmList cpackPackageExecutablesList; cmValue cpackPackageExecutables = GetOption("CPACK_PACKAGE_EXECUTABLES"); if (cpackPackageExecutables) { - cmExpandList(cpackPackageExecutables, cpackPackageExecutablesList); + cpackPackageExecutablesList.assign(cpackPackageExecutables); if (cpackPackageExecutablesList.size() % 2 != 0) { cmCPackLogger( cmCPackLog::LOG_ERROR, @@ -695,10 +695,10 @@ bool cmCPackWIXGenerator::AddComponentsToFeature( } } - std::vector cpackPackageDesktopLinksList; + cmList cpackPackageDesktopLinksList; cmValue cpackPackageDesktopLinks = GetOption("CPACK_CREATE_DESKTOP_LINKS"); if (cpackPackageDesktopLinks) { - cmExpandList(cpackPackageDesktopLinks, cpackPackageDesktopLinksList); + cpackPackageDesktopLinksList.assign(cpackPackageDesktopLinks); } AddDirectoryAndFileDefinitions( diff --git a/Source/CPack/WiX/cmWIXAccessControlList.cxx b/Source/CPack/WiX/cmWIXAccessControlList.cxx index 9685a7f495..2261a66e0f 100644 --- a/Source/CPack/WiX/cmWIXAccessControlList.cxx +++ b/Source/CPack/WiX/cmWIXAccessControlList.cxx @@ -19,10 +19,9 @@ cmWIXAccessControlList::cmWIXAccessControlList( bool cmWIXAccessControlList::Apply() { - std::vector entries; - this->InstalledFile.GetPropertyAsList("CPACK_WIX_ACL", entries); + auto entries = this->InstalledFile.GetPropertyAsList("CPACK_WIX_ACL"); - for (std::string const& entry : entries) { + for (auto const& entry : entries) { this->CreatePermissionElement(entry); } diff --git a/Source/CPack/WiX/cmWIXShortcut.cxx b/Source/CPack/WiX/cmWIXShortcut.cxx index cd1988a1cb..c3eb219a9d 100644 --- a/Source/CPack/WiX/cmWIXShortcut.cxx +++ b/Source/CPack/WiX/cmWIXShortcut.cxx @@ -91,10 +91,9 @@ void cmWIXShortcuts::CreateFromProperty(std::string const& propertyName, std::string const& directoryId, cmInstalledFile const& installedFile) { - std::vector list; - installedFile.GetPropertyAsList(propertyName, list); + auto list = installedFile.GetPropertyAsList(propertyName); - for (std::string const& label : list) { + for (auto const& label : list) { cmWIXShortcut shortcut; shortcut.label = label; shortcut.workingDirectoryId = directoryId; diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 2a0409db0d..768bfbe08d 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -543,9 +543,9 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, std::string sla_xml = cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/sla.xml"); - std::vector languages; + cmList languages; if (!oldStyle) { - cmExpandList(cpack_dmg_languages, languages); + languages.assign(cpack_dmg_languages); } std::vector header_data; @@ -574,7 +574,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, header_data.push_back(0); header_data.push_back(languages.size()); - for (size_t i = 0; i < languages.size(); ++i) { + for (cmList::size_type i = 0; i < languages.size(); ++i) { CFStringRef language_cfstring = CFStringCreateWithCString( nullptr, languages[i].c_str(), kCFStringEncodingUTF8); CFStringRef iso_language = diff --git a/Source/CPack/cmCPackExternalGenerator.cxx b/Source/CPack/cmCPackExternalGenerator.cxx index 4c92592d03..8ba015c8a6 100644 --- a/Source/CPack/cmCPackExternalGenerator.cxx +++ b/Source/CPack/cmCPackExternalGenerator.cxx @@ -15,8 +15,8 @@ #include "cmCPackComponentGroup.h" #include "cmCPackLog.h" +#include "cmList.h" #include "cmMakefile.h" -#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmValue.h" @@ -79,7 +79,7 @@ int cmCPackExternalGenerator::PackageFiles() cmValue builtPackages = this->GetOption("CPACK_EXTERNAL_BUILT_PACKAGES"); if (builtPackages) { - cmExpandList(builtPackages, this->packageFileNames, false); + cmExpandList(builtPackages, this->packageFileNames); } } diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 83194a695f..afd85cda75 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -573,7 +573,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( ++it; project.SubDirectory = *it; - std::vector componentsVector; + cmList componentsList; bool componentInstall = false; /* @@ -588,7 +588,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( std::string installTypesVar = "CPACK_" + cmSystemTools::UpperCase(project.Component) + "_INSTALL_TYPES"; cmValue installTypes = this->GetOption(installTypesVar); - if (cmNonempty(installTypes)) { + if (!installTypes.IsEmpty()) { cmList installTypesList{ installTypes }; for (std::string const& installType : installTypesList) { project.InstallationTypes.push_back( @@ -600,23 +600,23 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( std::string componentsVar = "CPACK_COMPONENTS_" + cmSystemTools::UpperCase(project.Component); cmValue components = this->GetOption(componentsVar); - if (cmNonempty(components)) { - cmExpandList(components, componentsVector); - for (std::string const& comp : componentsVector) { + if (!components.IsEmpty()) { + componentsList.assign(components); + for (auto const& comp : componentsList) { project.Components.push_back( this->GetComponent(project.ProjectName, comp)); } componentInstall = true; } } - if (componentsVector.empty()) { - componentsVector.push_back(project.Component); + if (componentsList.empty()) { + componentsList.push_back(project.Component); } - std::vector buildConfigs; + cmList buildConfigs; // Try get configuration names given via `-C` CLI option - cmExpandList(this->GetOption("CPACK_BUILD_CONFIG"), buildConfigs); + buildConfigs.assign(this->GetOption("CPACK_BUILD_CONFIG")); // Remove duplicates std::sort(buildConfigs.begin(), buildConfigs.end()); @@ -655,7 +655,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( << buildConfig << ']' << std::endl); // Run the installation for each component - for (std::string const& component : componentsVector) { + for (std::string const& component : componentsList) { if (!this->InstallCMakeProject( setDestDir, project.Directory, baseTempInstallDirectory, default_dir_mode, component, componentInstall, @@ -888,9 +888,8 @@ int cmCPackGenerator::InstallCMakeProject( mf.AddDefinition("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION", "1"); } - std::vector custom_variables; - this->MakefileMap->GetDefExpandList("CPACK_CUSTOM_INSTALL_VARIABLES", - custom_variables); + cmList custom_variables{ this->MakefileMap->GetDefinition( + "CPACK_CUSTOM_INSTALL_VARIABLES") }; for (auto const& custom_variable : custom_variables) { std::string value; diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 38a9d59f2c..7749b29303 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -246,8 +246,7 @@ int cmCPackNSISGenerator::PackageFiles() std::string nsisPreArguments; if (cmValue nsisArguments = this->GetOption("CPACK_NSIS_EXECUTABLE_PRE_ARGUMENTS")) { - std::vector expandedArguments; - cmExpandList(nsisArguments, expandedArguments); + cmList expandedArguments{ nsisArguments }; for (auto& arg : expandedArguments) { if (!cmHasPrefix(arg, NSIS_OPT)) { @@ -260,8 +259,7 @@ int cmCPackNSISGenerator::PackageFiles() std::string nsisPostArguments; if (cmValue nsisArguments = this->GetOption("CPACK_NSIS_EXECUTABLE_POST_ARGUMENTS")) { - std::vector expandedArguments; - cmExpandList(nsisArguments, expandedArguments); + cmList expandedArguments{ nsisArguments }; for (auto& arg : expandedArguments) { if (!cmHasPrefix(arg, NSIS_OPT)) { nsisPostArguments = cmStrCat(nsisPostArguments, NSIS_OPT); @@ -546,14 +544,14 @@ int cmCPackNSISGenerator::InitializeInternal() this->GetOption("CPACK_CREATE_DESKTOP_LINKS"); cmValue cpackNsisExecutablesDirectory = this->GetOption("CPACK_NSIS_EXECUTABLES_DIRECTORY"); - std::vector cpackPackageDesktopLinksVector; + cmList cpackPackageDesktopLinksList; if (cpackPackageDeskTopLinks) { cmCPackLogger(cmCPackLog::LOG_DEBUG, "CPACK_CREATE_DESKTOP_LINKS: " << cpackPackageDeskTopLinks << std::endl); - cmExpandList(cpackPackageDeskTopLinks, cpackPackageDesktopLinksVector); - for (std::string const& cpdl : cpackPackageDesktopLinksVector) { + cpackPackageDesktopLinksList.assign(cpackPackageDeskTopLinks); + for (std::string const& cpdl : cpackPackageDesktopLinksList) { cmCPackLogger(cmCPackLog::LOG_DEBUG, "CPACK_CREATE_DESKTOP_LINKS: " << cpdl << std::endl); } @@ -592,7 +590,7 @@ int cmCPackNSISGenerator::InitializeInternal() << ".lnk\"" << std::endl; // see if CPACK_CREATE_DESKTOP_LINK_ExeName is on // if so add a desktop link - if (cm::contains(cpackPackageDesktopLinksVector, execName)) { + if (cm::contains(cpackPackageDesktopLinksList, execName)) { str << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n"; str << " CreateShortCut \"$DESKTOP\\" << linkName << R"(.lnk" "$INSTDIR\)" << cpackNsisExecutablesDirectory << "\\" -- cgit v1.2.1