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
+14 -3
View File
@@ -349,7 +349,7 @@ struct StandardLevelComputer
} }
cm::optional<cmStandardLevel> needed = cm::optional<cmStandardLevel> needed =
this->HighestStandardNeeded(makefile, feature); this->CompileFeatureStandardLevel(makefile, feature);
cmValue existingStandard = currentLangStandardValue; cmValue existingStandard = currentLangStandardValue;
if (!existingStandard) { if (!existingStandard) {
@@ -437,13 +437,13 @@ struct StandardLevelComputer
} }
cm::optional<cmStandardLevel> needed = cm::optional<cmStandardLevel> needed =
this->HighestStandardNeeded(makefile, feature); this->CompileFeatureStandardLevel(makefile, feature);
return !needed || return !needed ||
(this->Levels.begin() + needed->Index()) <= existingLevelIter; (this->Levels.begin() + needed->Index()) <= existingLevelIter;
} }
cm::optional<cmStandardLevel> HighestStandardNeeded( cm::optional<cmStandardLevel> CompileFeatureStandardLevel(
cmMakefile* makefile, std::string const& feature) const cmMakefile* makefile, std::string const& feature) const
{ {
std::string prefix = cmStrCat("CMAKE_", this->Language); std::string prefix = cmStrCat("CMAKE_", this->Language);
@@ -652,6 +652,17 @@ bool cmStandardLevelResolver::CompileFeatureKnown(
return false; 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( cmValue cmStandardLevelResolver::CompileFeaturesAvailable(
const std::string& lang, std::string* error) const const std::string& lang, std::string* error) const
{ {
+6
View File
@@ -4,10 +4,13 @@
#include <string> #include <string>
#include <cm/optional>
#include "cmValue.h" #include "cmValue.h"
class cmMakefile; class cmMakefile;
class cmGeneratorTarget; class cmGeneratorTarget;
class cmStandardLevel;
class cmTarget; class cmTarget;
class cmStandardLevelResolver class cmStandardLevelResolver
@@ -33,6 +36,9 @@ public:
const std::string& feature, std::string& lang, const std::string& feature, std::string& lang,
std::string* error) const; std::string* error) const;
cm::optional<cmStandardLevel> CompileFeatureStandardLevel(
std::string const& lang, std::string const& feature) const;
cmValue CompileFeaturesAvailable(const std::string& lang, cmValue CompileFeaturesAvailable(const std::string& lang,
std::string* error) const; std::string* error) const;