From e8582abc6d13840b1885abdc0de4ad94b1157c94 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 9 Apr 2024 20:05:19 -0400 Subject: cmExperimental: add support for getting a feature value from its name --- Source/cmExperimental.cxx | 14 ++++++++++++++ Source/cmExperimental.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/Source/cmExperimental.cxx b/Source/cmExperimental.cxx index fb21f53..8adf4e2 100644 --- a/Source/cmExperimental.cxx +++ b/Source/cmExperimental.cxx @@ -54,6 +54,20 @@ const cmExperimental::FeatureData& cmExperimental::DataForFeature(Feature f) return ::DataForFeature(f); } +cm::optional cmExperimental::FeatureByName( + std::string const& name) +{ + size_t idx = 0; + for (auto const& feature : LookupTable) { + if (feature.Name == name) { + return static_cast(idx); + } + ++idx; + } + + return {}; +} + bool cmExperimental::HasSupportEnabled(cmMakefile const& mf, Feature f) { bool enabled = false; diff --git a/Source/cmExperimental.h b/Source/cmExperimental.h index 5593c85..1abfbc3 100644 --- a/Source/cmExperimental.h +++ b/Source/cmExperimental.h @@ -8,6 +8,8 @@ #include #include +#include + class cmMakefile; class cmExperimental @@ -40,5 +42,6 @@ public: }; static const FeatureData& DataForFeature(Feature f); + static cm::optional FeatureByName(std::string const& name); static bool HasSupportEnabled(cmMakefile const& mf, Feature f); }; -- cgit v0.12