Merge topic 'refactor-features'

e3078aa1 cmLocalGenerator: Implement GetFeature in terms of cmState.
7441fde3 cmLocalGenerator: Convert GetFeature recursion to loop.
ad0b0089 cmLocalGenerator: Simplify GetFeature implementation.
314c9ae3 cmLocalGenerator: Make GetFeature tail-recursive.
This commit is contained in:
Brad King 2015-08-27 10:04:05 -04:00 committed by CMake Topic Stage
commit a97bb6ae3f
1 changed files with 9 additions and 12 deletions

View File

@ -2368,25 +2368,22 @@ void cmLocalGenerator::AppendFeatureOptions(
const char* cmLocalGenerator::GetFeature(const std::string& feature,
const std::string& config)
{
std::string featureName = feature;
// TODO: Define accumulation policy for features (prepend, append, replace).
// Currently we always replace.
if(!config.empty())
{
std::string featureConfig = feature;
featureConfig += "_";
featureConfig += cmSystemTools::UpperCase(config);
if(const char* value = this->Makefile->GetProperty(featureConfig))
featureName += "_";
featureName += cmSystemTools::UpperCase(config);
}
cmState::Snapshot snp = this->StateSnapshot;
while(snp.IsValid())
{
if(const char* value = snp.GetDirectory().GetProperty(featureName))
{
return value;
}
}
if(const char* value = this->Makefile->GetProperty(feature))
{
return value;
}
if(cmLocalGenerator* parent = this->GetParent())
{
return parent->GetFeature(feature, config);
snp = snp.GetBuildsystemDirectoryParent();
}
return 0;
}