cmExperimental: Expose feature data API

This commit is contained in:
Kyle Edwards
2023-07-17 14:12:10 -04:00
parent a28217eb8c
commit 051cea7b7e
2 changed files with 19 additions and 10 deletions

View File

@@ -18,14 +18,7 @@ namespace {
* Search for other instances to keep the documentation and test suite
* up-to-date.
*/
struct FeatureData
{
std::string const Uuid;
std::string const Variable;
std::string const Description;
bool Warned;
} LookupTable[] = {
cmExperimental::FeatureData LookupTable[] = {
// CxxModuleCMakeApi
{ "bf70d4b0-9fb7-465c-9803-34014e70d112",
"CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API",
@@ -37,17 +30,22 @@ static_assert(sizeof(LookupTable) / sizeof(LookupTable[0]) ==
static_cast<size_t>(cmExperimental::Feature::Sentinel),
"Experimental feature lookup table mismatch");
FeatureData& DataForFeature(cmExperimental::Feature f)
cmExperimental::FeatureData& DataForFeature(cmExperimental::Feature f)
{
assert(f != cmExperimental::Feature::Sentinel);
return LookupTable[static_cast<size_t>(f)];
}
}
const cmExperimental::FeatureData& cmExperimental::DataForFeature(Feature f)
{
return ::DataForFeature(f);
}
bool cmExperimental::HasSupportEnabled(cmMakefile const& mf, Feature f)
{
bool enabled = false;
auto& data = DataForFeature(f);
auto& data = ::DataForFeature(f);
auto value = mf.GetDefinition(data.Variable);
if (value == data.Uuid) {

View File

@@ -5,6 +5,8 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
class cmMakefile;
class cmExperimental
@@ -17,5 +19,14 @@ public:
Sentinel,
};
struct FeatureData
{
std::string const Uuid;
std::string const Variable;
std::string const Description;
bool Warned;
};
static const FeatureData& DataForFeature(Feature f);
static bool HasSupportEnabled(cmMakefile const& mf, Feature f);
};