cmGlobalGenerator: Delegate storage of enabled languages to cmState.

This commit is contained in:
Stephen Kelly 2015-04-11 14:16:39 +02:00
parent b159bff732
commit 74de9a734c
3 changed files with 36 additions and 12 deletions

View File

@ -969,13 +969,7 @@ void cmGlobalGenerator::SetLanguageEnabled(const std::string& l,
void cmGlobalGenerator::SetLanguageEnabledFlag(const std::string& l, void cmGlobalGenerator::SetLanguageEnabledFlag(const std::string& l,
cmMakefile* mf) cmMakefile* mf)
{ {
std::vector<std::string>::iterator it = this->CMakeInstance->GetState()->SetLanguageEnabled(l);
std::lower_bound(this->LanguageEnabled.begin(),
this->LanguageEnabled.end(), l);
if (it == this->LanguageEnabled.end() || *it != l)
{
this->LanguageEnabled.insert(it, l);
}
// Fill the language-to-extension map with the current variable // Fill the language-to-extension map with the current variable
// settings to make sure it is available for the try_compile() // settings to make sure it is available for the try_compile()
@ -1086,13 +1080,12 @@ bool cmGlobalGenerator::IgnoreFile(const char* ext) const
bool cmGlobalGenerator::GetLanguageEnabled(const std::string& l) const bool cmGlobalGenerator::GetLanguageEnabled(const std::string& l) const
{ {
return std::binary_search(this->LanguageEnabled.begin(), return this->CMakeInstance->GetState()->GetLanguageEnabled(l);
this->LanguageEnabled.end(), l);
} }
void cmGlobalGenerator::ClearEnabledLanguages() void cmGlobalGenerator::ClearEnabledLanguages()
{ {
this->LanguageEnabled.clear(); return this->CMakeInstance->GetState()->ClearEnabledLanguages();
} }
void cmGlobalGenerator::Configure() void cmGlobalGenerator::Configure()
@ -1966,7 +1959,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
void void
cmGlobalGenerator::GetEnabledLanguages(std::vector<std::string>& lang) const cmGlobalGenerator::GetEnabledLanguages(std::vector<std::string>& lang) const
{ {
lang = this->LanguageEnabled; lang = this->CMakeInstance->GetState()->GetEnabledLanguages();
} }
int cmGlobalGenerator::GetLinkerPreference(const std::string& lang) const int cmGlobalGenerator::GetLinkerPreference(const std::string& lang) const

View File

@ -236,3 +236,30 @@ bool cmState::IsPropertyChained(const std::string& name,
{ {
return this->PropertyDefinitions[scope].IsPropertyChained(name); return this->PropertyDefinitions[scope].IsPropertyChained(name);
} }
void cmState::SetLanguageEnabled(std::string const& l)
{
std::vector<std::string>::iterator it =
std::lower_bound(this->EnabledLanguages.begin(),
this->EnabledLanguages.end(), l);
if (it == this->EnabledLanguages.end() || *it != l)
{
this->EnabledLanguages.insert(it, l);
}
}
bool cmState::GetLanguageEnabled(std::string const& l) const
{
return std::binary_search(this->EnabledLanguages.begin(),
this->EnabledLanguages.end(), l);
}
std::vector<std::string> cmState::GetEnabledLanguages() const
{
return this->EnabledLanguages;
}
void cmState::ClearEnabledLanguages()
{
this->EnabledLanguages.clear();
}

View File

@ -71,10 +71,14 @@ public:
bool IsPropertyDefined(const std::string& name, cmProperty::ScopeType scope); bool IsPropertyDefined(const std::string& name, cmProperty::ScopeType scope);
bool IsPropertyChained(const std::string& name, cmProperty::ScopeType scope); bool IsPropertyChained(const std::string& name, cmProperty::ScopeType scope);
void SetLanguageEnabled(std::string const& l);
bool GetLanguageEnabled(std::string const& l) const;
std::vector<std::string> GetEnabledLanguages() const;
void ClearEnabledLanguages();
private: private:
std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> PropertyDefinitions; std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> PropertyDefinitions;
std::vector<std::string> EnabledLanguages;
cmake* CMakeInstance; cmake* CMakeInstance;
}; };