diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2023-04-25 17:54:23 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2023-04-29 07:54:31 (GMT) |
commit | 241304190ffdf9cc7d4ede0601da370b111468cc (patch) | |
tree | e35dd7fe5c89da1eed3abe10f37abe3586e64df7 | |
parent | 87fe031a0703f07b8636f8ea59b6746788e71869 (diff) | |
download | CMake-241304190ffdf9cc7d4ede0601da370b111468cc.zip CMake-241304190ffdf9cc7d4ede0601da370b111468cc.tar.gz CMake-241304190ffdf9cc7d4ede0601da370b111468cc.tar.bz2 |
CMake code rely on cmList class for CMake lists management (part. 2)
60 files changed, 398 insertions, 497 deletions
diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index 69440d9..a77c22f 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 b759eff..083f1ef 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<std::string> 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 1ce346f..1ea78fd 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<std::string> 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<std::string> 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 9685a7f..2261a66 100644 --- a/Source/CPack/WiX/cmWIXAccessControlList.cxx +++ b/Source/CPack/WiX/cmWIXAccessControlList.cxx @@ -19,10 +19,9 @@ cmWIXAccessControlList::cmWIXAccessControlList( bool cmWIXAccessControlList::Apply() { - std::vector<std::string> 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 cd1988a..c3eb219 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<std::string> 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 2a0409d..768bfbe 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<std::string> languages; + cmList languages; if (!oldStyle) { - cmExpandList(cpack_dmg_languages, languages); + languages.assign(cpack_dmg_languages); } std::vector<uint16_t> 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 4c92592..8ba015c 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 83194a6..afd85cd 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -573,7 +573,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( ++it; project.SubDirectory = *it; - std::vector<std::string> 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<std::string> 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<std::string> 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 38a9d59..7749b29 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<std::string> 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<std::string> 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<std::string> 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 << "\\" diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index c6387ab..882b579 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -17,6 +17,7 @@ #include "cmDuration.h" #include "cmFileTimeCache.h" #include "cmGeneratedFileStream.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmProcessOutput.h" #include "cmStringAlgorithms.h" diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index 1f3633d..bae1f54 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -4,13 +4,13 @@ #include <cstring> #include <sstream> -#include <vector> #include <cmext/string_view> #include "cmCTest.h" #include "cmCTestConfigureHandler.h" #include "cmGlobalGenerator.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -25,10 +25,10 @@ void cmCTestConfigureCommand::BindArguments() cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() { - std::vector<std::string> options; + cmList options; if (!this->Options.empty()) { - cmExpandList(this->Options, options); + options.assign(this->Options); } if (this->CTest->GetCTestConfiguration("BuildDirectory").empty()) { diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 3adf33e..3a1cb64 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -2204,9 +2204,8 @@ bool cmCTestTestHandler::SetTestsProperties( for (cmCTestTestProperties& rt : this->TestList) { if (t == rt.Name) { if (key == "_BACKTRACE_TRIPLES"_s) { - std::vector<std::string> triples; // allow empty args in the triples - cmExpandList(val, triples, true); + cmList triples{ val, cmList::EmptyElements::Yes }; // Ensure we have complete triples otherwise the data is corrupt. if (triples.size() % 3 == 0) { @@ -2215,7 +2214,7 @@ bool cmCTestTestHandler::SetTestsProperties( // the first entry represents the top of the trace so we need to // reconstruct the backtrace in reverse - for (size_t i = triples.size(); i >= 3; i -= 3) { + for (auto i = triples.size(); i >= 3; i -= 3) { cmListFileContext fc; fc.FilePath = triples[i - 3]; long line = 0; diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx index 58129a0..8bfd7c8 100644 --- a/Source/cmCMakeHostSystemInformationCommand.cxx +++ b/Source/cmCMakeHostSystemInformationCommand.cxx @@ -21,10 +21,12 @@ #include "cmArgumentParser.h" #include "cmExecutionStatus.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmRange.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" +#include "cmValue.h" #include "cmWindowsRegistry.h" #ifdef _WIN32 @@ -303,7 +305,8 @@ std::map<std::string, std::string> GetOSReleaseVariables( } // 2. User provided (append to the CMake prvided) - makefile.GetDefExpandList("CMAKE_GET_OS_RELEASE_FALLBACK_SCRIPTS", scripts); + cmList::append( + scripts, makefile.GetDefinition("CMAKE_GET_OS_RELEASE_FALLBACK_SCRIPTS")); // Filter out files that are not in format `NNN-name.cmake` auto checkName = [](std::string const& filepath) -> bool { @@ -330,11 +333,11 @@ std::map<std::string, std::string> GetOSReleaseVariables( }); // Name of the variable to put the results - auto const result_variable = "CMAKE_GET_OS_RELEASE_FALLBACK_RESULT"_s; + std::string const result_variable{ "CMAKE_GET_OS_RELEASE_FALLBACK_RESULT" }; for (auto const& script : scripts) { // Unset the result variable - makefile.RemoveDefinition(result_variable.data()); + makefile.RemoveDefinition(result_variable); // include FATAL_ERROR and ERROR in the return status if (!makefile.ReadListFile(script) || @@ -343,8 +346,8 @@ std::map<std::string, std::string> GetOSReleaseVariables( continue; } - std::vector<std::string> variables; - if (!makefile.GetDefExpandList(result_variable.data(), variables)) { + cmList variables{ makefile.GetDefinition(result_variable) }; + if (variables.empty()) { // Heh, this script didn't found anything... go try the next one. continue; } @@ -370,7 +373,7 @@ std::map<std::string, std::string> GetOSReleaseVariables( } } - makefile.RemoveDefinition(result_variable.data()); + makefile.RemoveDefinition(result_variable); return data; } diff --git a/Source/cmCMakePathCommand.cxx b/Source/cmCMakePathCommand.cxx index 7755082..0c8f537 100644 --- a/Source/cmCMakePathCommand.cxx +++ b/Source/cmCMakePathCommand.cxx @@ -18,6 +18,7 @@ #include "cmArgumentParserTypes.h" #include "cmCMakePath.h" #include "cmExecutionStatus.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmRange.h" #include "cmStringAlgorithms.h" @@ -626,12 +627,12 @@ bool HandleConvertCommand(std::vector<std::string> const& args, return false; } - std::vector<std::string> paths; + cmList paths; if (action == cmakePath) { paths = cmSystemTools::SplitString(args[1], pathSep.front()); } else { - cmExpandList(args[1], paths); + paths.assign(args[1]); } for (auto& path : paths) { @@ -648,7 +649,7 @@ bool HandleConvertCommand(std::vector<std::string> const& args, } } - auto value = cmJoin(paths, action == cmakePath ? ";"_s : pathSep); + auto value = action == cmakePath ? paths.to_string() : paths.join(pathSep); status.GetMakefile().AddDefinition(args[3], value); return true; diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index c763cc6..a311041 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -3099,8 +3099,7 @@ void cmCTest::PopulateCustomVector(cmMakefile* mf, const std::string& def, } cmCTestLog(this, DEBUG, "PopulateCustomVector: " << def << std::endl); - vec.clear(); - cmExpandList(*dval, vec); + cmList::assign(vec, *dval); for (std::string const& it : vec) { cmCTestLog(this, DEBUG, " -- " << it << std::endl); diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 6a5b4cc..5d44a6a 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1917,19 +1917,18 @@ void cmComputeLinkInformation::DropDirectoryItem(BT<std::string> const& item) void cmComputeLinkInformation::ComputeFrameworkInfo() { // Avoid adding implicit framework paths. - std::vector<std::string> implicitDirVec; + cmList implicitDirs; // Get platform-wide implicit directories. - this->Makefile->GetDefExpandList( - "CMAKE_PLATFORM_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES", implicitDirVec); + implicitDirs.assign(this->Makefile->GetDefinition( + "CMAKE_PLATFORM_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES")); // Get language-specific implicit directories. std::string implicitDirVar = cmStrCat( "CMAKE_", this->LinkLanguage, "_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES"); - this->Makefile->GetDefExpandList(implicitDirVar, implicitDirVec); + implicitDirs.append(this->Makefile->GetDefinition(implicitDirVar)); - this->FrameworkPathsEmitted.insert(implicitDirVec.begin(), - implicitDirVec.end()); + this->FrameworkPathsEmitted.insert(implicitDirs.begin(), implicitDirs.end()); } void cmComputeLinkInformation::AddFrameworkPath(std::string const& p) @@ -2139,17 +2138,15 @@ void cmComputeLinkInformation::PrintLinkPolicyDiagnosis(std::ostream& os) void cmComputeLinkInformation::LoadImplicitLinkInfo() { - std::vector<std::string> implicitDirVec; - // Get platform-wide implicit directories. - this->Makefile->GetDefExpandList("CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES", - implicitDirVec); + cmList implicitDirs{ this->Makefile->GetDefinition( + "CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES") }; // Append library architecture to all implicit platform directories // and add them to the set if (cmValue libraryArch = this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE")) { - for (std::string const& i : implicitDirVec) { + for (auto const& i : implicitDirs) { this->ImplicitLinkDirs.insert(cmStrCat(i, '/', *libraryArch)); } } @@ -2157,19 +2154,18 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo() // Get language-specific implicit directories. std::string implicitDirVar = cmStrCat("CMAKE_", this->LinkLanguage, "_IMPLICIT_LINK_DIRECTORIES"); - this->Makefile->GetDefExpandList(implicitDirVar, implicitDirVec); + implicitDirs.append(this->Makefile->GetDefinition(implicitDirVar)); // Store implicit link directories. - this->ImplicitLinkDirs.insert(implicitDirVec.begin(), implicitDirVec.end()); + this->ImplicitLinkDirs.insert(implicitDirs.begin(), implicitDirs.end()); // Get language-specific implicit libraries. - std::vector<std::string> implicitLibVec; std::string implicitLibVar = cmStrCat("CMAKE_", this->LinkLanguage, "_IMPLICIT_LINK_LIBRARIES"); - this->Makefile->GetDefExpandList(implicitLibVar, implicitLibVec); + cmList implicitLibs{ this->Makefile->GetDefinition(implicitLibVar) }; // Store implicit link libraries. - for (std::string const& item : implicitLibVec) { + for (auto const& item : implicitLibs) { // Items starting in '-' but not '-l' are flags, not libraries, // and should not be filtered by this implicit list. if (item[0] != '-' || item[1] == 'l') { @@ -2178,8 +2174,8 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo() } // Get platform specific rpath link directories - this->Makefile->GetDefExpandList("CMAKE_PLATFORM_RUNTIME_PATH", - this->RuntimeLinkDirs); + cmList::append(this->RuntimeLinkDirs, + this->Makefile->GetDefinition("CMAKE_PLATFORM_RUNTIME_PATH")); } std::vector<std::string> const& diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 02ee9e2..7d4ab50 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -126,7 +126,7 @@ ArgumentParser::Continue TryCompileLangProp(Arguments& args, ArgumentParser::Continue TryCompileCompileDefs(Arguments& args, cm::string_view val) { - cmExpandList(val, args.CompileDefs); + args.CompileDefs.append(val); return ArgumentParser::Continue::Yes; } @@ -789,7 +789,7 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode( if (!arguments.CompileDefs.empty()) { // Pass using bracket arguments to preserve content. fprintf(fout, "add_definitions([==[%s]==])\n", - cmJoin(arguments.CompileDefs, "]==] [==[").c_str()); + arguments.CompileDefs.join("]==] [==[").c_str()); } if (!targets.empty()) { diff --git a/Source/cmCoreTryCompile.h b/Source/cmCoreTryCompile.h index ba38c19..c185c68 100644 --- a/Source/cmCoreTryCompile.h +++ b/Source/cmCoreTryCompile.h @@ -12,6 +12,7 @@ #include "cmArgumentParser.h" #include "cmArgumentParserTypes.h" +#include "cmList.h" #include "cmStateTypes.h" class cmConfigureLog; @@ -65,7 +66,7 @@ public: ArgumentParser::MaybeEmpty<std::vector<std::string>> CMakeFlags{ 1, "CMAKE_FLAGS" }; // fake argv[0] - std::vector<std::string> CompileDefs; + cmList CompileDefs; cm::optional<ArgumentParser::MaybeEmpty<std::vector<std::string>>> LinkLibraries; ArgumentParser::MaybeEmpty<std::vector<std::string>> LinkOptions; diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx index eca1abd..04bccce 100644 --- a/Source/cmDepends.cxx +++ b/Source/cmDepends.cxx @@ -9,6 +9,7 @@ #include "cmFileTime.h" #include "cmFileTimeCache.h" #include "cmGeneratedFileStream.h" +#include "cmList.h" #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" #include "cmStringAlgorithms.h" @@ -28,11 +29,11 @@ bool cmDepends::Write(std::ostream& makeDepends, std::ostream& internalDepends) std::map<std::string, std::set<std::string>> dependencies; { // Lookup the set of sources to scan. - std::vector<std::string> pairs; + cmList pairs; { std::string const srcLang = "CMAKE_DEPENDS_CHECK_" + this->Language; cmMakefile* mf = this->LocalGenerator->GetMakefile(); - cmExpandList(mf->GetSafeDefinition(srcLang), pairs); + pairs.assign(mf->GetSafeDefinition(srcLang)); } for (auto si = pairs.begin(); si != pairs.end();) { // Get the source and object file. diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 2527809..408a85b 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -8,6 +8,7 @@ #include "cmFileTime.h" #include "cmGlobalUnixMakefileGenerator3.h" +#include "cmList.h" #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" #include "cmStringAlgorithms.h" @@ -393,10 +394,10 @@ void cmDependsC::Scan(std::istream& is, const std::string& directory, void cmDependsC::SetupTransforms() { // Get the transformation rules. - std::vector<std::string> transformRules; cmMakefile* mf = this->LocalGenerator->GetMakefile(); - mf->GetDefExpandList("CMAKE_INCLUDE_TRANSFORMS", transformRules, true); - for (std::string const& tr : transformRules) { + cmList transformRules{ mf->GetDefinition("CMAKE_INCLUDE_TRANSFORMS"), + cmList::EmptyElements::Yes }; + for (auto const& tr : transformRules) { this->ParseTransform(tr); } diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 718097f..aede3fe 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -13,6 +13,7 @@ #include "cmFortranParser.h" /* Interface to parser object. */ #include "cmGeneratedFileStream.h" #include "cmGlobalUnixMakefileGenerator3.h" +#include "cmList.h" #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" #include "cmOutputConverter.h" @@ -78,9 +79,8 @@ cmDependsFortran::cmDependsFortran(cmLocalUnixMakefileGenerator3* lg) this->SetIncludePathFromLanguage("Fortran"); // Get the list of definitions. - std::vector<std::string> definitions; cmMakefile* mf = this->LocalGenerator->GetMakefile(); - mf->GetDefExpandList("CMAKE_TARGET_DEFINITIONS_Fortran", definitions); + cmList definitions{ mf->GetDefinition("CMAKE_TARGET_DEFINITIONS_Fortran") }; // translate i.e. FOO=BAR to FOO and add it to the list of defined // preprocessor symbols @@ -244,9 +244,9 @@ bool cmDependsFortran::LocateModules() // Load information about other targets. cmMakefile* mf = this->LocalGenerator->GetMakefile(); - std::vector<std::string> infoFiles; - mf->GetDefExpandList("CMAKE_Fortran_TARGET_LINKED_INFO_FILES", infoFiles); - for (std::string const& i : infoFiles) { + cmList infoFiles{ mf->GetDefinition( + "CMAKE_Fortran_TARGET_LINKED_INFO_FILES") }; + for (auto const& i : infoFiles) { std::string targetDir = cmSystemTools::GetFilenamePath(i); std::string fname = targetDir + "/fortran.internal"; cmsys::ifstream fin(fname.c_str()); diff --git a/Source/cmEvaluatedTargetProperty.cxx b/Source/cmEvaluatedTargetProperty.cxx index 1173690..b82c29b 100644 --- a/Source/cmEvaluatedTargetProperty.cxx +++ b/Source/cmEvaluatedTargetProperty.cxx @@ -8,7 +8,7 @@ #include "cmGeneratorExpressionContext.h" #include "cmGeneratorTarget.h" #include "cmLinkItem.h" -#include "cmStringAlgorithms.h" +#include "cmList.h" struct cmGeneratorExpressionDAGChecker; diff --git a/Source/cmFileAPIToolchains.cxx b/Source/cmFileAPIToolchains.cxx index fe2972f..a51ae20 100644 --- a/Source/cmFileAPIToolchains.cxx +++ b/Source/cmFileAPIToolchains.cxx @@ -10,6 +10,7 @@ #include "cmFileAPI.h" #include "cmGlobalGenerator.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmState.h" #include "cmStringAlgorithms.h" @@ -124,10 +125,11 @@ void Toolchains::DumpToolchainVariable(cmMakefile const* mf, cmStrCat("CMAKE_", lang, "_", variable.VariableSuffix); if (variable.IsList) { - std::vector<std::string> values; - if (mf->GetDefExpandList(variableName, values)) { + cmValue data = mf->GetDefinition(variableName); + if (data) { + cmList values(data); Json::Value jsonArray = Json::arrayValue; - for (std::string const& value : values) { + for (auto const& value : values) { jsonArray.append(value); } object[variable.ObjectKey] = jsonArray; diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index c3fb907..bec6369 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -9,6 +9,7 @@ #include <cmext/algorithm> #include "cmExecutionStatus.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmPolicies.h" @@ -238,9 +239,9 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) } // Construct the list of path roots with no trailing slashes. - std::vector<std::string> roots; + cmList roots; if (rootPath) { - cmExpandList(*rootPath, roots); + roots.assign(*rootPath); } if (sysrootCompile) { roots.emplace_back(*sysrootCompile); @@ -251,14 +252,14 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) if (sysroot) { roots.emplace_back(*sysroot); } - for (std::string& r : roots) { + for (auto& r : roots) { cmSystemTools::ConvertToUnixSlashes(r); } cmValue stagePrefix = this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX"); // Copy the original set of unrooted paths. - std::vector<std::string> unrootedPaths = paths; + auto unrootedPaths = paths; paths.clear(); auto isSameDirectoryOrSubDirectory = [](std::string const& l, @@ -267,8 +268,8 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) cmSystemTools::IsSubDirectory(l, r); }; - for (std::string const& r : roots) { - for (std::string const& up : unrootedPaths) { + for (auto const& r : roots) { + for (auto const& up : unrootedPaths) { // Place the unrooted path under the current root if it is not // already inside. Skip the unrooted path if it is relative to // a user home directory or is empty. @@ -308,7 +309,7 @@ void cmFindCommon::GetIgnoredPaths(std::vector<std::string>& ignore) // Construct the list of path roots with no trailing slashes. for (const char* pathName : paths) { // Get the list of paths to ignore from the variable. - this->Makefile->GetDefExpandList(pathName, ignore); + cmList::append(ignore, this->Makefile->GetDefinition(pathName)); } for (std::string& i : ignore) { @@ -333,7 +334,7 @@ void cmFindCommon::GetIgnoredPrefixPaths(std::vector<std::string>& ignore) // Construct the list of path roots with no trailing slashes. for (const char* pathName : paths) { // Get the list of paths to ignore from the variable. - this->Makefile->GetDefExpandList(pathName, ignore); + cmList::append(ignore, this->Makefile->GetDefinition(pathName)); } for (std::string& i : ignore) { diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 6296a60..9eb0603 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -11,6 +11,7 @@ #include "cmsys/RegularExpression.hxx" #include "cmGlobalGenerator.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmState.h" #include "cmStateTypes.h" @@ -196,8 +197,8 @@ struct cmFindLibraryHelper cmGlobalGenerator* GG; // List of valid prefixes and suffixes. - std::vector<std::string> Prefixes; - std::vector<std::string> Suffixes; + cmList Prefixes; + cmList Suffixes; std::string PrefixRegexStr; std::string SuffixRegexStr; @@ -223,7 +224,7 @@ struct cmFindLibraryHelper std::string TestPath; void RegexFromLiteral(std::string& out, std::string const& in); - void RegexFromList(std::string& out, std::vector<std::string> const& in); + void RegexFromList(std::string& out, cmList const& in); size_type GetPrefixIndex(std::string const& prefix) { return std::find(this->Prefixes.begin(), this->Prefixes.end(), prefix) - @@ -307,8 +308,8 @@ cmFindLibraryHelper::cmFindLibraryHelper(std::string debugName, cmMakefile* mf, std::string const& prefixes_list = get_prefixes(this->Makefile); std::string const& suffixes_list = get_suffixes(this->Makefile); - cmExpandList(prefixes_list, this->Prefixes, true); - cmExpandList(suffixes_list, this->Suffixes, true); + this->Prefixes.assign(prefixes_list, cmList::EmptyElements::Yes); + this->Suffixes.assign(suffixes_list, cmList::EmptyElements::Yes); this->RegexFromList(this->PrefixRegexStr, this->Prefixes); this->RegexFromList(this->SuffixRegexStr, this->Suffixes); @@ -334,14 +335,13 @@ void cmFindLibraryHelper::RegexFromLiteral(std::string& out, } } -void cmFindLibraryHelper::RegexFromList(std::string& out, - std::vector<std::string> const& in) +void cmFindLibraryHelper::RegexFromList(std::string& out, cmList const& in) { // Surround the list in parens so the '|' does not apply to anything // else and the result can be checked after matching. out += "("; const char* sep = ""; - for (std::string const& s : in) { + for (auto const& s : in) { // Separate from previous item. out += sep; sep = "|"; diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 656703c..98b085c 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -1782,28 +1782,20 @@ bool cmFindPackageCommand::ReadListFile(const std::string& f, void cmFindPackageCommand::AppendToFoundProperty(const bool found) { - std::vector<std::string> foundContents; + cmList foundContents; cmValue foundProp = this->Makefile->GetState()->GetGlobalProperty("PACKAGES_FOUND"); - if (cmNonempty(foundProp)) { - cmExpandList(*foundProp, foundContents, false); - auto nameIt = - std::find(foundContents.begin(), foundContents.end(), this->Name); - if (nameIt != foundContents.end()) { - foundContents.erase(nameIt); - } + if (!foundProp.IsEmpty()) { + foundContents.assign(*foundProp); + foundContents.remove_items({ this->Name }); } - std::vector<std::string> notFoundContents; + cmList notFoundContents; cmValue notFoundProp = this->Makefile->GetState()->GetGlobalProperty("PACKAGES_NOT_FOUND"); - if (cmNonempty(notFoundProp)) { - cmExpandList(*notFoundProp, notFoundContents, false); - auto nameIt = - std::find(notFoundContents.begin(), notFoundContents.end(), this->Name); - if (nameIt != notFoundContents.end()) { - notFoundContents.erase(nameIt); - } + if (!notFoundProp.IsEmpty()) { + notFoundContents.assign(*notFoundProp); + notFoundContents.remove_items({ this->Name }); } if (found) { @@ -1812,12 +1804,11 @@ void cmFindPackageCommand::AppendToFoundProperty(const bool found) notFoundContents.push_back(this->Name); } - std::string tmp = cmJoin(foundContents, ";"); - this->Makefile->GetState()->SetGlobalProperty("PACKAGES_FOUND", tmp.c_str()); + this->Makefile->GetState()->SetGlobalProperty( + "PACKAGES_FOUND", foundContents.to_string().c_str()); - tmp = cmJoin(notFoundContents, ";"); - this->Makefile->GetState()->SetGlobalProperty("PACKAGES_NOT_FOUND", - tmp.c_str()); + this->Makefile->GetState()->SetGlobalProperty( + "PACKAGES_NOT_FOUND", notFoundContents.to_string().c_str()); } void cmFindPackageCommand::AppendSuccessInformation() diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index 3465c23..21a140d 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -23,6 +23,7 @@ #include "cmExecutionStatus.h" #include "cmFunctionBlocker.h" +#include "cmList.h" #include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -156,16 +157,16 @@ bool cmForEachFunctionBlocker::ReplayZipLists( auto& mf = inStatus.GetMakefile(); // Expand the list of list-variables into a list of lists of strings - std::vector<std::vector<std::string>> values; + std::vector<cmList> values; values.reserve(this->Args.size() - this->IterationVarsCount); // Also track the longest list size std::size_t maxItems = 0u; for (auto const& var : cmMakeRange(this->Args).advance(this->IterationVarsCount)) { - std::vector<std::string> items; + cmList items; auto const& value = mf.GetSafeDefinition(var); if (!value.empty()) { - cmExpandList(value, items, true); + items.assign(value, cmList::EmptyElements::Yes); } maxItems = std::max(maxItems, items.size()); values.emplace_back(std::move(items)); @@ -344,7 +345,7 @@ bool HandleInMode(std::vector<std::string> const& args, } else if (doing == DoingLists) { auto const& value = makefile.GetSafeDefinition(arg); if (!value.empty()) { - cmExpandList(value, fb->Args, true); + cmExpandList(value, fb->Args, cmList::EmptyElements::Yes); } } else if (doing == DoingItems || doing == DoingZipLists) { diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index c5ae31b..04decd2 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -14,6 +14,7 @@ #include "cmGeneratorExpressionEvaluator.h" #include "cmGeneratorExpressionLexer.h" #include "cmGeneratorExpressionParser.h" +#include "cmList.h" #include "cmLocalGenerator.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index f774fdf..4f5a663 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -19,7 +19,6 @@ #include <cm/iterator> #include <cm/optional> #include <cm/string_view> -#include <cm/vector> #include <cmext/algorithm> #include <cmext/string_view> @@ -2146,11 +2145,11 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode // This imported target has an appropriate location // for this (possibly mapped) config. // Check if there is a proper config mapping for the tested config. - std::vector<std::string> mappedConfigs; + cmList mappedConfigs; std::string mapProp = cmStrCat( "MAP_IMPORTED_CONFIG_", cmSystemTools::UpperCase(context->Config)); if (cmValue mapValue = context->CurrentTarget->GetProperty(mapProp)) { - cmExpandList(cmSystemTools::UpperCase(*mapValue), mappedConfigs); + mappedConfigs.assign(cmSystemTools::UpperCase(*mapValue)); for (auto const& param : parameters) { if (cm::contains(mappedConfigs, cmSystemTools::UpperCase(param))) { @@ -2461,8 +2460,7 @@ static const struct LinkLibraryNode : public cmGeneratorExpressionNode return std::string(); } - std::vector<std::string> list; - cmExpandLists(parameters.begin(), parameters.end(), list); + cmList list{ parameters.begin(), parameters.end() }; if (list.empty()) { reportError( context, content->GetOriginalExpression(), @@ -2547,8 +2545,7 @@ static const struct LinkGroupNode : public cmGeneratorExpressionNode return std::string(); } - std::vector<std::string> list; - cmExpandLists(parameters.begin(), parameters.end(), list); + cmList list{ parameters.begin(), parameters.end() }; if (list.empty()) { reportError( context, content->GetOriginalExpression(), @@ -2638,8 +2635,7 @@ static const struct DeviceLinkNode : public cmGeneratorExpressionNode } if (context->HeadTarget->IsDeviceLink()) { - std::vector<std::string> list; - cmExpandLists(parameters.begin(), parameters.end(), list); + cmList list{ parameters.begin(), parameters.end() }; const auto DL_BEGIN = "<DEVICE_LINK>"_s; const auto DL_END = "</DEVICE_LINK>"_s; cm::erase_if(list, [&](const std::string& item) { @@ -3050,14 +3046,14 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode } } - std::vector<std::string> objects; + cmList objects; if (gt->IsImported()) { cmValue loc = nullptr; cmValue imp = nullptr; std::string suffix; if (gt->Target->GetMappedConfig(context->Config, loc, imp, suffix)) { - cmExpandList(*loc, objects); + objects.assign(*loc); } context->HadContextSensitiveCondition = true; } else { @@ -3075,7 +3071,7 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode context->HadContextSensitiveCondition = true; } - for (std::string& o : objects) { + for (auto& o : objects) { o = cmStrCat(obj_dir, o); } } @@ -3195,7 +3191,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode } context->HadHeadSensitiveCondition = true; - using LangMap = std::map<std::string, std::vector<std::string>>; + using LangMap = std::map<std::string, cmList>; static LangMap availableFeatures; LangMap testedFeatures; @@ -3217,7 +3213,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode reportError(context, content->GetOriginalExpression(), error); return std::string(); } - cmExpandList(featuresKnown, availableFeatures[lang]); + availableFeatures[lang].assign(featuresKnown); } } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index db3d7e6..1c37e52 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -747,14 +747,13 @@ void handleSystemIncludesDep(cmLocalGenerator* lg, const std::string& config, cmGeneratorTarget const* headTarget, cmGeneratorExpressionDAGChecker* dagChecker, - std::vector<std::string>& result, - bool excludeImported, std::string const& language) + cmList& result, bool excludeImported, + std::string const& language) { if (cmValue dirs = depTgt->GetProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")) { - cmExpandList(cmGeneratorExpression::Evaluate(*dirs, lg, config, headTarget, - dagChecker, depTgt, language), - result); + result.append(cmGeneratorExpression::Evaluate( + *dirs, lg, config, headTarget, dagChecker, depTgt, language)); } if (!depTgt->GetPropertyAsBool("SYSTEM")) { return; @@ -769,9 +768,8 @@ void handleSystemIncludesDep(cmLocalGenerator* lg, } if (cmValue dirs = depTgt->GetProperty("INTERFACE_INCLUDE_DIRECTORIES")) { - cmExpandList(cmGeneratorExpression::Evaluate(*dirs, lg, config, headTarget, - dagChecker, depTgt, language), - result); + result.append(cmGeneratorExpression::Evaluate( + *dirs, lg, config, headTarget, dagChecker, depTgt, language)); } } } @@ -1265,12 +1263,11 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory( bool excludeImported = this->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED"); - std::vector<std::string> result; + cmList result; for (std::string const& it : this->Target->GetSystemIncludeDirectories()) { - cmExpandList(cmGeneratorExpression::Evaluate(it, this->LocalGenerator, - config, this, &dagChecker, - nullptr, language), - result); + result.append(cmGeneratorExpression::Evaluate(it, this->LocalGenerator, + config, this, &dagChecker, + nullptr, language)); } std::vector<cmGeneratorTarget const*> const& deps = @@ -1753,10 +1750,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetSourceFilePaths( return files; } - std::vector<std::string> debugProperties; - this->Makefile->GetDefExpandList("CMAKE_DEBUG_TARGET_PROPERTIES", - debugProperties); - + cmList debugProperties{ this->Makefile->GetDefinition( + "CMAKE_DEBUG_TARGET_PROPERTIES") }; bool debugSources = !this->DebugSourcesDone && cm::contains(debugProperties, "SOURCES"); @@ -3300,9 +3295,9 @@ std::string cmGeneratorTarget::GetCompilePDBDirectory( std::vector<std::string> cmGeneratorTarget::GetAppleArchs( std::string const& config, cm::optional<std::string> lang) const { - std::vector<std::string> archVec; + cmList archList; if (!this->IsApple()) { - return archVec; + return std::move(archList.data()); } cmValue archs = nullptr; if (!config.empty()) { @@ -3314,17 +3309,18 @@ std::vector<std::string> cmGeneratorTarget::GetAppleArchs( archs = this->GetProperty("OSX_ARCHITECTURES"); } if (archs) { - cmExpandList(*archs, archVec); + archList.assign(*archs); } - if (archVec.empty() && + if (archList.empty() && // Fall back to a default architecture if no compiler target is set. (!lang || this->Makefile ->GetDefinition(cmStrCat("CMAKE_", *lang, "_COMPILER_TARGET")) .IsEmpty())) { - this->Makefile->GetDefExpandList("_CMAKE_APPLE_ARCHS_DEFAULT", archVec); + archList.assign( + this->Makefile->GetDefinition("_CMAKE_APPLE_ARCHS_DEFAULT")); } - return archVec; + return std::move(archList.data()); } void cmGeneratorTarget::AddExplicitLanguageFlags(std::string& flags, @@ -3433,10 +3429,9 @@ void cmGeneratorTarget::AddCUDAArchitectureFlags(cmBuildStep compileOrLink, std::vector<CudaArchitecture> architectures; { - std::vector<std::string> options; - cmExpandList(property, options); + cmList options(property); - for (std::string& option : options) { + for (auto& option : options) { CudaArchitecture architecture; // Architecture name is up to the first specifier. @@ -3527,8 +3522,7 @@ void cmGeneratorTarget::AddISPCTargetFlags(std::string& flags) const this->Makefile->GetSafeDefinition("CMAKE_ISPC_COMPILER_ID"); if (compiler == "Intel") { - std::vector<std::string> targets; - cmExpandList(property, targets); + cmList targets(property); if (!targets.empty()) { flags += cmStrCat(" --target=", cmWrap("", targets, "", ",")); } @@ -3550,8 +3544,7 @@ void cmGeneratorTarget::AddHIPArchitectureFlags(std::string& flags) const return; } - std::vector<std::string> options; - cmExpandList(property, options); + cmList options(property); for (std::string& option : options) { flags += " --offload-arch=" + option; @@ -3763,10 +3756,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetIncludeDirectories( cmGeneratorExpressionDAGChecker dagChecker(this, "INCLUDE_DIRECTORIES", nullptr, nullptr); - std::vector<std::string> debugProperties; - this->Makefile->GetDefExpandList("CMAKE_DEBUG_TARGET_PROPERTIES", - debugProperties); - + cmList debugProperties{ this->Makefile->GetDefinition( + "CMAKE_DEBUG_TARGET_PROPERTIES") }; bool debugIncludes = !this->DebugIncludesDone && cm::contains(debugProperties, "INCLUDE_DIRECTORIES"); @@ -4022,10 +4013,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileOptions( cmGeneratorExpressionDAGChecker dagChecker(this, "COMPILE_OPTIONS", nullptr, nullptr); - std::vector<std::string> debugProperties; - this->Makefile->GetDefExpandList("CMAKE_DEBUG_TARGET_PROPERTIES", - debugProperties); - + cmList debugProperties{ this->Makefile->GetDefinition( + "CMAKE_DEBUG_TARGET_PROPERTIES") }; bool debugOptions = !this->DebugCompileOptionsDone && cm::contains(debugProperties, "COMPILE_OPTIONS"); @@ -4065,10 +4054,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileFeatures( cmGeneratorExpressionDAGChecker dagChecker(this, "COMPILE_FEATURES", nullptr, nullptr); - std::vector<std::string> debugProperties; - this->Makefile->GetDefExpandList("CMAKE_DEBUG_TARGET_PROPERTIES", - debugProperties); - + cmList debugProperties{ this->Makefile->GetDefinition( + "CMAKE_DEBUG_TARGET_PROPERTIES") }; bool debugFeatures = !this->DebugCompileFeaturesDone && cm::contains(debugProperties, "COMPILE_FEATURES"); @@ -4117,10 +4104,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileDefinitions( cmGeneratorExpressionDAGChecker dagChecker(this, "COMPILE_DEFINITIONS", nullptr, nullptr); - std::vector<std::string> debugProperties; - this->Makefile->GetDefExpandList("CMAKE_DEBUG_TARGET_PROPERTIES", - debugProperties); - + cmList debugProperties{ this->Makefile->GetDefinition( + "CMAKE_DEBUG_TARGET_PROPERTIES") }; bool debugDefines = !this->DebugCompileDefinitionsDone && cm::contains(debugProperties, "COMPILE_DEFINITIONS"); @@ -4183,10 +4168,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetPrecompileHeaders( cmGeneratorExpressionDAGChecker dagChecker(this, "PRECOMPILE_HEADERS", nullptr, nullptr); - std::vector<std::string> debugProperties; - this->Makefile->GetDefExpandList("CMAKE_DEBUG_TARGET_PROPERTIES", - debugProperties); - + cmList debugProperties{ this->Makefile->GetDefinition( + "CMAKE_DEBUG_TARGET_PROPERTIES") }; bool debugDefines = !this->DebugPrecompileHeadersDone && std::find(debugProperties.begin(), debugProperties.end(), "PRECOMPILE_HEADERS") != debugProperties.end(); @@ -4580,10 +4563,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkOptions( cmGeneratorExpressionDAGChecker dagChecker(this, "LINK_OPTIONS", nullptr, nullptr); - std::vector<std::string> debugProperties; - this->Makefile->GetDefExpandList("CMAKE_DEBUG_TARGET_PROPERTIES", - debugProperties); - + cmList debugProperties{ this->Makefile->GetDefinition( + "CMAKE_DEBUG_TARGET_PROPERTIES") }; bool debugOptions = !this->DebugLinkOptionsDone && cm::contains(debugProperties, "LINK_OPTIONS"); @@ -4864,10 +4845,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDirectories( cmGeneratorExpressionDAGChecker dagChecker(this, "LINK_DIRECTORIES", nullptr, nullptr); - std::vector<std::string> debugProperties; - this->Makefile->GetDefExpandList("CMAKE_DEBUG_TARGET_PROPERTIES", - debugProperties); - + cmList debugProperties{ this->Makefile->GetDefinition( + "CMAKE_DEBUG_TARGET_PROPERTIES") }; bool debugDirectories = !this->DebugLinkDirectoriesDone && cm::contains(debugProperties, "LINK_DIRECTORIES"); @@ -5644,8 +5623,7 @@ cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const for (cmGeneratorTarget const* li : deps) { #define CM_READ_COMPATIBLE_INTERFACE(X, x) \ if (cmValue prop = li->GetProperty("COMPATIBLE_INTERFACE_" #X)) { \ - std::vector<std::string> props; \ - cmExpandList(*prop, props); \ + cmList props(*prop); \ compat.Props##x.insert(props.begin(), props.end()); \ } CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool) @@ -6719,10 +6697,8 @@ void cmGeneratorTarget::ReportPropertyOrigin( const std::string& p, const std::string& result, const std::string& report, const std::string& compatibilityType) const { - std::vector<std::string> debugProperties; - this->Target->GetMakefile()->GetDefExpandList( - "CMAKE_DEBUG_TARGET_PROPERTIES", debugProperties); - + cmList debugProperties{ this->Target->GetMakefile()->GetDefinition( + "CMAKE_DEBUG_TARGET_PROPERTIES") }; bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] && cm::contains(debugProperties, p); @@ -8223,7 +8199,6 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( cmBTStringRange entryRange = this->Target->GetLinkImplementationEntries(); // Collect libraries directly linked in this configuration. for (auto const& entry : entryRange) { - std::vector<std::string> llibs; // Keep this logic in sync with ExpandLinkItems. cmGeneratorExpressionDAGChecker dagChecker(this, "LINK_LIBRARIES", nullptr, nullptr); @@ -8250,7 +8225,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( cge->Evaluate(this->LocalGenerator, config, head, &dagChecker, nullptr, this->LinkerLanguage); bool const checkCMP0027 = evaluated != entry.Value; - cmExpandList(evaluated, llibs); + cmList llibs(evaluated); if (cge->GetHadHeadSensitiveCondition()) { impl.HadHeadSensitiveCondition = true; } @@ -8261,7 +8236,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( impl.HadLinkLanguageSensitiveCondition = true; } - for (std::string const& lib : llibs) { + for (auto const& lib : llibs) { if (this->IsLinkLookupScope(lib, lg)) { continue; } @@ -8429,16 +8404,16 @@ bool cmGeneratorTarget::HasPackageReferences() const std::vector<std::string> cmGeneratorTarget::GetPackageReferences() const { - std::vector<std::string> packageReferences; + cmList packageReferences; if (this->IsInBuildSystem()) { if (cmValue vsPackageReferences = this->GetProperty("VS_PACKAGE_REFERENCES")) { - cmExpandList(*vsPackageReferences, packageReferences); + packageReferences.assign(*vsPackageReferences); } } - return packageReferences; + return std::move(packageReferences.data()); } std::string cmGeneratorTarget::GetPDBDirectory(const std::string& config) const diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index d0a0fdf..040f500 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -239,10 +239,10 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string& lang, this->GetCMakeInstance()->GetState()->GetInitializedCacheValue(langComp); // Split compiler from arguments - std::vector<std::string> cnameArgVec; + cmList cnameArgList; if (cname && !cname->empty()) { - cmExpandList(*cname, cnameArgVec); - cname = cmValue(cnameArgVec.front()); + cnameArgList.assign(*cname); + cname = cmValue(cnameArgList.front()); } std::string changeVars; @@ -1985,7 +1985,6 @@ void cmGlobalGenerator::CheckTargetProperties() notFoundMap[varName] = text; } } - std::vector<std::string> incs; cmValue incDirProp = target.second.GetProperty("INCLUDE_DIRECTORIES"); if (!incDirProp) { continue; @@ -1994,7 +1993,7 @@ void cmGlobalGenerator::CheckTargetProperties() std::string incDirs = cmGeneratorExpression::Preprocess( *incDirProp, cmGeneratorExpression::StripAllGeneratorExpressions); - cmExpandList(incDirs, incs); + cmList incs(incDirs); for (std::string const& incDir : incs) { if (incDir.size() > 9 && cmIsNOTFOUND(incDir)) { @@ -2789,11 +2788,9 @@ void cmGlobalGenerator::AddGlobalTarget_Test( cmCustomCommandLine singleLine; singleLine.push_back(cmSystemTools::GetCTestCommand()); singleLine.push_back("--force-new-ctest-process"); - std::vector<std::string> args; - if (mf->GetDefExpandList("CMAKE_CTEST_ARGUMENTS", args)) { - for (auto const& arg : args) { - singleLine.push_back(arg); - } + cmList args(mf->GetDefinition("CMAKE_CTEST_ARGUMENTS")); + for (auto const& arg : args) { + singleLine.push_back(arg); } if (cmNonempty(cmakeCfgIntDir) && cmakeCfgIntDir[0] != '.') { singleLine.push_back("-C"); @@ -3348,12 +3345,12 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) cmSystemTools::MakeDirectory(dir); cmGeneratedFileStream fout(file); - std::vector<std::string> labels; + cmList labels; // List the target-wide labels. All sources in the target get // these labels. if (targetLabels) { - cmExpandList(*targetLabels, labels); + labels.assign(*targetLabels); if (!labels.empty()) { fout << "# Target labels\n"; for (std::string const& l : labels) { @@ -3364,27 +3361,27 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) } // List directory labels - std::vector<std::string> directoryLabelsList; - std::vector<std::string> cmakeDirectoryLabelsList; + cmList directoryLabelsList; + cmList cmakeDirectoryLabelsList; if (directoryLabels) { - cmExpandList(*directoryLabels, directoryLabelsList); + directoryLabelsList.assign(*directoryLabels); } if (cmakeDirectoryLabels) { - cmExpandList(*cmakeDirectoryLabels, cmakeDirectoryLabelsList); + cmakeDirectoryLabelsList.assign(*cmakeDirectoryLabels); } if (!directoryLabelsList.empty() || !cmakeDirectoryLabelsList.empty()) { fout << "# Directory labels\n"; } - for (std::string const& li : directoryLabelsList) { + for (auto const& li : directoryLabelsList) { fout << " " << li << "\n"; lj_target_labels.append(li); } - for (std::string const& li : cmakeDirectoryLabelsList) { + for (auto const& li : cmakeDirectoryLabelsList) { fout << " " << li << "\n"; lj_target_labels.append(li); } @@ -3405,10 +3402,9 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) fout << sfp << "\n"; lj_source["file"] = sfp; if (cmValue svalue = sf->GetProperty("LABELS")) { - labels.clear(); Json::Value& lj_source_labels = lj_source["labels"] = Json::arrayValue; - cmExpandList(*svalue, labels); - for (std::string const& label : labels) { + labels.assign(*svalue); + for (auto const& label : labels) { fout << " " << label << "\n"; lj_source_labels.append(label); } diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 0c28776..84c85e0 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -32,6 +32,7 @@ #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" #include "cmLinkLineComputer.h" +#include "cmList.h" #include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmLocalNinjaGenerator.h" @@ -3031,19 +3032,17 @@ void cmGlobalNinjaMultiGenerator::GetQtAutoGenConfigs( bool cmGlobalNinjaMultiGenerator::InspectConfigTypeVariables() { - std::vector<std::string> configsVec; - cmExpandList( - this->Makefiles.front()->GetSafeDefinition("CMAKE_CONFIGURATION_TYPES"), - configsVec); - if (configsVec.empty()) { - configsVec.emplace_back(); + cmList configsList{ this->Makefiles.front()->GetDefinition( + "CMAKE_CONFIGURATION_TYPES") }; + if (configsList.empty()) { + configsList.emplace_back(); } - std::set<std::string> configs(configsVec.cbegin(), configsVec.cend()); + std::set<std::string> configs(configsList.cbegin(), configsList.cend()); this->DefaultFileConfig = this->Makefiles.front()->GetSafeDefinition("CMAKE_DEFAULT_BUILD_TYPE"); if (this->DefaultFileConfig.empty()) { - this->DefaultFileConfig = configsVec.front(); + this->DefaultFileConfig = configsList.front(); } if (!configs.count(this->DefaultFileConfig)) { std::ostringstream msg; @@ -3055,11 +3054,9 @@ bool cmGlobalNinjaMultiGenerator::InspectConfigTypeVariables() return false; } - std::vector<std::string> crossConfigsVec; - cmExpandList( - this->Makefiles.front()->GetSafeDefinition("CMAKE_CROSS_CONFIGS"), - crossConfigsVec); - auto crossConfigs = ListSubsetWithAll(configs, configs, crossConfigsVec); + cmList crossConfigsList{ this->Makefiles.front()->GetSafeDefinition( + "CMAKE_CROSS_CONFIGS") }; + auto crossConfigs = ListSubsetWithAll(configs, configs, crossConfigsList); if (!crossConfigs) { std::ostringstream msg; msg << "CMAKE_CROSS_CONFIGS is not a subset of " @@ -3086,12 +3083,11 @@ bool cmGlobalNinjaMultiGenerator::InspectConfigTypeVariables() return false; } - std::vector<std::string> defaultConfigsVec; - cmExpandList(defaultConfigsString, defaultConfigsVec); + cmList defaultConfigsList(defaultConfigsString); if (!this->DefaultFileConfig.empty()) { auto defaultConfigs = ListSubsetWithAll(this->GetCrossConfigs(this->DefaultFileConfig), - this->CrossConfigs, defaultConfigsVec); + this->CrossConfigs, defaultConfigsList); if (!defaultConfigs) { std::ostringstream msg; msg << "CMAKE_DEFAULT_CONFIGS is not a subset of CMAKE_CROSS_CONFIGS"; diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index de13924..bcb26cc 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -8,6 +8,7 @@ #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" #include "cmGlobalVisualStudioGenerator.h" +#include "cmList.h" #include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" @@ -205,12 +206,12 @@ void cmGlobalVisualStudio71Generator::WriteProjectConfigurations( !platformMapping.empty() ? platformMapping : this->GetPlatformName(); std::string guid = this->GetGUID(name); for (std::string const& i : configs) { - std::vector<std::string> mapConfig; + cmList mapConfig; const char* dstConfig = i.c_str(); if (target.GetProperty("EXTERNAL_MSPROJECT")) { if (cmValue m = target.GetProperty("MAP_IMPORTED_CONFIG_" + cmSystemTools::UpperCase(i))) { - cmExpandList(*m, mapConfig); + mapConfig.assign(*m); if (!mapConfig.empty()) { dstConfig = mapConfig[0].c_str(); } diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index d902c68..819bb09 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -20,6 +20,7 @@ #include "cmGlobalGenerator.h" #include "cmGlobalVisualStudio7Generator.h" #include "cmGlobalVisualStudioGenerator.h" +#include "cmList.h" #include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmLocalVisualStudio7Generator.h" @@ -411,12 +412,12 @@ void cmGlobalVisualStudio8Generator::WriteProjectConfigurations( { std::string guid = this->GetGUID(name); for (std::string const& i : configs) { - std::vector<std::string> mapConfig; + cmList mapConfig; const char* dstConfig = i.c_str(); if (target.GetProperty("EXTERNAL_MSPROJECT")) { if (cmValue m = target.GetProperty("MAP_IMPORTED_CONFIG_" + cmSystemTools::UpperCase(i))) { - cmExpandList(*m, mapConfig); + mapConfig.assign(*m); if (!mapConfig.empty()) { dstConfig = mapConfig[0].c_str(); } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 1328f4b..60f46e5 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -4600,13 +4600,12 @@ std::string cmGlobalXCodeGenerator::GetTargetTempDir( void cmGlobalXCodeGenerator::ComputeArchitectures(cmMakefile* mf) { this->Architectures.clear(); - cmValue sysroot = mf->GetDefinition("CMAKE_OSX_SYSROOT"); - if (sysroot) { - mf->GetDefExpandList("CMAKE_OSX_ARCHITECTURES", this->Architectures); - } + cmList::append(this->Architectures, + mf->GetDefinition("CMAKE_OSX_ARCHITECTURES")); if (this->Architectures.empty()) { - mf->GetDefExpandList("_CMAKE_APPLE_ARCHS_DEFAULT", this->Architectures); + cmList::append(this->Architectures, + mf->GetDefinition("_CMAKE_APPLE_ARCHS_DEFAULT")); } if (this->Architectures.empty()) { diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index 9468d4a..f94faf8 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -12,6 +12,7 @@ #include "cmsys/String.h" #include "cmIDEFlagTable.h" +#include "cmList.h" #include "cmStringAlgorithms.h" cmIDEOptions::cmIDEOptions() diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx index d358763..6aa9910 100644 --- a/Source/cmInstallDirectoryGenerator.cxx +++ b/Source/cmInstallDirectoryGenerator.cxx @@ -6,6 +6,7 @@ #include "cmGeneratorExpression.h" #include "cmInstallType.h" +#include "cmList.h" #include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" @@ -53,17 +54,16 @@ bool cmInstallDirectoryGenerator::Compute(cmLocalGenerator* lg) std::vector<std::string> cmInstallDirectoryGenerator::GetDirectories( std::string const& config) const { - std::vector<std::string> directories; + cmList directories; if (this->ActionsPerConfig) { for (std::string const& f : this->Directories) { - cmExpandList( - cmGeneratorExpression::Evaluate(f, this->LocalGenerator, config), - directories); + directories.append( + cmGeneratorExpression::Evaluate(f, this->LocalGenerator, config)); } } else { directories = this->Directories; } - return directories; + return std::move(directories.data()); } void cmInstallDirectoryGenerator::GenerateScriptActions(std::ostream& os, diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index 18a852b..43dc656 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -6,8 +6,8 @@ #include "cmGeneratorExpression.h" #include "cmInstallType.h" +#include "cmList.h" #include "cmListFileCache.h" -#include "cmStringAlgorithms.h" class cmLocalGenerator; @@ -69,17 +69,15 @@ std::string cmInstallFilesGenerator::GetRename(std::string const& config) const std::vector<std::string> cmInstallFilesGenerator::GetFiles( std::string const& config) const { - std::vector<std::string> files; if (this->ActionsPerConfig) { + cmList files; for (std::string const& f : this->Files) { - cmExpandList( - cmGeneratorExpression::Evaluate(f, this->LocalGenerator, config), - files); + files.append( + cmGeneratorExpression::Evaluate(f, this->LocalGenerator, config)); } - } else { - files = this->Files; + return std::move(files.data()); } - return files; + return this->Files; } void cmInstallFilesGenerator::AddFilesInstallRule( diff --git a/Source/cmInstalledFile.cxx b/Source/cmInstalledFile.cxx index 5bf8320..381c91b 100644 --- a/Source/cmInstalledFile.cxx +++ b/Source/cmInstalledFile.cxx @@ -5,9 +5,9 @@ #include <utility> #include "cmGeneratorExpression.h" +#include "cmList.h" #include "cmListFileCache.h" #include "cmMakefile.h" -#include "cmStringAlgorithms.h" #include "cmValue.h" cmInstalledFile::cmInstalledFile() = default; @@ -97,12 +97,11 @@ bool cmInstalledFile::GetPropertyAsBool(const std::string& prop) const return isSet && cmIsOn(value); } -void cmInstalledFile::GetPropertyAsList(const std::string& prop, - std::vector<std::string>& list) const +std::vector<std::string> cmInstalledFile::GetPropertyAsList( + const std::string& prop) const { std::string value; this->GetProperty(prop, value); - list.clear(); - cmExpandList(value, list); + return std::move(cmList(value).data()); } diff --git a/Source/cmInstalledFile.h b/Source/cmInstalledFile.h index 82474f5..373c349 100644 --- a/Source/cmInstalledFile.h +++ b/Source/cmInstalledFile.h @@ -59,8 +59,7 @@ public: bool GetPropertyAsBool(const std::string& prop) const; - void GetPropertyAsList(const std::string& prop, - std::vector<std::string>& list) const; + std::vector<std::string> GetPropertyAsList(const std::string& prop) const; void SetName(cmMakefile* mf, const std::string& name); diff --git a/Source/cmList.h b/Source/cmList.h index 26bf42e..d9ce951 100644 --- a/Source/cmList.h +++ b/Source/cmList.h @@ -24,6 +24,8 @@ /** * CMake lists management + * A CMake list is a string where list elements are separated by the ';' + * character. * * For all operations, input arguments (single value like cm::string_view or * multiple values specified through pair of iterators) are, by default, @@ -1331,3 +1333,20 @@ void append(cmList& v, Range const& r) #endif } // namespace cm + +/** + * Helper functions for legacy support. Use preferably cmList class directly + * or the static methods of the class. + */ +inline void cmExpandList( + cm::string_view arg, std::vector<std::string>& argsOut, + cmList::EmptyElements emptyElements = cmList::EmptyElements::No) +{ + cmList::append(argsOut, arg, emptyElements); +} +inline void cmExpandList( + cmValue arg, std::vector<std::string>& argsOut, + cmList::EmptyElements emptyElements = cmList::EmptyElements::No) +{ + cmList::append(argsOut, arg, emptyElements); +} diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 73c97a6..64f0246 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -147,12 +147,10 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile) this->Makefile->GetDefinition("CMAKE_APPLE_ARCH_SYSROOTS")) { std::string const& appleArchs = this->Makefile->GetSafeDefinition("CMAKE_OSX_ARCHITECTURES"); - std::vector<std::string> archs; - std::vector<std::string> sysroots; - cmExpandList(appleArchs, archs); - cmExpandList(*appleArchSysroots, sysroots, true); + cmList archs(appleArchs); + cmList sysroots{ appleArchSysroots, cmList::EmptyElements::Yes }; if (archs.size() == sysroots.size()) { - for (size_t i = 0; i < archs.size(); ++i) { + for (cmList::size_type i = 0; i < archs.size(); ++i) { this->AppleArchSysroots[archs[i]] = sysroots[i]; } } else { @@ -1169,11 +1167,11 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit( // Standard include directories to be added unconditionally at the end. // These are intended to simulate additional implicit include directories. - std::vector<std::string> userStandardDirs; + cmList userStandardDirs; { std::string const value = this->Makefile->GetSafeDefinition( cmStrCat("CMAKE_", lang, "_STANDARD_INCLUDE_DIRECTORIES")); - cmExpandList(value, userStandardDirs); + userStandardDirs.assign(value); for (std::string& usd : userStandardDirs) { cmSystemTools::ConvertToUnixSlashes(usd); } @@ -1196,13 +1194,12 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit( // directories for modules ('.mod' files). if (lang != "Fortran") { size_t const impDirVecOldSize = impDirVec.size(); - if (this->Makefile->GetDefExpandList( - cmStrCat("CMAKE_", lang, "_IMPLICIT_INCLUDE_DIRECTORIES"), - impDirVec)) { - // FIXME: Use cmRange with 'advance()' when it supports non-const. - for (size_t i = impDirVecOldSize; i < impDirVec.size(); ++i) { - cmSystemTools::ConvertToUnixSlashes(impDirVec[i]); - } + cmList::append(impDirVec, + this->Makefile->GetDefinition(cmStrCat( + "CMAKE_", lang, "_IMPLICIT_INCLUDE_DIRECTORIES"))); + // FIXME: Use cmRange with 'advance()' when it supports non-const. + for (size_t i = impDirVecOldSize; i < impDirVec.size(); ++i) { + cmSystemTools::ConvertToUnixSlashes(impDirVec[i]); } } @@ -2448,10 +2445,9 @@ void cmLocalGenerator::AddColorDiagnosticsFlags(std::string& flags, cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_COLOR_DIAGNOSTICS_OFF"); } - std::vector<std::string> options; - this->Makefile->GetDefExpandList(colorFlagName, options); + cmList options{ this->Makefile->GetDefinition(colorFlagName) }; - for (std::string const& option : options) { + for (auto const& option : options) { this->AppendFlagEscape(flags, option); } } @@ -4387,12 +4383,11 @@ void AddUtilityCommand(cmLocalGenerator& lg, cmCommandOrigin origin, std::vector<std::string> ComputeISPCObjectSuffixes(cmGeneratorTarget* target) { - const std::string& targetProperty = - target->GetSafeProperty("ISPC_INSTRUCTION_SETS"); - std::vector<std::string> ispcTargets; + const cmValue targetProperty = target->GetProperty("ISPC_INSTRUCTION_SETS"); + cmList ispcTargets; - if (!cmIsOff(targetProperty)) { - cmExpandList(targetProperty, ispcTargets); + if (!targetProperty.IsOff()) { + ispcTargets.assign(targetProperty); for (auto& ispcTarget : ispcTargets) { // transform targets into the suffixes auto pos = ispcTarget.find('-'); @@ -4404,7 +4399,7 @@ std::vector<std::string> ComputeISPCObjectSuffixes(cmGeneratorTarget* target) ispcTarget = target_suffix; } } - return ispcTargets; + return std::move(ispcTargets.data()); } std::vector<std::string> ComputeISPCExtraObjects( diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 42fa298..a047233 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -909,14 +909,11 @@ void cmLocalNinjaGenerator::AdditionalCleanFiles(const std::string& config) { if (cmValue prop_value = this->Makefile->GetProperty("ADDITIONAL_CLEAN_FILES")) { - std::vector<std::string> cleanFiles; - { - cmExpandList(cmGeneratorExpression::Evaluate(*prop_value, this, config), - cleanFiles); - } + cmList cleanFiles{ cmGeneratorExpression::Evaluate(*prop_value, this, + config) }; std::string const& binaryDir = this->GetCurrentBinaryDirectory(); cmGlobalNinjaGenerator* gg = this->GetGlobalNinjaGenerator(); - for (std::string const& cleanFile : cleanFiles) { + for (auto const& cleanFile : cleanFiles) { // Support relative paths gg->AddAdditionalCleanFile( cmSystemTools::CollapseFullPath(cleanFile, binaryDir), config); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 12cecbd..d8f532f 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1130,14 +1130,13 @@ void cmLocalUnixMakefileGenerator3::AppendCleanCommand( void cmLocalUnixMakefileGenerator3::AppendDirectoryCleanCommand( std::vector<std::string>& commands) { - std::vector<std::string> cleanFiles; + cmList cleanFiles; // Look for additional files registered for cleaning in this directory. if (cmValue prop_value = this->Makefile->GetProperty("ADDITIONAL_CLEAN_FILES")) { - cmExpandList(cmGeneratorExpression::Evaluate( - *prop_value, this, - this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")), - cleanFiles); + cleanFiles.assign(cmGeneratorExpression::Evaluate( + *prop_value, this, + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"))); } if (cleanFiles.empty()) { return; @@ -1973,14 +1972,14 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo( // Store include transform rule properties. Write the directory // rules first because they may be overridden by later target rules. - std::vector<std::string> transformRules; + cmList transformRules; if (cmValue xform = this->Makefile->GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) { - cmExpandList(*xform, transformRules); + transformRules.assign(*xform); } if (cmValue xform = target->GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) { - cmExpandList(*xform, transformRules); + transformRules.append(*xform); } if (!transformRules.empty()) { cmakefileStream << "\nset(CMAKE_INCLUDE_TRANSFORMS\n"; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 490a905..01afc44 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1957,21 +1957,15 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, value = existingValue->c_str(); } if (type == cmStateEnums::PATH || type == cmStateEnums::FILEPATH) { - std::vector<std::string>::size_type cc; - std::vector<std::string> files; nvalue = value ? value : ""; - cmExpandList(nvalue, files); - nvalue.clear(); - for (cc = 0; cc < files.size(); cc++) { - if (!cmIsOff(files[cc])) { - files[cc] = cmSystemTools::CollapseFullPath(files[cc]); + cmList files(nvalue); + for (auto& file : files) { + if (!cmIsOff(file)) { + file = cmSystemTools::CollapseFullPath(file); } - if (cc > 0) { - nvalue += ";"; - } - nvalue += files[cc]; } + nvalue = files.to_string(); this->GetCMakeInstance()->AddCacheEntry(name, nvalue, doc, type); nvalue = *this->GetState()->GetInitializedCacheValue(name); @@ -2613,18 +2607,6 @@ const std::string& cmMakefile::GetSafeDefinition(const std::string& name) const return this->GetDefinition(name); } -bool cmMakefile::GetDefExpandList(const std::string& name, - std::vector<std::string>& out, - bool emptyArgs) const -{ - cmValue def = this->GetDefinition(name); - if (!def) { - return false; - } - cmExpandList(*def, out, emptyArgs); - return true; -} - std::vector<std::string> cmMakefile::GetDefinitions() const { std::vector<std::string> res = this->StateSnapshot.ClosureKeys(); @@ -3265,9 +3247,9 @@ std::string cmMakefile::GetDefaultConfiguration() const std::vector<std::string> cmMakefile::GetGeneratorConfigs( GeneratorConfigQuery mode) const { - std::vector<std::string> configs; + cmList configs; if (this->GetGlobalGenerator()->IsMultiConfig()) { - this->GetDefExpandList("CMAKE_CONFIGURATION_TYPES", configs); + configs.assign(this->GetDefinition("CMAKE_CONFIGURATION_TYPES")); } else if (mode != cmMakefile::OnlyMultiConfig) { const std::string& buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE"); if (!buildType.empty()) { @@ -3277,7 +3259,7 @@ std::vector<std::string> cmMakefile::GetGeneratorConfigs( if (mode == cmMakefile::IncludeEmptyConfig && configs.empty()) { configs.emplace_back(); } - return configs; + return std::move(configs.data()); } bool cmMakefile::IsFunctionBlocked(const cmListFileFunction& lff, @@ -4154,11 +4136,11 @@ void cmMakefile::GetTests(const std::string& config, void cmMakefile::AddCMakeDependFilesFromUser() { - std::vector<std::string> deps; + cmList deps; if (cmValue deps_str = this->GetProperty("CMAKE_CONFIGURE_DEPENDS")) { - cmExpandList(*deps_str, deps); + deps.assign(*deps_str); } - for (std::string const& dep : deps) { + for (auto const& dep : deps) { if (cmSystemTools::FileIsFullPath(dep)) { this->AddCMakeDependFile(dep); } else { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index a43ff41..d1f5be5 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -518,8 +518,6 @@ public: const std::string& GetRequiredDefinition(const std::string& name) const; bool IsDefinitionSet(const std::string&) const; bool IsNormalDefinitionSet(const std::string&) const; - bool GetDefExpandList(const std::string& name, std::vector<std::string>& out, - bool emptyArgs = false) const; /** * Get the list of all variables in the current space. If argument * cacheonly is specified and is greater than 0, then only cache diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 1960073..3caabde 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -16,6 +16,7 @@ #include "cmGlobalUnixMakefileGenerator3.h" #include "cmLinkLineComputer.h" #include "cmLinkLineDeviceComputer.h" +#include "cmList.h" #include "cmLocalGenerator.h" #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" @@ -151,11 +152,10 @@ void cmMakefileExecutableTargetGenerator::WriteNvidiaDeviceExecutableRule( bool useLinkScript = this->GlobalGenerator->GetUseLinkScript(); // Construct the main link rule. - std::vector<std::string> real_link_commands; const std::string linkRuleVar = "CMAKE_CUDA_DEVICE_LINK_EXECUTABLE"; const std::string linkRule = this->GetLinkRule(linkRuleVar); std::vector<std::string> commands1; - cmExpandList(linkRule, real_link_commands); + cmList real_link_commands(linkRule); bool useResponseFileForObjects = this->CheckUseResponseFileForObjects(linkLanguage); @@ -235,7 +235,7 @@ void cmMakefileExecutableTargetGenerator::WriteNvidiaDeviceExecutableRule( // Expand placeholders in the commands. rulePlaceholderExpander->SetTargetImpLib(targetOutput); - for (std::string& real_link_command : real_link_commands) { + for (auto& real_link_command : real_link_commands) { real_link_command = cmStrCat(launcher, real_link_command); rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, real_link_command, vars); @@ -466,18 +466,18 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) bool useLinkScript = this->GlobalGenerator->GetUseLinkScript(); // Construct the main link rule. - std::vector<std::string> real_link_commands; std::string linkRuleVar = this->GeneratorTarget->GetCreateRuleVariable( linkLanguage, this->GetConfigName()); std::string linkRule = this->GetLinkRule(linkRuleVar); std::vector<std::string> commands1; - cmExpandList(linkRule, real_link_commands); + cmList real_link_commands(linkRule); + if (this->GeneratorTarget->IsExecutableWithExports()) { // If a separate rule for creating an import library is specified // add it now. std::string implibRuleVar = cmStrCat("CMAKE_", linkLanguage, "_CREATE_IMPORT_LIBRARY"); - this->Makefile->GetDefExpandList(implibRuleVar, real_link_commands); + real_link_commands.append(this->Makefile->GetDefinition(implibRuleVar)); } bool useResponseFileForObjects = @@ -601,7 +601,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Expand placeholders in the commands. rulePlaceholderExpander->SetTargetImpLib(targetOutPathImport); - for (std::string& real_link_command : real_link_commands) { + for (auto& real_link_command : real_link_commands) { real_link_command = cmStrCat(launcher, real_link_command); rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, real_link_command, vars); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 43062d9..691edf4 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -305,7 +305,7 @@ void cmMakefileLibraryTargetGenerator::WriteNvidiaDeviceLibraryRules( vars.Language = linkLanguage.c_str(); // Expand the rule variables. - std::vector<std::string> real_link_commands; + cmList real_link_commands; { // Set path conversion for link script shells. this->LocalGenerator->SetLinkScriptShell(useLinkScript); @@ -376,10 +376,10 @@ void cmMakefileLibraryTargetGenerator::WriteNvidiaDeviceLibraryRules( // Construct the main link rule and expand placeholders. rulePlaceholderExpander->SetTargetImpLib(targetOutput); std::string linkRule = this->GetLinkRule(linkRuleVar); - cmExpandList(linkRule, real_link_commands); + real_link_commands.append(linkRule); // Expand placeholders. - for (std::string& real_link_command : real_link_commands) { + for (auto& real_link_command : real_link_commands) { real_link_command = cmStrCat(launcher, real_link_command); rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, real_link_command, vars); @@ -641,9 +641,9 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( // For static libraries there might be archiving rules. bool haveStaticLibraryRule = false; - std::vector<std::string> archiveCreateCommands; - std::vector<std::string> archiveAppendCommands; - std::vector<std::string> archiveFinishCommands; + cmList archiveCreateCommands; + cmList archiveAppendCommands; + cmList archiveFinishCommands; std::string::size_type archiveCommandLimit = std::string::npos; if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) { haveStaticLibraryRule = this->Makefile->IsDefinitionSet(linkRuleVar); @@ -653,21 +653,23 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( arCreateVar = this->GeneratorTarget->GetFeatureSpecificLinkRuleVariable( arCreateVar, linkLanguage, this->GetConfigName()); - this->Makefile->GetDefExpandList(arCreateVar, archiveCreateCommands); + archiveCreateCommands.assign(this->Makefile->GetDefinition(arCreateVar)); + std::string arAppendVar = cmStrCat("CMAKE_", linkLanguage, "_ARCHIVE_APPEND"); arAppendVar = this->GeneratorTarget->GetFeatureSpecificLinkRuleVariable( arAppendVar, linkLanguage, this->GetConfigName()); - this->Makefile->GetDefExpandList(arAppendVar, archiveAppendCommands); + archiveAppendCommands.assign(this->Makefile->GetDefinition(arAppendVar)); + std::string arFinishVar = cmStrCat("CMAKE_", linkLanguage, "_ARCHIVE_FINISH"); arFinishVar = this->GeneratorTarget->GetFeatureSpecificLinkRuleVariable( arFinishVar, linkLanguage, this->GetConfigName()); - this->Makefile->GetDefExpandList(arFinishVar, archiveFinishCommands); + archiveFinishCommands.assign(this->Makefile->GetDefinition(arFinishVar)); } // Decide whether to use archiving rules. @@ -695,7 +697,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( this->LocalGenerator->CreateRulePlaceholderExpander()); bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar + "_USE_WATCOM_QUOTE"); - std::vector<std::string> real_link_commands; + cmList real_link_commands; { // Set path conversion for link script shells. this->LocalGenerator->SetLinkScriptShell(useLinkScript); @@ -880,7 +882,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( } else { // Get the set of commands. std::string linkRule = this->GetLinkRule(linkRuleVar); - cmExpandList(linkRule, real_link_commands); + real_link_commands.append(linkRule); if (this->UseLWYU) { cmValue lwyuCheck = this->Makefile->GetDefinition("CMAKE_LINK_WHAT_YOU_USE_CHECK"); @@ -896,7 +898,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( } // Expand placeholders. - for (std::string& real_link_command : real_link_commands) { + for (auto& real_link_command : real_link_commands) { real_link_command = cmStrCat(launcher, real_link_command); rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, real_link_command, vars); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 1e35fe7..a0a7324 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -208,27 +208,24 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() // -- Write the custom commands for this target // Evaluates generator expressions and expands prop_value - auto evaluatedFiles = - [this](const std::string& prop_value) -> std::vector<std::string> { - std::vector<std::string> files; - cmExpandList(cmGeneratorExpression::Evaluate( - prop_value, this->LocalGenerator, this->GetConfigName(), - this->GeneratorTarget), - files); + auto evaluatedFiles = [this](const std::string& prop_value) -> cmList { + cmList files{ cmGeneratorExpression::Evaluate( + prop_value, this->LocalGenerator, this->GetConfigName(), + this->GeneratorTarget) }; return files; }; // Look for additional files registered for cleaning in this directory. if (cmValue prop_value = this->Makefile->GetProperty("ADDITIONAL_MAKE_CLEAN_FILES")) { - std::vector<std::string> const files = evaluatedFiles(*prop_value); + auto const files = evaluatedFiles(*prop_value); this->CleanFiles.insert(files.begin(), files.end()); } // Look for additional files registered for cleaning in this target. if (cmValue prop_value = this->GeneratorTarget->GetProperty("ADDITIONAL_CLEAN_FILES")) { - std::vector<std::string> const files = evaluatedFiles(*prop_value); + auto const files = evaluatedFiles(*prop_value); // For relative path support std::string const& binaryDir = this->LocalGenerator->GetCurrentBinaryDirectory(); @@ -1003,10 +1000,10 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( vars.CudaCompileMode = cudaCompileMode.c_str(); } - std::vector<std::string> compileCommands; + cmList compileCommands; const std::string& compileRule = this->Makefile->GetRequiredDefinition( "CMAKE_" + lang + "_COMPILE_OBJECT"); - cmExpandList(compileRule, compileCommands); + compileCommands.assign(compileRule); if (this->GeneratorTarget->GetPropertyAsBool("EXPORT_COMPILE_COMMANDS") && lang_can_export_cmds && compileCommands.size() == 1) { @@ -1209,7 +1206,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( i = this->LocalGenerator->EscapeForShell(i); } } - compileCommands.front().insert(0, cmJoin(args, " ") + " "); + compileCommands.front().insert(0, args.join(" ") + " "); } std::string launcher; @@ -1241,9 +1238,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( const auto& extraCommands = this->Makefile->GetSafeDefinition( cmStrCat("CMAKE_", lang, "_DEPENDS_EXTRA_COMMANDS")); if (!extraCommands.empty()) { - cmList commandList{ extraCommands }; - compileCommands.insert(compileCommands.end(), commandList.cbegin(), - commandList.cend()); + compileCommands.append(extraCommands); } const auto& depFormat = this->Makefile->GetRequiredDefinition( @@ -1284,14 +1279,15 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( } // Check for extra outputs created by the compilation. - std::vector<std::string> outputs(1, relativeObj); + cmList outputs; + outputs.emplace_back(relativeObj); if (cmValue extra_outputs_str = source.GetProperty("OBJECT_OUTPUTS")) { std::string evaluated_outputs = cmGeneratorExpression::Evaluate( *extra_outputs_str, this->LocalGenerator, config); if (!evaluated_outputs.empty()) { // Register these as extra files to clean. - cmExpandList(evaluated_outputs, outputs); + outputs.append(evaluated_outputs); } } if (!ispcHeaderRelative.empty()) { diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 091acd6..ee4fa90 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -610,7 +610,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile, std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeDeviceLinkCmd() { - std::vector<std::string> linkCmds; + cmList linkCmds; // this target requires separable cuda compilation // now build the correct command depending on if the target is @@ -619,23 +619,23 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeDeviceLinkCmd() case cmStateEnums::STATIC_LIBRARY: case cmStateEnums::SHARED_LIBRARY: case cmStateEnums::MODULE_LIBRARY: { - this->GetMakefile()->GetDefExpandList("CMAKE_CUDA_DEVICE_LINK_LIBRARY", - linkCmds); + linkCmds.assign( + this->GetMakefile()->GetDefinition("CMAKE_CUDA_DEVICE_LINK_LIBRARY")); } break; case cmStateEnums::EXECUTABLE: { - this->GetMakefile()->GetDefExpandList( - "CMAKE_CUDA_DEVICE_LINK_EXECUTABLE", linkCmds); + linkCmds.assign(this->GetMakefile()->GetDefinition( + "CMAKE_CUDA_DEVICE_LINK_EXECUTABLE")); } break; default: break; } - return linkCmds; + return std::move(linkCmds.data()); } std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd( const std::string& config) { - std::vector<std::string> linkCmds; + cmList linkCmds; cmMakefile* mf = this->GetMakefile(); { // If we have a rule variable prefer it. In the case of static libraries @@ -654,7 +654,7 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd( linkCmdStr += *rule; } } - cmExpandList(linkCmdStr, linkCmds); + linkCmds.assign(linkCmdStr); if (this->UseLWYU) { cmValue lwyuCheck = mf->GetDefinition("CMAKE_LINK_WHAT_YOU_USE_CHECK"); if (lwyuCheck) { @@ -673,7 +673,7 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd( linkCmds.push_back(std::move(cmakeCommand)); } } - return linkCmds; + return std::move(linkCmds.data()); } } switch (this->GetGeneratorTarget()->GetType()) { @@ -694,7 +694,7 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd( linkCmdVar, this->TargetLinkLanguage(config), config); std::string const& linkCmd = mf->GetRequiredDefinition(linkCmdVar); - cmExpandList(linkCmd, linkCmds); + linkCmds.append(linkCmd); } { std::string linkCmdVar = cmStrCat( @@ -704,7 +704,7 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd( linkCmdVar, this->TargetLinkLanguage(config), config); std::string const& linkCmd = mf->GetRequiredDefinition(linkCmdVar); - cmExpandList(linkCmd, linkCmds); + linkCmds.append(linkCmd); } #ifdef __APPLE__ // On macOS ranlib truncates the fractional part of the static archive @@ -728,7 +728,7 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd( default: assert(false && "Unexpected target type"); } - return linkCmds; + return std::move(linkCmds.data()); } void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement( diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index c2ae629..7ce6c96 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -9,6 +9,7 @@ #include <iterator> #include <map> #include <ostream> +#include <type_traits> #include <unordered_map> #include <unordered_set> #include <utility> @@ -688,7 +689,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, // Rule to scan dependencies of sources that need preprocessing. { - std::vector<std::string> scanCommands; + cmList scanCommands; std::string scanRuleName; std::string ppFileName; if (compilationPreprocesses) { @@ -696,8 +697,8 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, ppFileName = "$PREPROCESSED_OUTPUT_FILE"; std::string const& scanCommand = mf->GetRequiredDefinition( cmStrCat("CMAKE_EXPERIMENTAL_", lang, "_SCANDEP_SOURCE")); - cmExpandList(scanCommand, scanCommands); - for (std::string& i : scanCommands) { + scanCommands.assign(scanCommand); + for (auto& i : scanCommands) { i = cmStrCat(launcher, i); } } else { @@ -705,8 +706,8 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, ppFileName = "$out"; std::string const& ppCommmand = mf->GetRequiredDefinition( cmStrCat("CMAKE_", lang, "_PREPROCESS_SOURCE")); - cmExpandList(ppCommmand, scanCommands); - for (std::string& i : scanCommands) { + scanCommands.assign(ppCommmand); + for (auto& i : scanCommands) { i = cmStrCat(launcher, i); } scanCommands.emplace_back(GetScanCommand(cmakeCmd, tdi, lang, "$out", @@ -885,10 +886,9 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, } // Rule for compiling object file. - std::vector<std::string> compileCmds; const std::string cmdVar = cmStrCat("CMAKE_", lang, "_COMPILE_OBJECT"); const std::string& compileCmd = mf->GetRequiredDefinition(cmdVar); - cmExpandList(compileCmd, compileCmds); + cmList compileCmds(compileCmd); // See if we need to use a compiler launcher like ccache or distcc std::string compilerLauncher; @@ -1055,12 +1055,10 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, const auto& extraCommands = this->GetMakefile()->GetSafeDefinition( cmStrCat("CMAKE_", lang, "_DEPENDS_EXTRA_COMMANDS")); if (!extraCommands.empty()) { - cmList commandList{ extraCommands }; - compileCmds.insert(compileCmds.end(), commandList.cbegin(), - commandList.cend()); + compileCmds.append(extraCommands); } - for (std::string& i : compileCmds) { + for (auto& i : compileCmds) { i = cmStrCat(launcher, i); rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(), i, vars); @@ -1862,16 +1860,15 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand( compileObjectVars.CudaCompileMode = cudaCompileMode.c_str(); } - std::vector<std::string> compileCmds; const std::string cmdVar = cmStrCat("CMAKE_", language, "_COMPILE_OBJECT"); const std::string& compileCmd = this->Makefile->GetRequiredDefinition(cmdVar); - cmExpandList(compileCmd, compileCmds); + cmList compileCmds(compileCmd); std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander( this->GetLocalGenerator()->CreateRulePlaceholderExpander()); - for (std::string& i : compileCmds) { + for (auto& i : compileCmds) { // no launcher for CMAKE_EXPORT_COMPILE_COMMANDS rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(), i, compileObjectVars); @@ -1889,13 +1886,11 @@ void cmNinjaTargetGenerator::AdditionalCleanFiles(const std::string& config) if (cmValue prop_value = this->GeneratorTarget->GetProperty("ADDITIONAL_CLEAN_FILES")) { cmLocalNinjaGenerator* lg = this->LocalGenerator; - std::vector<std::string> cleanFiles; - cmExpandList(cmGeneratorExpression::Evaluate(*prop_value, lg, config, - this->GeneratorTarget), - cleanFiles); + cmList cleanFiles(cmGeneratorExpression::Evaluate(*prop_value, lg, config, + this->GeneratorTarget)); std::string const& binaryDir = lg->GetCurrentBinaryDirectory(); cmGlobalNinjaGenerator* gg = lg->GetGlobalNinjaGenerator(); - for (std::string const& cleanFile : cleanFiles) { + for (auto const& cleanFile : cleanFiles) { // Support relative paths gg->AddAdditionalCleanFile( cmSystemTools::CollapseFullPath(cleanFile, binaryDir), config); diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx index 3e677e6..b0462f0 100644 --- a/Source/cmParseArgumentsCommand.cxx +++ b/Source/cmParseArgumentsCommand.cxx @@ -174,13 +174,11 @@ bool cmParseArgumentsCommand(std::vector<std::string> const& args, parser.Bind(list, options, duplicateKey); // the third argument is a (cmake) list of single argument options - list.clear(); - cmExpandList(*argIter++, list); + list.assign(*argIter++); parser.Bind(list, singleValArgs, duplicateKey); // the fourth argument is a (cmake) list of multi argument options - list.clear(); - cmExpandList(*argIter++, list); + list.assign(*argIter++); parser.Bind(list, multiValArgs, duplicateKey); list.clear(); @@ -188,7 +186,7 @@ bool cmParseArgumentsCommand(std::vector<std::string> const& args, // Flatten ;-lists in the arguments into a single list as was done // by the original function(CMAKE_PARSE_ARGUMENTS). for (; argIter != argEnd; ++argIter) { - cmExpandList(*argIter, list); + list.append(*argIter); } } else { // in the PARSE_ARGV move read the arguments from ARGC and ARGV# diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 9f00a52..5c32093 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -614,8 +614,9 @@ bool cmQtAutoGenInitializer::InitMoc() if (this->GenTarget->GetPropertyAsBool("AUTOMOC_COMPILER_PREDEFINES") && (this->QtVersion >= IntegerVersion(5, 8))) { // Command - this->Makefile->GetDefExpandList("CMAKE_CXX_COMPILER_PREDEFINES_COMMAND", - this->Moc.PredefsCmd); + cmList::assign( + this->Moc.PredefsCmd, + this->Makefile->GetDefinition("CMAKE_CXX_COMPILER_PREDEFINES_COMMAND")); // Header if (!this->Moc.PredefsCmd.empty()) { this->ConfigFileNames(this->Moc.PredefsFile, diff --git a/Source/cmRuntimeDependencyArchive.cxx b/Source/cmRuntimeDependencyArchive.cxx index 4dfdfae..2fbf2fa 100644 --- a/Source/cmRuntimeDependencyArchive.cxx +++ b/Source/cmRuntimeDependencyArchive.cxx @@ -3,13 +3,21 @@ #include "cmRuntimeDependencyArchive.h" +#include <algorithm> +#include <sstream> +#include <string> +#include <utility> +#include <vector> + +#include <cm/memory> + #include "cmBinUtilsLinuxELFLinker.h" #include "cmBinUtilsMacOSMachOLinker.h" #include "cmBinUtilsWindowsPELinker.h" #include "cmExecutionStatus.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmStateTypes.h" -#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #if defined(_WIN32) @@ -22,14 +30,6 @@ # include "cmVSSetupHelper.h" #endif -#include <algorithm> -#include <sstream> -#include <string> -#include <utility> -#include <vector> - -#include <cm/memory> - #if defined(_WIN32) static void AddVisualStudioPath(std::vector<std::string>& paths, const std::string& prefix, diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h index 0e9dfbf..4a9840b 100644 --- a/Source/cmStringAlgorithms.h +++ b/Source/cmStringAlgorithms.h @@ -14,7 +14,6 @@ #include <cm/string_view> -#include "cmList.h" #include "cmRange.h" #include "cmValue.h" @@ -89,38 +88,6 @@ std::string cmJoin(cmStringRange const& rng, cm::string_view separator, /** Extract tokens that are separated by any of the characters in @a sep. */ std::vector<std::string> cmTokenize(cm::string_view str, cm::string_view sep); -/** - * Expand the ; separated string @a arg into multiple arguments. - * All found arguments are appended to @a argsOut. - */ -inline void cmExpandList(cm::string_view arg, - std::vector<std::string>& argsOut, - bool emptyArgs = false) -{ - cmList::append(argsOut, arg, - emptyArgs ? cmList::EmptyElements::Yes - : cmList::EmptyElements::No); -} -inline void cmExpandList(cmValue arg, std::vector<std::string>& argsOut, - bool emptyArgs = false) -{ - cmList::append(argsOut, arg, - emptyArgs ? cmList::EmptyElements::Yes - : cmList::EmptyElements::No); -} - -/** - * Expand out any arguments in the string range [@a first, @a last) that have - * ; separated strings into multiple arguments. All found arguments are - * appended to @a argsOut. - */ -template <class InputIt> -void cmExpandLists(InputIt first, InputIt last, - std::vector<std::string>& argsOut) -{ - cmList::append(argsOut, first, last); -} - /** Concatenate string pieces into a single string. */ std::string cmCatViews( std::initializer_list<std::pair<cm::string_view, std::string*>> views); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 4f14648..74a25ff 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3030,11 +3030,11 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, cmValue& loc, // Track the configuration-specific property suffix. suffix = cmStrCat('_', config_upper); - std::vector<std::string> mappedConfigs; + cmList mappedConfigs; { std::string mapProp = cmStrCat("MAP_IMPORTED_CONFIG_", config_upper); if (cmValue mapValue = this->GetProperty(mapProp)) { - cmExpandList(*mapValue, mappedConfigs, true); + mappedConfigs.assign(*mapValue, cmList::EmptyElements::Yes); } } @@ -3116,9 +3116,9 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, cmValue& loc, // If we have not yet found it then the project is willing to try // any available configuration. if (!loc && !imp) { - std::vector<std::string> availableConfigs; + cmList availableConfigs; if (cmValue iconfigs = this->GetProperty("IMPORTED_CONFIGURATIONS")) { - cmExpandList(*iconfigs, availableConfigs); + availableConfigs.assign(*iconfigs); } for (auto aci = availableConfigs.begin(); !loc && !imp && aci != availableConfigs.end(); ++aci) { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ec6608d..7360bf5 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1094,10 +1094,10 @@ void cmVisualStudio10TargetGenerator::WritePackageReferences(Elem& e0) void cmVisualStudio10TargetGenerator::WriteDotNetReferences(Elem& e0) { - std::vector<std::string> references; + cmList references; if (cmValue vsDotNetReferences = this->GeneratorTarget->GetProperty("VS_DOTNET_REFERENCES")) { - cmExpandList(*vsDotNetReferences, references); + references.assign(*vsDotNetReferences); } cmPropertyMap const& props = this->GeneratorTarget->Target->GetProperties(); for (auto const& i : props.GetList()) { @@ -1114,7 +1114,7 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences(Elem& e0) } if (!references.empty() || !this->DotNetHintReferences.empty()) { Elem e1(e0, "ItemGroup"); - for (std::string const& ri : references) { + for (auto const& ri : references) { // if the entry from VS_DOTNET_REFERENCES is an existing file, generate // a new hint-reference and name it from the filename if (cmsys::SystemTools::FileExists(ri, true)) { @@ -1369,20 +1369,20 @@ void cmVisualStudio10TargetGenerator::WriteTargetsFileReferences(Elem& e1) void cmVisualStudio10TargetGenerator::WriteWinRTReferences(Elem& e0) { - std::vector<std::string> references; + cmList references; if (cmValue vsWinRTReferences = this->GeneratorTarget->GetProperty("VS_WINRT_REFERENCES")) { - cmExpandList(*vsWinRTReferences, references); + references.assign(*vsWinRTReferences); } if (this->GlobalGenerator->TargetsWindowsPhone() && this->GlobalGenerator->GetSystemVersion() == "8.0" && references.empty()) { - references.push_back("platform.winmd"); + references.push_back(std::string{ "platform.winmd" }); } if (!references.empty()) { Elem e1(e0, "ItemGroup"); - for (std::string const& ri : references) { + for (auto const& ri : references) { Elem e2(e1, "Reference"); e2.Attribute("Include", ri); e2.Element("IsWinMDFile", "true"); @@ -4817,13 +4817,13 @@ void cmVisualStudio10TargetGenerator::WriteSinglePlatformExtension( void cmVisualStudio10TargetGenerator::WriteSDKReferences(Elem& e0) { - std::vector<std::string> sdkReferences; + cmList sdkReferences; std::unique_ptr<Elem> spe1; if (cmValue vsSDKReferences = this->GeneratorTarget->GetProperty("VS_SDK_REFERENCES")) { - cmExpandList(*vsSDKReferences, sdkReferences); + sdkReferences.assign(*vsSDKReferences); spe1 = cm::make_unique<Elem>(e0, "ItemGroup"); - for (std::string const& ri : sdkReferences) { + for (auto const& ri : sdkReferences) { Elem(*spe1, "SDKReference").Attribute("Include", ri); } } diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 623478e..0fd7461 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -3141,9 +3141,8 @@ int cmake::CheckBuildSystem() } // If any byproduct of makefile generation is missing we must re-run. - std::vector<std::string> products; - mf.GetDefExpandList("CMAKE_MAKEFILE_PRODUCTS", products); - for (std::string const& p : products) { + cmList products{ mf.GetDefinition("CMAKE_MAKEFILE_PRODUCTS") }; + for (auto const& p : products) { if (!(cmSystemTools::FileExists(p) || cmSystemTools::FileIsSymlink(p))) { if (verbose) { cmSystemTools::Stdout( @@ -3154,10 +3153,10 @@ int cmake::CheckBuildSystem() } // Get the set of dependencies and outputs. - std::vector<std::string> depends; - std::vector<std::string> outputs; - if (mf.GetDefExpandList("CMAKE_MAKEFILE_DEPENDS", depends)) { - mf.GetDefExpandList("CMAKE_MAKEFILE_OUTPUTS", outputs); + cmList depends{ mf.GetDefinition("CMAKE_MAKEFILE_DEPENDS") }; + cmList outputs; + if (!depends.empty()) { + outputs.assign(mf.GetDefinition("CMAKE_MAKEFILE_OUTPUTS")); } if (depends.empty() || outputs.empty()) { // Not enough information was provided to do the test. Just rerun. @@ -3433,19 +3432,18 @@ void cmake::IssueMessage(MessageType t, std::string const& text, std::vector<std::string> cmake::GetDebugConfigs() { - std::vector<std::string> configs; + cmList configs; if (cmValue config_list = this->State->GetGlobalProperty("DEBUG_CONFIGURATIONS")) { // Expand the specified list and convert to upper-case. - cmExpandList(*config_list, configs); - std::transform(configs.begin(), configs.end(), configs.begin(), - cmSystemTools::UpperCase); + configs.assign(*config_list); + configs.transform(cmList::TransformAction::TOUPPER); } // If no configurations were specified, use a default list. if (configs.empty()) { configs.emplace_back("DEBUG"); } - return configs; + return std::move(configs.data()); } int cmake::Build(int jobs, std::string dir, std::vector<std::string> targets, diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index f4d17f8..9929e85 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -559,8 +559,8 @@ struct CoCompileJob int cmcmd::HandleCoCompileCommands(std::vector<std::string> const& args) { std::vector<CoCompileJob> jobs; - std::string sourceFile; // store --source= - std::vector<std::string> launchers; // store --launcher= + std::string sourceFile; // store --source= + cmList launchers; // store --launcher= // Default is to run the original command found after -- if the option // does not need to do that, it should be specified here, currently only @@ -593,7 +593,7 @@ int cmcmd::HandleCoCompileCommands(std::vector<std::string> const& args) if (cmHasLiteralPrefix(arg, "--source=")) { sourceFile = arg.substr(9); } else if (cmHasLiteralPrefix(arg, "--launcher=")) { - cmExpandList(arg.substr(11), launchers, true); + launchers.append(arg.substr(11), cmList::EmptyElements::Yes); } else { // if it was not a co-compiler or --source/--launcher then error std::cerr << "__run_co_compile given unknown argument: " << arg diff --git a/Tests/CMakeLib/testList.cxx b/Tests/CMakeLib/testList.cxx index ff1f278..f6ec720 100644 --- a/Tests/CMakeLib/testList.cxx +++ b/Tests/CMakeLib/testList.cxx @@ -8,7 +8,6 @@ #include <utility> #include <vector> -#include <cm/string_view> #include <cmext/string_view> #include "cmList.h" |