diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2023-06-20 14:32:27 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2023-06-22 13:44:17 (GMT) |
commit | 45f17e5a8566fcdec0071a5ed1bc2656968bf258 (patch) | |
tree | d7391fbaa4ab69666ced6dd940892c5c401bcfca /Source | |
parent | 88e7ad0084bd6a2fa6f032d7be1ee5d993440dcf (diff) | |
download | CMake-45f17e5a8566fcdec0071a5ed1bc2656968bf258.zip CMake-45f17e5a8566fcdec0071a5ed1bc2656968bf258.tar.gz CMake-45f17e5a8566fcdec0071a5ed1bc2656968bf258.tar.bz2 |
cmList: Add container conversion to string
Diffstat (limited to 'Source')
33 files changed, 149 insertions, 96 deletions
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index afd85cd..11d90c0 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -1119,8 +1119,8 @@ int cmCPackGenerator::DoPackage() // Run post-build actions cmValue postBuildScripts = this->GetOption("CPACK_POST_BUILD_SCRIPTS"); if (postBuildScripts) { - this->MakefileMap->AddDefinition("CPACK_PACKAGE_FILES", - cmJoin(this->packageFileNames, ";")); + this->MakefileMap->AddDefinition( + "CPACK_PACKAGE_FILES", cmList::to_string(this->packageFileNames)); const cmList scripts{ postBuildScripts }; for (const auto& script : scripts) { diff --git a/Source/CPack/cmCPackNuGetGenerator.cxx b/Source/CPack/cmCPackNuGetGenerator.cxx index 5de8179..aa99fb6 100644 --- a/Source/CPack/cmCPackNuGetGenerator.cxx +++ b/Source/CPack/cmCPackNuGetGenerator.cxx @@ -12,7 +12,7 @@ #include "cmCPackComponentGroup.h" #include "cmCPackLog.h" -#include "cmStringAlgorithms.h" +#include "cmList.h" #include "cmSystemTools.h" #include "cmValue.h" @@ -82,10 +82,10 @@ void cmCPackNuGetGenerator::SetupGroupComponentVariables(bool ignoreGroup) std::back_inserter(components), [](cmCPackComponent const* comp) { return comp->Name; }); this->SetOption("CPACK_NUGET_" + compGUp + "_GROUP_COMPONENTS", - cmJoin(components, ";")); + cmList::to_string(components)); } if (!groups.empty()) { - this->SetOption("CPACK_NUGET_GROUPS", cmJoin(groups, ";")); + this->SetOption("CPACK_NUGET_GROUPS", cmList::to_string(groups)); } // Handle Orphan components (components not belonging to any groups) @@ -103,7 +103,7 @@ void cmCPackNuGetGenerator::SetupGroupComponentVariables(bool ignoreGroup) } } if (!components.empty()) { - this->SetOption("CPACK_NUGET_COMPONENTS", cmJoin(components, ";")); + this->SetOption("CPACK_NUGET_COMPONENTS", cmList::to_string(components)); } } else { @@ -114,7 +114,7 @@ void cmCPackNuGetGenerator::SetupGroupComponentVariables(bool ignoreGroup) [](std::pair<std::string, cmCPackComponent> const& comp) { return comp.first; }); - this->SetOption("CPACK_NUGET_COMPONENTS", cmJoin(components, ";")); + this->SetOption("CPACK_NUGET_COMPONENTS", cmList::to_string(components)); } } diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 90716e6..00c8fa2 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -363,11 +363,11 @@ int main(int argc, char const* const* argv) } if (!expandedPreset->Generators.empty() && generator.empty()) { - generator = cmJoin(expandedPreset->Generators, ";"); + generator = cmList::to_string(expandedPreset->Generators); } if (!expandedPreset->Configurations.empty() && cpackBuildConfig.empty()) { - cpackBuildConfig = cmJoin(expandedPreset->Configurations, ";"); + cpackBuildConfig = cmList::to_string(expandedPreset->Configurations); } definitions.insert(expandedPreset->Variables.begin(), diff --git a/Source/cmAuxSourceDirectoryCommand.cxx b/Source/cmAuxSourceDirectoryCommand.cxx index 35f4c88..b2e3cad 100644 --- a/Source/cmAuxSourceDirectoryCommand.cxx +++ b/Source/cmAuxSourceDirectoryCommand.cxx @@ -11,6 +11,7 @@ #include "cmsys/Directory.hxx" #include "cmExecutionStatus.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmSourceFile.h" #include "cmStringAlgorithms.h" @@ -67,7 +68,7 @@ bool cmAuxSourceDirectoryCommand(std::vector<std::string> const& args, if (!sourceListValue.empty()) { sourceListValue += ";"; } - sourceListValue += cmJoin(files, ";"); + sourceListValue += cmList::to_string(files); mf.AddDefinition(args[1], sourceListValue); return true; } diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx index 1c00f15..81ed41f 100644 --- a/Source/cmCMakeHostSystemInformationCommand.cxx +++ b/Source/cmCMakeHostSystemInformationCommand.cxx @@ -529,12 +529,12 @@ bool QueryWindowsRegistry(Range args, cmExecutionStatus& status, if (arguments.ValueNames) { auto result = registry.GetValueNames(key, view); if (result) { - makefile.AddDefinition(variable, cmJoin(*result, ";"_s)); + makefile.AddDefinition(variable, cmList::to_string(*result)); } } else if (arguments.SubKeys) { auto result = registry.GetSubKeys(key, view); if (result) { - makefile.AddDefinition(variable, cmJoin(*result, ";"_s)); + makefile.AddDefinition(variable, cmList::to_string(*result)); } } else { auto result = diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx index 7fbd826..3b98219 100644 --- a/Source/cmExecuteProcessCommand.cxx +++ b/Source/cmExecuteProcessCommand.cxx @@ -20,6 +20,7 @@ #include "cmArgumentParser.h" #include "cmExecutionStatus.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmProcessOutput.h" @@ -356,7 +357,7 @@ bool cmExecuteProcessCommand(std::vector<std::string> const& args, } } status.GetMakefile().AddDefinition(arguments.ResultsVariable, - cmJoin(res, ";")); + cmList::to_string(res)); } break; case cmsysProcess_State_Exception: status.GetMakefile().AddDefinition( diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index df26bad..8d3960c 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -19,6 +19,7 @@ #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" +#include "cmList.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -237,7 +238,7 @@ void cmExportBuildFileGenerator::SetImportLocationProperty( } // Store the property. - properties[prop] = cmJoin(objects, ";"); + properties[prop] = cmList::to_string(objects); } else { // Add the main target file. { diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 9176d12..481c98f 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -383,7 +383,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( cmGeneratorExpression ge(*target->Makefile->GetCMakeInstance()); std::string dirs = cmGeneratorExpression::Preprocess( - cmJoin(target->Target->GetInstallIncludeDirectoriesEntries(te), ";"), + cmList::to_string(target->Target->GetInstallIncludeDirectoriesEntries(te)), preprocessRule, true); this->ReplaceInstallPrefix(dirs); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 538c883..66cae64 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -19,6 +19,7 @@ #include "cmInstallExportGenerator.h" #include "cmInstallFileSetGenerator.h" #include "cmInstallTargetGenerator.h" +#include "cmList.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -430,7 +431,7 @@ void cmExportInstallFileGenerator::SetImportLocationProperty( } // Store the property. - properties[prop] = cmJoin(objects, ";"); + properties[prop] = cmList::to_string(objects); importedLocations.insert(prop); } else { if (target->IsFrameworkOnApple() && target->HasImportLibrary(config)) { diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index f30c3c3..7e525d5 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -156,12 +156,12 @@ std::string cmExportTryCompileFileGenerator::GetFileSetDirectories( cmGeneratorTarget* /*gte*/, cmFileSet* fileSet, cmTargetExport* /*te*/) { return cmOutputConverter::EscapeForCMake( - cmJoin(fileSet->GetDirectoryEntries(), ";")); + cmList::to_string(fileSet->GetDirectoryEntries())); } std::string cmExportTryCompileFileGenerator::GetFileSetFiles( cmGeneratorTarget* /*gte*/, cmFileSet* fileSet, cmTargetExport* /*te*/) { return cmOutputConverter::EscapeForCMake( - cmJoin(fileSet->GetFileEntries(), ";")); + cmList::to_string(fileSet->GetFileEntries())); } diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 45fba8b..def09fe 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -42,6 +42,7 @@ #include "cmGeneratorExpression.h" #include "cmGlobalGenerator.h" #include "cmHexFileConverter.h" +#include "cmList.h" #include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -805,7 +806,7 @@ bool HandleGlobImpl(std::vector<std::string> const& args, bool recurse, std::sort(files.begin(), files.end()); files.erase(std::unique(files.begin(), files.end()), files.end()); - status.GetMakefile().AddDefinition(variable, cmJoin(files, ";")); + status.GetMakefile().AddDefinition(variable, cmList::to_string(files)); return true; } @@ -1556,7 +1557,7 @@ bool HandlePathCommand(std::vector<std::string> const& args, #endif std::vector<std::string> path = cmSystemTools::SplitString(args[1], pathSep); - std::string value = cmJoin(cmMakeRange(path).transform(convert), ";"); + std::string value = cmList::to_string(cmMakeRange(path).transform(convert)); status.GetMakefile().AddDefinition(args[2], value); return true; } @@ -3157,7 +3158,7 @@ bool HandleGetRuntimeDependenciesCommand(std::vector<std::string> const& args, if (!parsedArgs.RPathPrefix.empty()) { status.GetMakefile().AddDefinition( parsedArgs.RPathPrefix + "_" + firstPath, - cmJoin(archive.GetRPaths().at(firstPath), ";")); + cmList::to_string(archive.GetRPaths().at(firstPath))); } } else if (!parsedArgs.ConflictingDependenciesPrefix.empty()) { conflictingDeps.push_back(val.first); @@ -3165,7 +3166,7 @@ bool HandleGetRuntimeDependenciesCommand(std::vector<std::string> const& args, paths.insert(paths.begin(), val.second.begin(), val.second.end()); std::string varName = parsedArgs.ConflictingDependenciesPrefix + "_" + val.first; - std::string pathsStr = cmJoin(paths, ";"); + std::string pathsStr = cmList::to_string(paths); status.GetMakefile().AddDefinition(varName, pathsStr); } else { std::ostringstream e; @@ -3196,17 +3197,17 @@ bool HandleGetRuntimeDependenciesCommand(std::vector<std::string> const& args, } if (!parsedArgs.ResolvedDependenciesVar.empty()) { - std::string val = cmJoin(deps, ";"); + std::string val = cmList::to_string(deps); status.GetMakefile().AddDefinition(parsedArgs.ResolvedDependenciesVar, val); } if (!parsedArgs.UnresolvedDependenciesVar.empty()) { - std::string val = cmJoin(unresolvedDeps, ";"); + std::string val = cmList::to_string(unresolvedDeps); status.GetMakefile().AddDefinition(parsedArgs.UnresolvedDependenciesVar, val); } if (!parsedArgs.ConflictingDependenciesPrefix.empty()) { - std::string val = cmJoin(conflictingDeps, ";"); + std::string val = cmList::to_string(conflictingDeps); status.GetMakefile().AddDefinition( parsedArgs.ConflictingDependenciesPrefix + "_FILENAMES", val); } diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index f4768b6..8d2d972 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -11,6 +11,7 @@ #include "cmExecutionStatus.h" #include "cmFunctionBlocker.h" +#include "cmList.h" #include "cmListFileCache.h" #include "cmMakefile.h" #include "cmPolicies.h" @@ -89,9 +90,9 @@ bool cmFunctionHelperCommand::operator()( } // define ARGV and ARGN - auto const argvDef = cmJoin(expandedArgs, ";"); + auto const argvDef = cmList::to_string(expandedArgs); auto const eit = expandedArgs.begin() + (this->Args.size() - 1); - auto const argnDef = cmJoin(cmMakeRange(eit, expandedArgs.end()), ";"); + auto const argnDef = cmList::to_string(cmMakeRange(eit, expandedArgs.end())); makefile.AddDefinition(ARGV, argvDef); makefile.MarkVariableAsUsed(ARGV); makefile.AddDefinition(ARGN, argnDef); diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index bb4fc7e..647c62d 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -2538,7 +2538,7 @@ static const struct LinkLibraryNode : public cmGeneratorExpressionNode list.front() = LL_BEGIN; list.push_back(LL_END); - return cmJoin(list, ";"_s); + return list.to_string(); } } linkLibraryNode; @@ -2607,7 +2607,7 @@ static const struct LinkGroupNode : public cmGeneratorExpressionNode list.front() = LG_BEGIN; list.push_back(LG_END); - return cmJoin(list, ";"_s); + return list.to_string(); } } linkGroupNode; @@ -2632,7 +2632,7 @@ static const struct HostLinkNode : public cmGeneratorExpressionNode } return context->HeadTarget->IsDeviceLink() ? std::string() - : cmJoin(parameters, ";"); + : cmList::to_string(parameters); } } hostLinkNode; @@ -2667,7 +2667,7 @@ static const struct DeviceLinkNode : public cmGeneratorExpressionNode list.insert(list.begin(), static_cast<std::string>(DL_BEGIN)); list.push_back(static_cast<std::string>(DL_END)); - return cmJoin(list, ";"); + return list.to_string(); } return std::string(); @@ -3104,7 +3104,7 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode mf->AddTargetObject(tgtName, o); } - return cmJoin(objects, ";"); + return objects.to_string(); } } targetObjectsNode; @@ -3164,7 +3164,7 @@ static const struct TargetRuntimeDllsNode : public TargetRuntimeDllsBaseNode cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override { std::vector<std::string> dlls = CollectDlls(parameters, context, content); - return cmJoin(dlls, ";"); + return cmList::to_string(dlls); } } targetRuntimeDllsNode; @@ -3187,7 +3187,7 @@ static const struct TargetRuntimeDllDirsNode : public TargetRuntimeDllsBaseNode dllDirs.push_back(directory); } } - return cmJoin(dllDirs, ";"); + return cmList::to_string(dllDirs); } } targetRuntimeDllDirsNode; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 357d0a6..1148386 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -190,7 +190,7 @@ public: } static std::string filesStr; - filesStr = cmJoin(files, ";"); + filesStr = cmList::to_string(files); return filesStr; } @@ -322,8 +322,7 @@ cmValue cmGeneratorTarget::GetSourcesProperty() const values.push_back(se->GetInput()); } static std::string value; - value.clear(); - value = cmJoin(values, ";"); + value = cmList::to_string(values); return cmValue(value); } diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx index 42bd206..d2c4fd6 100644 --- a/Source/cmGetCMakePropertyCommand.cxx +++ b/Source/cmGetCMakePropertyCommand.cxx @@ -6,9 +6,9 @@ #include "cmExecutionStatus.h" #include "cmGlobalGenerator.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmState.h" -#include "cmStringAlgorithms.h" #include "cmValue.h" // cmGetCMakePropertyCommand @@ -35,7 +35,7 @@ bool cmGetCMakePropertyCommand(std::vector<std::string> const& args, } else if (args[1] == "COMPONENTS") { const std::set<std::string>* components = status.GetMakefile().GetGlobalGenerator()->GetInstallComponents(); - output = cmJoin(*components, ";"); + output = cmList::to_string(*components); } else { cmValue prop = nullptr; if (!args[1].empty()) { diff --git a/Source/cmLinkDirectoriesCommand.cxx b/Source/cmLinkDirectoriesCommand.cxx index 1ec071b..6775a60 100644 --- a/Source/cmLinkDirectoriesCommand.cxx +++ b/Source/cmLinkDirectoriesCommand.cxx @@ -6,6 +6,7 @@ #include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmPolicies.h" @@ -39,7 +40,7 @@ bool cmLinkDirectoriesCommand(std::vector<std::string> const& args, AddLinkDir(mf, *i, directories); } - mf.AddLinkDirectory(cmJoin(directories, ";"), before); + mf.AddLinkDirectory(cmList::to_string(directories), before); return true; } diff --git a/Source/cmList.cxx b/Source/cmList.cxx index 022fcd2..3835e59 100644 --- a/Source/cmList.cxx +++ b/Source/cmList.cxx @@ -19,6 +19,7 @@ #include "cmAlgorithms.h" #include "cmGeneratorExpression.h" +#include "cmListFileCache.h" #include "cmRange.h" #include "cmStringAlgorithms.h" #include "cmStringReplaceHelper.h" @@ -802,11 +803,6 @@ cmList& cmList::transform(TransformAction action, return *this; } -std::string cmList::join(cm::string_view glue) const -{ - return cmJoin(this->Values, glue); -} - std::string& cmList::append(std::string& list, cm::string_view value) { if (list.empty()) { @@ -1001,3 +997,8 @@ cmList::container_type::iterator cmList::Insert( } return container.begin() + delta; } + +std::string const& cmList::ToString(BT<std::string> const& s) +{ + return s.Value; +} diff --git a/Source/cmList.h b/Source/cmList.h index eba0400..9ee4a46 100644 --- a/Source/cmList.h +++ b/Source/cmList.h @@ -22,6 +22,9 @@ #include "cmValue.h" +template <typename T> +class BT; + /** * CMake lists management * A CMake list is a string where list elements are separated by the ';' @@ -936,7 +939,10 @@ public: std::vector<std::string> const& args, std::unique_ptr<TransformSelector> = {}); - std::string join(cm::string_view glue) const; + std::string join(cm::string_view glue) const + { + return cmList::Join(this->Values, glue); + } void swap(cmList& other) noexcept { this->Values.swap(other.Values); } @@ -1092,8 +1098,8 @@ public: return cmList::append(list, cm::string_view{ std::accumulate( std::next(first), last, *first, - [](std::string a, const std::string& b) { - return std::move(a) + + [](const std::string& a, const std::string& b) { + return a + std::string(cmList::element_separator) + b; }) }); } @@ -1116,6 +1122,13 @@ public: }) }); } + template <typename Range, + cm::enable_if_t<cm::is_range<Range>::value, int> = 0> + static std::string to_string(Range const& r) + { + return cmList::Join(r, cmList::element_separator); + } + // Non-members // =========== friend inline bool operator==(const cmList& lhs, const cmList& rhs) noexcept @@ -1185,6 +1198,28 @@ private: return container.begin() + delta; } + static std::string const& ToString(std::string const& s) { return s; } + static std::string ToString(cm::string_view s) { return std::string{ s }; } + static std::string const& ToString(BT<std::string> const&); + + template <typename Range> + static std::string Join(Range const& r, cm::string_view glue) + { + if (cm::size(r) == 0) { + return std::string{}; + } + + const auto sep = std::string{ glue }; + + return std::accumulate( + std::next(std::begin(r)), std::end(r), cmList::ToString(*std::begin(r)), + [&sep](std::string const& a, + typename std::iterator_traits<decltype(std::begin( + r))>::value_type const& b) -> std::string { + return a + sep + cmList::ToString(b); + }); + } + container_type Values; }; diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 47ad749..3d7cd8b 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -12,6 +12,7 @@ #include "cmExecutionStatus.h" #include "cmFunctionBlocker.h" +#include "cmList.h" #include "cmListFileCache.h" #include "cmMakefile.h" #include "cmPolicies.h" @@ -66,8 +67,9 @@ bool cmMacroHelperCommand::operator()( std::string argcDef = std::to_string(expandedArgs.size()); auto eit = expandedArgs.begin() + (this->Args.size() - 1); - std::string expandedArgn = cmJoin(cmMakeRange(eit, expandedArgs.end()), ";"); - std::string expandedArgv = cmJoin(expandedArgs, ";"); + std::string expandedArgn = + cmList::to_string(cmMakeRange(eit, expandedArgs.end())); + std::string expandedArgv = cmList::to_string(expandedArgs); std::vector<std::string> variables; variables.reserve(this->Args.size() - 1); for (unsigned int j = 1; j < this->Args.size(); ++j) { diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index c3c8d46..5890819 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1980,7 +1980,7 @@ void cmMakefile::AddIncludeDirectories(const std::vector<std::string>& incs, return; } - std::string entryString = cmJoin(incs, ";"); + std::string entryString = cmList::to_string(incs); if (before) { this->StateSnapshot.GetDirectory().PrependIncludeDirectoriesEntry( BT<std::string>(entryString, this->Backtrace)); @@ -3004,12 +3004,11 @@ cm::optional<std::string> cmMakefile::DeferGetCallIds() const { cm::optional<std::string> ids; if (this->Defer) { - ids = cmJoin( + ids = cmList::to_string( cmMakeRange(this->Defer->Commands) .filter([](DeferCommand const& dc) -> bool { return !dc.Id.empty(); }) .transform( - [](DeferCommand const& dc) -> std::string const& { return dc.Id; }), - ";"); + [](DeferCommand const& dc) -> std::string const& { return dc.Id; })); } return ids; } @@ -4160,7 +4159,7 @@ cmValue cmMakefile::GetProperty(const std::string& prop) const std::transform( t->Tests.begin(), t->Tests.end(), std::back_inserter(keys), [](decltype(t->Tests)::value_type const& pair) { return pair.first; }); - output = cmJoin(keys, ";"); + output = cmList::to_string(keys); return cmValue(output); } diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx index b0462f0..f193ed9 100644 --- a/Source/cmParseArgumentsCommand.cxx +++ b/Source/cmParseArgumentsCommand.cxx @@ -20,7 +20,9 @@ #include "cmSystemTools.h" #include "cmValue.h" -static std::string EscapeArg(const std::string& arg) +namespace { + +std::string EscapeArg(const std::string& arg) { // replace ";" with "\;" so output argument lists will split correctly std::string escapedArg; @@ -33,14 +35,12 @@ static std::string EscapeArg(const std::string& arg) return escapedArg; } -static std::string JoinList(std::vector<std::string> const& arg, bool escape) +std::string JoinList(std::vector<std::string> const& arg, bool escape) { - return escape ? cmJoin(cmMakeRange(arg).transform(EscapeArg), ";") - : cmJoin(cmMakeRange(arg), ";"); + return escape ? cmList::to_string(cmMakeRange(arg).transform(EscapeArg)) + : cmList::to_string(cmMakeRange(arg)); } -namespace { - using options_map = std::map<std::string, bool>; using single_map = std::map<std::string, std::string>; using multi_map = @@ -108,8 +108,9 @@ static void PassParsedArguments( } if (!keywordsMissingValues.empty()) { - makefile.AddDefinition(prefix + "KEYWORDS_MISSING_VALUES", - cmJoin(cmMakeRange(keywordsMissingValues), ";")); + makefile.AddDefinition( + prefix + "KEYWORDS_MISSING_VALUES", + cmList::to_string(cmMakeRange(keywordsMissingValues))); } else { makefile.RemoveDefinition(prefix + "KEYWORDS_MISSING_VALUES"); } diff --git a/Source/cmSeparateArgumentsCommand.cxx b/Source/cmSeparateArgumentsCommand.cxx index 17285e7..3576e4f 100644 --- a/Source/cmSeparateArgumentsCommand.cxx +++ b/Source/cmSeparateArgumentsCommand.cxx @@ -9,6 +9,7 @@ #include "cmArgumentParser.h" #include "cmExecutionStatus.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmRange.h" #include "cmStringAlgorithms.h" @@ -159,7 +160,7 @@ bool cmSeparateArgumentsCommand(std::vector<std::string> const& args, pos += 2; } }); - auto value = cmJoin(values, ";"); + auto value = cmList::to_string(values); status.GetMakefile().AddDefinition(var, value); return true; diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index 040eb08..c4bb949 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -3,6 +3,7 @@ #include "cmSetCommand.h" #include "cmExecutionStatus.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmRange.h" @@ -103,7 +104,8 @@ bool cmSetCommand(std::vector<std::string> const& args, } // collect any values into a single semi-colon separated value list - value = cmJoin(cmMakeRange(args).advance(1).retreat(ignoreLastArgs), ";"); + value = + cmList::to_string(cmMakeRange(args).advance(1).retreat(ignoreLastArgs)); if (parentScope) { status.GetMakefile().RaiseScope(variable, value.c_str()); diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 3403745..1be680a 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -8,6 +8,7 @@ #include <cmext/string_view> #include "cmGlobalGenerator.h" +#include "cmList.h" #include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -390,7 +391,7 @@ cmValue cmSourceFile::GetProperty(const std::string& prop) const } static std::string output; - output = cmJoin(this->IncludeDirectories, ";"); + output = cmList::to_string(this->IncludeDirectories); return cmValue(output); } @@ -400,7 +401,7 @@ cmValue cmSourceFile::GetProperty(const std::string& prop) const } static std::string output; - output = cmJoin(this->CompileOptions, ";"); + output = cmList::to_string(this->CompileOptions); return cmValue(output); } @@ -410,7 +411,7 @@ cmValue cmSourceFile::GetProperty(const std::string& prop) const } static std::string output; - output = cmJoin(this->CompileDefinitions, ";"); + output = cmList::to_string(this->CompileDefinitions); return cmValue(output); } diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 2596d8c..d41e8e5 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -17,6 +17,7 @@ #include "cmDefinitions.h" #include "cmExecutionStatus.h" #include "cmGlobVerificationManager.h" +#include "cmList.h" #include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -584,10 +585,10 @@ cmValue cmState::GetGlobalProperty(const std::string& prop) { if (prop == "CACHE_VARIABLES") { std::vector<std::string> cacheKeys = this->GetCacheEntryKeys(); - this->SetGlobalProperty("CACHE_VARIABLES", cmJoin(cacheKeys, ";")); + this->SetGlobalProperty("CACHE_VARIABLES", cmList::to_string(cacheKeys)); } else if (prop == "COMMANDS") { std::vector<std::string> commands = this->GetCommandNames(); - this->SetGlobalProperty("COMMANDS", cmJoin(commands, ";")); + this->SetGlobalProperty("COMMANDS", cmList::to_string(commands)); } else if (prop == "IN_TRY_COMPILE") { this->SetGlobalProperty( "IN_TRY_COMPILE", @@ -596,8 +597,7 @@ cmValue cmState::GetGlobalProperty(const std::string& prop) this->SetGlobalProperty("GENERATOR_IS_MULTI_CONFIG", this->IsGeneratorMultiConfig ? "1" : "0"); } else if (prop == "ENABLED_LANGUAGES") { - std::string langs; - langs = cmJoin(this->EnabledLanguages, ";"); + auto langs = cmList::to_string(this->EnabledLanguages); this->SetGlobalProperty("ENABLED_LANGUAGES", langs); } else if (prop == "CMAKE_ROLE") { std::string mode = this->GetModeString(); diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx index 6e6fcbd..39353f3 100644 --- a/Source/cmStateDirectory.cxx +++ b/Source/cmStateDirectory.cxx @@ -13,6 +13,7 @@ #include <cmext/string_view> #include "cmAlgorithms.h" +#include "cmList.h" #include "cmListFileCache.h" #include "cmProperty.h" #include "cmPropertyMap.h" @@ -20,7 +21,6 @@ #include "cmState.h" #include "cmStatePrivate.h" #include "cmStateTypes.h" -#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmValue.h" @@ -381,15 +381,15 @@ cmValue cmStateDirectory::GetProperty(const std::string& prop, for (cmStateSnapshot const& ci : children) { child_dirs.push_back(ci.GetDirectory().GetCurrentSource()); } - output = cmJoin(child_dirs, ";"); + output = cmList::to_string(child_dirs); return cmValue(output); } if (prop == kBUILDSYSTEM_TARGETS) { - output = cmJoin(this->DirectoryState->NormalTargetNames, ";"); + output = cmList::to_string(this->DirectoryState->NormalTargetNames); return cmValue(output); } if (prop == "IMPORTED_TARGETS"_s) { - output = cmJoin(this->DirectoryState->ImportedTargetNames, ";"); + output = cmList::to_string(this->DirectoryState->ImportedTargetNames); return cmValue(output); } @@ -401,38 +401,38 @@ cmValue cmStateDirectory::GetProperty(const std::string& prop, snp = snp.GetCallStackParent(); } std::reverse(listFiles.begin(), listFiles.end()); - output = cmJoin(listFiles, ";"); + output = cmList::to_string(listFiles); return cmValue(output); } if (prop == "CACHE_VARIABLES") { - output = cmJoin(this->Snapshot_.State->GetCacheEntryKeys(), ";"); + output = cmList::to_string(this->Snapshot_.State->GetCacheEntryKeys()); return cmValue(output); } if (prop == "VARIABLES") { std::vector<std::string> res = this->Snapshot_.ClosureKeys(); cm::append(res, this->Snapshot_.State->GetCacheEntryKeys()); std::sort(res.begin(), res.end()); - output = cmJoin(res, ";"); + output = cmList::to_string(res); return cmValue(output); } if (prop == "INCLUDE_DIRECTORIES") { - output = cmJoin(this->GetIncludeDirectoriesEntries(), ";"); + output = cmList::to_string(this->GetIncludeDirectoriesEntries()); return cmValue(output); } if (prop == "COMPILE_OPTIONS") { - output = cmJoin(this->GetCompileOptionsEntries(), ";"); + output = cmList::to_string(this->GetCompileOptionsEntries()); return cmValue(output); } if (prop == "COMPILE_DEFINITIONS") { - output = cmJoin(this->GetCompileDefinitionsEntries(), ";"); + output = cmList::to_string(this->GetCompileDefinitionsEntries()); return cmValue(output); } if (prop == "LINK_OPTIONS") { - output = cmJoin(this->GetLinkOptionsEntries(), ";"); + output = cmList::to_string(this->GetLinkOptionsEntries()); return cmValue(output); } if (prop == "LINK_DIRECTORIES") { - output = cmJoin(this->GetLinkDirectoriesEntries(), ";"); + output = cmList::to_string(this->GetLinkDirectoriesEntries()); return cmValue(output); } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 81497f5..15f45f5 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -811,12 +811,12 @@ std::pair<bool, cmValue> FileSetType::ReadProperties( did_read = true; } else if (prop == this->SelfEntries.PropertyName) { static std::string output; - output = cmJoin(this->SelfEntries.Entries, ";"_s); + output = cmList::to_string(this->SelfEntries.Entries); value = cmValue(output); did_read = true; } else if (prop == this->InterfaceEntries.PropertyName) { static std::string output; - output = cmJoin(this->InterfaceEntries.Entries, ";"_s); + output = cmList::to_string(this->InterfaceEntries.Entries); value = cmValue(output); did_read = true; } else if (cmHasPrefix(prop, this->DirectoryPrefix)) { @@ -899,7 +899,7 @@ std::pair<bool, cmValue> UsageRequirementProperty::Read( if (!this->Entries.empty()) { // Storage to back the returned `cmValue`. static std::string output; - output = cmJoin(this->Entries, ";"); + output = cmList::to_string(this->Entries); value = cmValue(output); } did_read = true; @@ -2130,7 +2130,7 @@ cmValue cmTargetInternals::GetFileSetDirectories( return nullptr; } static std::string output; - output = cmJoin(fileSet->GetDirectoryEntries(), ";"_s); + output = cmList::to_string(fileSet->GetDirectoryEntries()); return cmValue(output); } @@ -2150,7 +2150,7 @@ cmValue cmTargetInternals::GetFileSetPaths(cmTarget const* self, return nullptr; } static std::string output; - output = cmJoin(fileSet->GetFileEntries(), ";"_s); + output = cmList::to_string(fileSet->GetFileEntries()); return cmValue(output); } @@ -2495,7 +2495,7 @@ cmValue cmTarget::GetProperty(const std::string& prop) const [](const BT<std::pair<std::string, bool>>& item) -> std::string { return item.Value.first; }); - output = cmJoin(utilities, ";"); + output = cmList::to_string(utilities); return cmValue(output); } if (prop == propIMPORTED) { diff --git a/Source/cmTargetCompileFeaturesCommand.cxx b/Source/cmTargetCompileFeaturesCommand.cxx index aa1abdd..37c125b 100644 --- a/Source/cmTargetCompileFeaturesCommand.cxx +++ b/Source/cmTargetCompileFeaturesCommand.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTargetCompileFeaturesCommand.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmStandardLevelResolver.h" @@ -43,7 +44,7 @@ private: std::string Join(const std::vector<std::string>& content) override { - return cmJoin(content, ";"); + return cmList::to_string(content); } }; diff --git a/Source/cmTargetCompileOptionsCommand.cxx b/Source/cmTargetCompileOptionsCommand.cxx index 8ca3842..e73a75f 100644 --- a/Source/cmTargetCompileOptionsCommand.cxx +++ b/Source/cmTargetCompileOptionsCommand.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTargetCompileOptionsCommand.h" +#include "cmList.h" #include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -44,7 +45,7 @@ private: std::string Join(const std::vector<std::string>& content) override { - return cmJoin(content, ";"); + return cmList::to_string(content); } }; diff --git a/Source/cmTargetLinkDirectoriesCommand.cxx b/Source/cmTargetLinkDirectoriesCommand.cxx index 3ba27a8..dddb348 100644 --- a/Source/cmTargetLinkDirectoriesCommand.cxx +++ b/Source/cmTargetLinkDirectoriesCommand.cxx @@ -3,6 +3,7 @@ #include "cmTargetLinkDirectoriesCommand.h" #include "cmGeneratorExpression.h" +#include "cmList.h" #include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -58,7 +59,7 @@ std::string TargetLinkDirectoriesImpl::Join( directories.push_back(unixPath); } - return cmJoin(directories, ";"); + return cmList::to_string(directories); } } // namespace diff --git a/Source/cmTargetLinkOptionsCommand.cxx b/Source/cmTargetLinkOptionsCommand.cxx index 3ea2d71..cd93835 100644 --- a/Source/cmTargetLinkOptionsCommand.cxx +++ b/Source/cmTargetLinkOptionsCommand.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTargetLinkOptionsCommand.h" +#include "cmList.h" #include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -36,7 +37,7 @@ private: std::string Join(const std::vector<std::string>& content) override { - return cmJoin(content, ";"); + return cmList::to_string(content); } }; diff --git a/Source/cmTargetPrecompileHeadersCommand.cxx b/Source/cmTargetPrecompileHeadersCommand.cxx index 4dd158d..0173a92 100644 --- a/Source/cmTargetPrecompileHeadersCommand.cxx +++ b/Source/cmTargetPrecompileHeadersCommand.cxx @@ -5,6 +5,7 @@ #include <utility> #include "cmGeneratorExpression.h" +#include "cmList.h" #include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -73,7 +74,7 @@ private: std::string Join(const std::vector<std::string>& content) override { - return cmJoin(content, ";"); + return cmList::to_string(content); } }; diff --git a/Source/cmTargetSourcesCommand.cxx b/Source/cmTargetSourcesCommand.cxx index 12328b1..3d484f5 100644 --- a/Source/cmTargetSourcesCommand.cxx +++ b/Source/cmTargetSourcesCommand.cxx @@ -98,7 +98,7 @@ private: std::string Join(const std::vector<std::string>& content) override { - return cmJoin(content, ";"); + return cmList::to_string(content); } enum class IsInterface |