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, ImportPropertyMap& properties,
std::set<cmGeneratorTarget const*> &emitted) std::set<cmGeneratorTarget const*> &emitted)
{ {
cmPropertyMap props = target->Target->GetProperties(); std::vector<std::string> props = target->GetPropertyKeys();
for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i) 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 properties[*i] = target->GetProperty(*i);
|| i->first.find("IMPORTED_LINK_DEPENDENT_LIBRARIES") == 0
|| i->first.find("INTERFACE_LINK_LIBRARIES") == 0) 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); target, emitted);
std::vector<std::string> depends; std::vector<std::string> depends;

View File

@ -4251,9 +4251,11 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
PropertyType *) PropertyType *)
{ {
PropertyType propContent = getTypedProperty<PropertyType>(tgt, p); PropertyType propContent = getTypedProperty<PropertyType>(tgt, p);
const bool explicitlySet = tgt->Target->GetProperties() std::vector<std::string> headPropKeys = tgt->GetPropertyKeys();
.find(p) const bool explicitlySet =
!= tgt->Target->GetProperties().end(); std::find(headPropKeys.begin(), headPropKeys.end(),
p) != headPropKeys.end();
const bool impliedByUse = const bool impliedByUse =
tgt->IsNullImpliedByLinkLibraries(p); tgt->IsNullImpliedByLinkLibraries(p);
assert((impliedByUse ^ explicitlySet) assert((impliedByUse ^ explicitlySet)
@ -4298,9 +4300,11 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
cmGeneratorTarget const* theTarget = *li; cmGeneratorTarget const* theTarget = *li;
const bool ifaceIsSet = theTarget->Target->GetProperties() std::vector<std::string> propKeys = theTarget->GetPropertyKeys();
.find(interfaceProperty)
!= theTarget->Target->GetProperties().end(); const bool ifaceIsSet =
std::find(propKeys.begin(), propKeys.end(),
interfaceProperty) != propKeys.end();
PropertyType ifacePropContent = PropertyType ifacePropContent =
getTypedProperty<PropertyType>(theTarget, getTypedProperty<PropertyType>(theTarget,
interfaceProperty); interfaceProperty);
@ -4577,6 +4581,19 @@ void cmGeneratorTarget::ComputeVersionedName(std::string& vName,
vName += this->Makefile->IsOn("APPLE") ? suffix : std::string(); 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 void
cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, cmGeneratorTarget::ReportPropertyOrigin(const std::string &p,

View File

@ -57,6 +57,7 @@ public:
std::string GetName() const; std::string GetName() const;
std::string GetExportName() const; std::string GetExportName() const;
std::vector<std::string> GetPropertyKeys() const;
const char *GetProperty(const std::string& prop) const; const char *GetProperty(const std::string& prop) const;
bool GetPropertyAsBool(const std::string& prop) const; bool GetPropertyAsBool(const std::string& prop) const;
void GetSourceFiles(std::vector<cmSourceFile*>& files, 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 // put this last so it can override existing settings
// Convert "XCODE_ATTRIBUTE_*" properties directly. // Convert "XCODE_ATTRIBUTE_*" properties directly.
{ {
cmPropertyMap const& props = gtgt->Target->GetProperties(); std::vector<std::string> const& props = gtgt->GetPropertyKeys();
for(cmPropertyMap::const_iterator i = props.begin(); for(std::vector<std::string>::const_iterator i = props.begin();
i != props.end(); ++i) 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. // Handle [variant=<config>] condition explicitly here.
std::string::size_type beginVariant = std::string::size_type beginVariant =
attribute.find("[variant="); attribute.find("[variant=");
@ -2523,7 +2523,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
if (!attribute.empty()) if (!attribute.empty())
{ {
cmGeneratorExpression ge; cmGeneratorExpression ge;
std::string processed = ge.Parse(i->second.GetValue()) std::string processed = ge.Parse(gtgt->GetProperty(*i))
->Evaluate(this->CurrentLocalGenerator, configName); ->Evaluate(this->CurrentLocalGenerator, configName);
buildSettings->AddAttribute(attribute.c_str(), buildSettings->AddAttribute(attribute.c_str(),
this->CreateString(processed)); this->CreateString(processed));

View File

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