mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-12 09:08:58 -05:00
cmGeneratorTarget: Track explicitly enabled language standard levels
Previously we only tracked when an explicit setting requires the standard level to be higher than the compiler's default.
This commit is contained in:
@@ -5025,10 +5025,44 @@ void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cm::optional<cmStandardLevel> cmGeneratorTarget::GetExplicitStandardLevel(
|
||||||
|
std::string const& lang, std::string const& config) const
|
||||||
|
{
|
||||||
|
cm::optional<cmStandardLevel> level;
|
||||||
|
std::string key = cmStrCat(cmSystemTools::UpperCase(config), '-', lang);
|
||||||
|
auto i = this->ExplicitStandardLevel.find(key);
|
||||||
|
if (i != this->ExplicitStandardLevel.end()) {
|
||||||
|
level = i->second;
|
||||||
|
}
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmGeneratorTarget::UpdateExplicitStandardLevel(std::string const& lang,
|
||||||
|
std::string const& config,
|
||||||
|
cmStandardLevel level)
|
||||||
|
{
|
||||||
|
auto e = this->ExplicitStandardLevel.emplace(
|
||||||
|
cmStrCat(cmSystemTools::UpperCase(config), '-', lang), level);
|
||||||
|
if (!e.second && e.first->second < level) {
|
||||||
|
e.first->second = level;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool cmGeneratorTarget::ComputeCompileFeatures(std::string const& config)
|
bool cmGeneratorTarget::ComputeCompileFeatures(std::string const& config)
|
||||||
{
|
{
|
||||||
// Compute the language standard based on the compile features.
|
|
||||||
cmStandardLevelResolver standardResolver(this->Makefile);
|
cmStandardLevelResolver standardResolver(this->Makefile);
|
||||||
|
|
||||||
|
for (std::string const& lang :
|
||||||
|
this->Makefile->GetState()->GetEnabledLanguages()) {
|
||||||
|
if (cmValue languageStd = this->GetLanguageStandard(lang, config)) {
|
||||||
|
if (cm::optional<cmStandardLevel> langLevel =
|
||||||
|
standardResolver.LanguageStandardLevel(lang, *languageStd)) {
|
||||||
|
this->UpdateExplicitStandardLevel(lang, config, *langLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute the language standard based on the compile features.
|
||||||
std::vector<BT<std::string>> features = this->GetCompileFeatures(config);
|
std::vector<BT<std::string>> features = this->GetCompileFeatures(config);
|
||||||
for (BT<std::string> const& f : features) {
|
for (BT<std::string> const& f : features) {
|
||||||
std::string lang;
|
std::string lang;
|
||||||
@@ -5048,6 +5082,10 @@ bool cmGeneratorTarget::ComputeCompileFeatures(std::string const& config)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (featureLevel) {
|
||||||
|
this->UpdateExplicitStandardLevel(lang, config, *featureLevel);
|
||||||
|
}
|
||||||
|
|
||||||
if (!newRequiredStandard.empty()) {
|
if (!newRequiredStandard.empty()) {
|
||||||
BTs<std::string>& languageStandardProperty =
|
BTs<std::string>& languageStandardProperty =
|
||||||
this->LanguageStandardMap[key];
|
this->LanguageStandardMap[key];
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "cmLinkItem.h"
|
#include "cmLinkItem.h"
|
||||||
#include "cmListFileCache.h"
|
#include "cmListFileCache.h"
|
||||||
#include "cmPolicies.h"
|
#include "cmPolicies.h"
|
||||||
|
#include "cmStandardLevel.h"
|
||||||
#include "cmStateTypes.h"
|
#include "cmStateTypes.h"
|
||||||
#include "cmValue.h"
|
#include "cmValue.h"
|
||||||
|
|
||||||
@@ -1242,6 +1243,13 @@ private:
|
|||||||
|
|
||||||
std::map<std::string, BTs<std::string>> LanguageStandardMap;
|
std::map<std::string, BTs<std::string>> LanguageStandardMap;
|
||||||
|
|
||||||
|
cm::optional<cmStandardLevel> GetExplicitStandardLevel(
|
||||||
|
std::string const& lang, std::string const& config) const;
|
||||||
|
void UpdateExplicitStandardLevel(std::string const& lang,
|
||||||
|
std::string const& config,
|
||||||
|
cmStandardLevel level);
|
||||||
|
std::map<std::string, cmStandardLevel> ExplicitStandardLevel;
|
||||||
|
|
||||||
cmValue GetPropertyWithPairedLanguageSupport(std::string const& lang,
|
cmValue GetPropertyWithPairedLanguageSupport(std::string const& lang,
|
||||||
const char* suffix) const;
|
const char* suffix) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user