mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 08:20:18 -06:00
cmStandardLevelResolver: Report feature std level from GetNewRequiredStandard
Regardless of whether the feature requires a new (higher) standard level, always report the standard level that the feature needs.
This commit is contained in:
@@ -50,6 +50,7 @@
|
||||
#include "cmSourceFileLocation.h"
|
||||
#include "cmSourceFileLocationKind.h"
|
||||
#include "cmSourceGroup.h"
|
||||
#include "cmStandardLevel.h"
|
||||
#include "cmStandardLevelResolver.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
@@ -5039,10 +5040,11 @@ bool cmGeneratorTarget::ComputeCompileFeatures(std::string const& config) const
|
||||
std::string key = cmStrCat(cmSystemTools::UpperCase(config), '-', lang);
|
||||
cmValue currentLanguageStandard = this->GetLanguageStandard(lang, config);
|
||||
|
||||
cm::optional<cmStandardLevel> featureLevel;
|
||||
std::string newRequiredStandard;
|
||||
if (!standardResolver.GetNewRequiredStandard(
|
||||
this->Target->GetName(), f.Value, currentLanguageStandard,
|
||||
newRequiredStandard)) {
|
||||
featureLevel, newRequiredStandard)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -337,7 +337,7 @@ struct StandardLevelComputer
|
||||
|
||||
bool GetNewRequiredStandard(cmMakefile* makefile,
|
||||
std::string const& targetName,
|
||||
const std::string& feature,
|
||||
cm::optional<cmStandardLevel> featureLevel,
|
||||
cmValue currentLangStandardValue,
|
||||
std::string& newRequiredStandard,
|
||||
std::string* error) const
|
||||
@@ -348,9 +348,6 @@ struct StandardLevelComputer
|
||||
newRequiredStandard.clear();
|
||||
}
|
||||
|
||||
cm::optional<cmStandardLevel> needed =
|
||||
this->CompileFeatureStandardLevel(makefile, feature);
|
||||
|
||||
cmValue existingStandard = currentLangStandardValue;
|
||||
if (!existingStandard) {
|
||||
cmValue defaultStandard = makefile->GetDefinition(
|
||||
@@ -379,12 +376,12 @@ struct StandardLevelComputer
|
||||
}
|
||||
}
|
||||
|
||||
if (needed) {
|
||||
if (featureLevel) {
|
||||
// Ensure the C++ language level is high enough to support
|
||||
// the needed C++ features.
|
||||
if (existingLevelIter == cm::cend(this->Levels) ||
|
||||
existingLevelIter < this->Levels.begin() + needed->Index()) {
|
||||
newRequiredStandard = this->LevelsAsStrings[needed->Index()];
|
||||
existingLevelIter < this->Levels.begin() + featureLevel->Index()) {
|
||||
newRequiredStandard = this->LevelsAsStrings[featureLevel->Index()];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -550,11 +547,12 @@ bool cmStandardLevelResolver::AddRequiredTargetFeature(
|
||||
// should be done purely at generate time based on whatever the project
|
||||
// code put in these properties explicitly. That is mostly true now,
|
||||
// but for compatibility we need to continue updating the property here.
|
||||
cm::optional<cmStandardLevel> featureLevel;
|
||||
std::string newRequiredStandard;
|
||||
bool succeeded = this->GetNewRequiredStandard(
|
||||
target->GetName(), feature,
|
||||
target->GetProperty(cmStrCat(lang, "_STANDARD")), newRequiredStandard,
|
||||
error);
|
||||
target->GetProperty(cmStrCat(lang, "_STANDARD")), featureLevel,
|
||||
newRequiredStandard, error);
|
||||
if (!newRequiredStandard.empty()) {
|
||||
target->SetProperty(cmStrCat(lang, "_STANDARD"), newRequiredStandard);
|
||||
}
|
||||
@@ -711,18 +709,21 @@ cmValue cmStandardLevelResolver::CompileFeaturesAvailable(
|
||||
|
||||
bool cmStandardLevelResolver::GetNewRequiredStandard(
|
||||
const std::string& targetName, const std::string& feature,
|
||||
cmValue currentLangStandardValue, std::string& newRequiredStandard,
|
||||
std::string* error) const
|
||||
cmValue currentLangStandardValue,
|
||||
cm::optional<cmStandardLevel>& featureLevel,
|
||||
std::string& newRequiredStandard, std::string* error) const
|
||||
{
|
||||
std::string lang;
|
||||
if (!this->CheckCompileFeaturesAvailable(targetName, feature, lang, error)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
featureLevel = this->CompileFeatureStandardLevel(lang, feature);
|
||||
|
||||
auto mapping = StandardComputerMapping.find(lang);
|
||||
if (mapping != cm::cend(StandardComputerMapping)) {
|
||||
return mapping->second.GetNewRequiredStandard(
|
||||
this->Makefile, targetName, feature, currentLangStandardValue,
|
||||
this->Makefile, targetName, featureLevel, currentLangStandardValue,
|
||||
newRequiredStandard, error);
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -45,6 +45,7 @@ public:
|
||||
bool GetNewRequiredStandard(const std::string& targetName,
|
||||
const std::string& feature,
|
||||
cmValue currentLangStandardValue,
|
||||
cm::optional<cmStandardLevel>& featureLevel,
|
||||
std::string& newRequiredStandard,
|
||||
std::string* error = nullptr) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user