cmGeneratorTarget: Add API for property keys

This commit is contained in:
Stephen Kelly 2015-10-25 10:35:36 +01:00
parent 3e3c754b8c
commit 520ca0ff6c
5 changed files with 44 additions and 23 deletions

View File

@ -105,16 +105,18 @@ cmExportTryCompileFileGenerator::PopulateProperties(
ImportPropertyMap& properties,
std::set<cmGeneratorTarget const*> &emitted)
{
cmPropertyMap props = target->Target->GetProperties();
for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i)
std::vector<std::string> props = target->GetPropertyKeys();
for(std::vector<std::string>::const_iterator i = props.begin();
i != props.end(); ++i)
{
properties[i->first] = i->second.GetValue();
if(i->first.find("IMPORTED_LINK_INTERFACE_LIBRARIES") == 0
|| i->first.find("IMPORTED_LINK_DEPENDENT_LIBRARIES") == 0
|| i->first.find("INTERFACE_LINK_LIBRARIES") == 0)
properties[*i] = target->GetProperty(*i);
if(i->find("IMPORTED_LINK_INTERFACE_LIBRARIES") == 0
|| i->find("IMPORTED_LINK_DEPENDENT_LIBRARIES") == 0
|| i->find("INTERFACE_LINK_LIBRARIES") == 0)
{
std::string evalResult = this->FindTargets(i->first,
std::string evalResult = this->FindTargets(*i,
target, emitted);
std::vector<std::string> depends;

View File

@ -4251,9 +4251,11 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
PropertyType *)
{
PropertyType propContent = getTypedProperty<PropertyType>(tgt, p);
const bool explicitlySet = tgt->Target->GetProperties()
.find(p)
!= tgt->Target->GetProperties().end();
std::vector<std::string> headPropKeys = tgt->GetPropertyKeys();
const bool explicitlySet =
std::find(headPropKeys.begin(), headPropKeys.end(),
p) != headPropKeys.end();
const bool impliedByUse =
tgt->IsNullImpliedByLinkLibraries(p);
assert((impliedByUse ^ explicitlySet)
@ -4298,9 +4300,11 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
cmGeneratorTarget const* theTarget = *li;
const bool ifaceIsSet = theTarget->Target->GetProperties()
.find(interfaceProperty)
!= theTarget->Target->GetProperties().end();
std::vector<std::string> propKeys = theTarget->GetPropertyKeys();
const bool ifaceIsSet =
std::find(propKeys.begin(), propKeys.end(),
interfaceProperty) != propKeys.end();
PropertyType ifacePropContent =
getTypedProperty<PropertyType>(theTarget,
interfaceProperty);
@ -4577,6 +4581,19 @@ void cmGeneratorTarget::ComputeVersionedName(std::string& vName,
vName += this->Makefile->IsOn("APPLE") ? suffix : std::string();
}
std::vector<std::string> cmGeneratorTarget::GetPropertyKeys() const
{
cmPropertyMap propsObject = this->Target->GetProperties();
std::vector<std::string> props;
props.reserve(propsObject.size());
for (cmPropertyMap::const_iterator it = propsObject.begin();
it != propsObject.end(); ++it)
{
props.push_back(it->first);
}
return props;
}
//----------------------------------------------------------------------------
void
cmGeneratorTarget::ReportPropertyOrigin(const std::string &p,

View File

@ -57,6 +57,7 @@ public:
std::string GetName() const;
std::string GetExportName() const;
std::vector<std::string> GetPropertyKeys() const;
const char *GetProperty(const std::string& prop) const;
bool GetPropertyAsBool(const std::string& prop) const;
void GetSourceFiles(std::vector<cmSourceFile*>& files,

View File

@ -2486,13 +2486,13 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
// put this last so it can override existing settings
// Convert "XCODE_ATTRIBUTE_*" properties directly.
{
cmPropertyMap const& props = gtgt->Target->GetProperties();
for(cmPropertyMap::const_iterator i = props.begin();
std::vector<std::string> const& props = gtgt->GetPropertyKeys();
for(std::vector<std::string>::const_iterator i = props.begin();
i != props.end(); ++i)
{
if(i->first.find("XCODE_ATTRIBUTE_") == 0)
if(i->find("XCODE_ATTRIBUTE_") == 0)
{
std::string attribute = i->first.substr(16);
std::string attribute = i->substr(16);
// Handle [variant=<config>] condition explicitly here.
std::string::size_type beginVariant =
attribute.find("[variant=");
@ -2523,7 +2523,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
if (!attribute.empty())
{
cmGeneratorExpression ge;
std::string processed = ge.Parse(i->second.GetValue())
std::string processed = ge.Parse(gtgt->GetProperty(*i))
->Evaluate(this->CurrentLocalGenerator, configName);
buildSettings->AddAttribute(attribute.c_str(),
this->CreateString(processed));

View File

@ -2219,17 +2219,18 @@ void cmLocalVisualStudio7Generator::WriteVCProjFooter(
{
fout << "\t<Globals>\n";
cmPropertyMap const& props = target->Target->GetProperties();
for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i)
std::vector<std::string> const& props = target->GetPropertyKeys();
for(std::vector<std::string>::const_iterator i = props.begin();
i != props.end(); ++i)
{
if(i->first.find("VS_GLOBAL_") == 0)
if(i->find("VS_GLOBAL_") == 0)
{
std::string name = i->first.substr(10);
std::string name = i->substr(10);
if(name != "")
{
fout << "\t\t<Global\n"
<< "\t\t\tName=\"" << name << "\"\n"
<< "\t\t\tValue=\"" << i->second.GetValue() << "\"\n"
<< "\t\t\tValue=\"" << target->GetProperty(*i) << "\"\n"
<< "\t\t/>\n";
}
}