Merge topic 'move-Feature-API'

f573bd22 cmLocalGenerator: Add Feature API from cmMakefile.
ccbc2259 cmGeneratorTarget: Move Feature API from cmTarget.
This commit is contained in:
Brad King 2015-06-08 13:54:05 -04:00 committed by CMake Topic Stage
commit f5690cc57c
11 changed files with 71 additions and 69 deletions

View File

@ -352,6 +352,34 @@ void cmGeneratorTarget::ComputeObjectMapping()
}
}
//----------------------------------------------------------------------------
const char* cmGeneratorTarget::GetFeature(const std::string& feature,
const std::string& config) const
{
if(!config.empty())
{
std::string featureConfig = feature;
featureConfig += "_";
featureConfig += cmSystemTools::UpperCase(config);
if(const char* value = this->Target->GetProperty(featureConfig))
{
return value;
}
}
if(const char* value = this->Target->GetProperty(feature))
{
return value;
}
return this->LocalGenerator->GetFeature(feature, config);
}
//----------------------------------------------------------------------------
bool cmGeneratorTarget::GetFeatureAsBool(const std::string& feature,
const std::string& config) const
{
return cmSystemTools::IsOn(this->GetFeature(feature, config));
}
//----------------------------------------------------------------------------
const std::string& cmGeneratorTarget::GetObjectName(cmSourceFile const* file)
{
@ -983,7 +1011,7 @@ cmGeneratorTarget::GetCreateRuleVariable(std::string const& lang,
case cmTarget::STATIC_LIBRARY:
{
std::string var = "CMAKE_" + lang + "_CREATE_STATIC_LIBRARY";
if(this->Target->GetFeatureAsBool(
if(this->GetFeatureAsBool(
"INTERPROCEDURAL_OPTIMIZATION", config))
{
std::string varIPO = var + "_IPO";

View File

@ -67,6 +67,11 @@ public:
void ComputeObjectMapping();
const char* GetFeature(const std::string& feature,
const std::string& config) const;
bool GetFeatureAsBool(const std::string& feature,
const std::string& config) const;
cmTarget* Target;
cmMakefile* Makefile;
cmLocalGenerator* LocalGenerator;

View File

@ -1025,12 +1025,13 @@ cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
{
return activeConfigs;
}
cmGeneratorTarget* gt = this->GetGeneratorTarget(target);
// inspect EXCLUDE_FROM_DEFAULT_BUILD[_<CONFIG>] properties
for(std::vector<std::string>::const_iterator i = configs.begin();
i != configs.end(); ++i)
{
const char* propertyValue =
target->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i->c_str());
gt->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i->c_str());
if(cmSystemTools::IsOff(propertyValue))
{
activeConfigs.insert(*i);

View File

@ -2519,6 +2519,33 @@ void cmLocalGenerator::AppendFeatureOptions(
}
}
//----------------------------------------------------------------------------
const char* cmLocalGenerator::GetFeature(const std::string& feature,
const std::string& config)
{
// 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))
{
return value;
}
}
if(const char* value = this->Makefile->GetProperty(feature))
{
return value;
}
if(cmLocalGenerator* parent = this->GetParent())
{
return parent->GetFeature(feature, config);
}
return 0;
}
//----------------------------------------------------------------------------
std::string
cmLocalGenerator::ConstructComment(cmCustomCommandGenerator const& ccg,

View File

@ -151,6 +151,9 @@ public:
void AppendFeatureOptions(std::string& flags, const std::string& lang,
const char* feature);
const char* GetFeature(const std::string& feature,
const std::string& config);
/** \brief Get absolute path to dependency \a name
*
* Translate a dependency as given in CMake code to the name to

View File

@ -4215,33 +4215,6 @@ bool cmMakefile::GetPropertyAsBool(const std::string& prop) const
return cmSystemTools::IsOn(this->GetProperty(prop));
}
//----------------------------------------------------------------------------
const char* cmMakefile::GetFeature(const std::string& feature,
const std::string& config)
{
// 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->GetProperty(featureConfig))
{
return value;
}
}
if(const char* value = this->GetProperty(feature))
{
return value;
}
if(cmLocalGenerator* parent = this->LocalGenerator->GetParent())
{
return parent->GetMakefile()->GetFeature(feature, config);
}
return 0;
}
cmTarget* cmMakefile::FindTarget(const std::string& name,
bool excludeAliases) const
{

View File

@ -727,9 +727,6 @@ public:
cmProperty::ScopeType scope) const;
bool GetPropertyAsBool(const std::string& prop) const;
const char* GetFeature(const std::string& feature,
const std::string& config);
// Get the properties
cmPropertyMap &GetProperties() { return this->Properties; }

View File

@ -2086,13 +2086,13 @@ void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
//----------------------------------------------------------------------------
const char* cmMakefileTargetGenerator::GetFeature(const std::string& feature)
{
return this->Target->GetFeature(feature, this->ConfigName);
return this->GeneratorTarget->GetFeature(feature, this->ConfigName);
}
//----------------------------------------------------------------------------
bool cmMakefileTargetGenerator::GetFeatureAsBool(const std::string& feature)
{
return this->Target->GetFeatureAsBool(feature, this->ConfigName);
return this->GeneratorTarget->GetFeatureAsBool(feature, this->ConfigName);
}
//----------------------------------------------------------------------------

View File

@ -107,13 +107,14 @@ std::string cmNinjaTargetGenerator::LanguageCompilerRule(
// TODO: Picked up from cmMakefileTargetGenerator. Refactor it.
const char* cmNinjaTargetGenerator::GetFeature(const std::string& feature)
{
return this->Target->GetFeature(feature, this->GetConfigName());
return this->GeneratorTarget->GetFeature(feature, this->GetConfigName());
}
// TODO: Picked up from cmMakefileTargetGenerator. Refactor it.
bool cmNinjaTargetGenerator::GetFeatureAsBool(const std::string& feature)
{
return this->Target->GetFeatureAsBool(feature, this->GetConfigName());
return this->GeneratorTarget->GetFeatureAsBool(feature,
this->GetConfigName());
}
// TODO: Picked up from cmMakefileTargetGenerator. Refactor it.

View File

@ -2813,34 +2813,6 @@ void cmTarget::GetTargetVersion(bool soversion,
}
}
//----------------------------------------------------------------------------
const char* cmTarget::GetFeature(const std::string& feature,
const std::string& config) const
{
if(!config.empty())
{
std::string featureConfig = feature;
featureConfig += "_";
featureConfig += cmSystemTools::UpperCase(config);
if(const char* value = this->GetProperty(featureConfig))
{
return value;
}
}
if(const char* value = this->GetProperty(feature))
{
return value;
}
return this->Makefile->GetFeature(feature, config);
}
//----------------------------------------------------------------------------
bool cmTarget::GetFeatureAsBool(const std::string& feature,
const std::string& config) const
{
return cmSystemTools::IsOn(this->GetFeature(feature, config));
}
//----------------------------------------------------------------------------
bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const
{

View File

@ -260,11 +260,6 @@ public:
bool GetPropertyAsBool(const std::string& prop) const;
void CheckProperty(const std::string& prop, cmMakefile* context) const;
const char* GetFeature(const std::string& feature,
const std::string& config) const;
bool GetFeatureAsBool(const std::string& feature,
const std::string& config) const;
bool IsImported() const {return this->IsImportedTarget;}
void GetObjectLibrariesCMP0026(std::vector<cmTarget*>& objlibs) const;