cmStandardLevelResolver: Add method to get feature standard level

This commit is contained in:
Brad King
2023-10-04 13:59:10 -04:00
parent 99fa01d3fa
commit 7519001ae6
2 changed files with 20 additions and 3 deletions

View File

@@ -349,7 +349,7 @@ struct StandardLevelComputer
}
cm::optional<cmStandardLevel> needed =
this->HighestStandardNeeded(makefile, feature);
this->CompileFeatureStandardLevel(makefile, feature);
cmValue existingStandard = currentLangStandardValue;
if (!existingStandard) {
@@ -437,13 +437,13 @@ struct StandardLevelComputer
}
cm::optional<cmStandardLevel> needed =
this->HighestStandardNeeded(makefile, feature);
this->CompileFeatureStandardLevel(makefile, feature);
return !needed ||
(this->Levels.begin() + needed->Index()) <= existingLevelIter;
}
cm::optional<cmStandardLevel> HighestStandardNeeded(
cm::optional<cmStandardLevel> CompileFeatureStandardLevel(
cmMakefile* makefile, std::string const& feature) const
{
std::string prefix = cmStrCat("CMAKE_", this->Language);
@@ -652,6 +652,17 @@ bool cmStandardLevelResolver::CompileFeatureKnown(
return false;
}
cm::optional<cmStandardLevel>
cmStandardLevelResolver::CompileFeatureStandardLevel(
std::string const& lang, std::string const& feature) const
{
auto mapping = StandardComputerMapping.find(lang);
if (mapping == cm::cend(StandardComputerMapping)) {
return cm::nullopt;
}
return mapping->second.CompileFeatureStandardLevel(this->Makefile, feature);
}
cmValue cmStandardLevelResolver::CompileFeaturesAvailable(
const std::string& lang, std::string* error) const
{

View File

@@ -4,10 +4,13 @@
#include <string>
#include <cm/optional>
#include "cmValue.h"
class cmMakefile;
class cmGeneratorTarget;
class cmStandardLevel;
class cmTarget;
class cmStandardLevelResolver
@@ -33,6 +36,9 @@ public:
const std::string& feature, std::string& lang,
std::string* error) const;
cm::optional<cmStandardLevel> CompileFeatureStandardLevel(
std::string const& lang, std::string const& feature) const;
cmValue CompileFeaturesAvailable(const std::string& lang,
std::string* error) const;