diff options
author | Brad King <brad.king@kitware.com> | 2023-10-04 18:28:45 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-10-04 22:44:18 (GMT) |
commit | 23b57462aa5865d1e526c40dfd0f04f6a4af9e25 (patch) | |
tree | 570352230a1ddd943ced914685e5864bff1d76bd /Source/cmStandardLevelResolver.cxx | |
parent | 7519001ae6cf9da781da465c561870680f3c955d (diff) | |
download | CMake-23b57462aa5865d1e526c40dfd0f04f6a4af9e25.zip CMake-23b57462aa5865d1e526c40dfd0f04f6a4af9e25.tar.gz CMake-23b57462aa5865d1e526c40dfd0f04f6a4af9e25.tar.bz2 |
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.
Diffstat (limited to 'Source/cmStandardLevelResolver.cxx')
-rw-r--r-- | Source/cmStandardLevelResolver.cxx | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/Source/cmStandardLevelResolver.cxx b/Source/cmStandardLevelResolver.cxx index a24d480..4a149e0 100644 --- a/Source/cmStandardLevelResolver.cxx +++ b/Source/cmStandardLevelResolver.cxx @@ -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; |