cmGeneratorTarget: Move IsLinkInterfaceDependent* from cmTarget.

This commit is contained in:
Stephen Kelly 2015-08-04 19:19:42 +02:00
parent 12bc571c13
commit 244c5b5dcd
5 changed files with 122 additions and 119 deletions

View File

@ -1128,6 +1128,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
}
}
cmGeneratorTarget* gtgt =
context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target);
if (!prop)
{
if (target->IsImported()
@ -1135,7 +1138,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
{
return linkedTargetsContent;
}
if (target->IsLinkInterfaceDependentBoolProperty(propertyName,
if (gtgt->IsLinkInterfaceDependentBoolProperty(propertyName,
context->Config))
{
context->HadContextSensitiveCondition = true;
@ -1143,7 +1146,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
propertyName,
context->Config) ? "1" : "0";
}
if (target->IsLinkInterfaceDependentStringProperty(propertyName,
if (gtgt->IsLinkInterfaceDependentStringProperty(propertyName,
context->Config))
{
context->HadContextSensitiveCondition = true;
@ -1153,7 +1156,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
context->Config);
return propContent ? propContent : "";
}
if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName,
if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName,
context->Config))
{
context->HadContextSensitiveCondition = true;
@ -1163,7 +1166,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
context->Config);
return propContent ? propContent : "";
}
if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName,
if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName,
context->Config))
{
context->HadContextSensitiveCondition = true;
@ -1180,7 +1183,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
if (!target->IsImported()
&& dagCheckerParent && !dagCheckerParent->EvaluatingLinkLibraries())
{
if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName,
if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName,
context->Config))
{
context->HadContextSensitiveCondition = true;
@ -1190,7 +1193,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
context->Config);
return propContent ? propContent : "";
}
if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName,
if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName,
context->Config))
{
context->HadContextSensitiveCondition = true;

View File

@ -1436,3 +1436,84 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const
}
}
}
//----------------------------------------------------------------------------
const cmGeneratorTarget::CompatibleInterfacesBase&
cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const
{
cmGeneratorTarget::CompatibleInterfaces& compat =
this->CompatibleInterfacesMap[config];
if(!compat.Done)
{
compat.Done = true;
compat.PropsBool.insert("POSITION_INDEPENDENT_CODE");
compat.PropsString.insert("AUTOUIC_OPTIONS");
std::vector<cmTarget const*> const& deps =
this->Target->GetLinkImplementationClosure(config);
for(std::vector<cmTarget const*>::const_iterator li = deps.begin();
li != deps.end(); ++li)
{
#define CM_READ_COMPATIBLE_INTERFACE(X, x) \
if(const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) \
{ \
std::vector<std::string> props; \
cmSystemTools::ExpandListArgument(prop, props); \
compat.Props##x.insert(props.begin(), props.end()); \
}
CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool)
CM_READ_COMPATIBLE_INTERFACE(STRING, String)
CM_READ_COMPATIBLE_INTERFACE(NUMBER_MIN, NumberMin)
CM_READ_COMPATIBLE_INTERFACE(NUMBER_MAX, NumberMax)
#undef CM_READ_COMPATIBLE_INTERFACE
}
}
return compat;
}
//----------------------------------------------------------------------------
bool cmGeneratorTarget::IsLinkInterfaceDependentBoolProperty(
const std::string &p, const std::string& config) const
{
if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY
|| this->Target->GetType() == cmTarget::INTERFACE_LIBRARY)
{
return false;
}
return this->GetCompatibleInterfaces(config).PropsBool.count(p) > 0;
}
//----------------------------------------------------------------------------
bool cmGeneratorTarget::IsLinkInterfaceDependentStringProperty(
const std::string &p, const std::string& config) const
{
if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY
|| this->Target->GetType() == cmTarget::INTERFACE_LIBRARY)
{
return false;
}
return this->GetCompatibleInterfaces(config).PropsString.count(p) > 0;
}
//----------------------------------------------------------------------------
bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMinProperty(
const std::string &p, const std::string& config) const
{
if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY
|| this->Target->GetType() == cmTarget::INTERFACE_LIBRARY)
{
return false;
}
return this->GetCompatibleInterfaces(config).PropsNumberMin.count(p) > 0;
}
//----------------------------------------------------------------------------
bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty(
const std::string &p, const std::string& config) const
{
if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY
|| this->Target->GetType() == cmTarget::INTERFACE_LIBRARY)
{
return false;
}
return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0;
}

View File

@ -82,6 +82,15 @@ public:
bool GetFeatureAsBool(const std::string& feature,
const std::string& config) const;
bool IsLinkInterfaceDependentBoolProperty(const std::string &p,
const std::string& config) const;
bool IsLinkInterfaceDependentStringProperty(const std::string &p,
const std::string& config) const;
bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p,
const std::string& config) const;
bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p,
const std::string& config) const;
/** Get the full path to the target according to the settings in its
makefile and the configuration type. */
std::string GetFullPath(const std::string& config="", bool implib = false,
@ -187,6 +196,23 @@ private:
mutable bool SourceFileFlagsConstructed;
mutable std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap;
struct CompatibleInterfacesBase
{
std::set<std::string> PropsBool;
std::set<std::string> PropsString;
std::set<std::string> PropsNumberMax;
std::set<std::string> PropsNumberMin;
};
CompatibleInterfacesBase const&
GetCompatibleInterfaces(std::string const& config) const;
struct CompatibleInterfaces: public CompatibleInterfacesBase
{
CompatibleInterfaces(): Done(false) {}
bool Done;
};
mutable std::map<std::string, CompatibleInterfaces> CompatibleInterfacesMap;
cmGeneratorTarget(cmGeneratorTarget const&);
void operator=(cmGeneratorTarget const&);
};

View File

@ -170,13 +170,6 @@ public:
};
std::map<std::string, LinkImplClosure> LinkImplClosureMap;
struct CompatibleInterfaces: public cmTarget::CompatibleInterfaces
{
CompatibleInterfaces(): Done(false) {}
bool Done;
};
std::map<std::string, CompatibleInterfaces> CompatibleInterfacesMap;
typedef std::map<std::string, std::vector<cmSourceFile*> >
SourceFilesMapType;
SourceFilesMapType SourceFilesMap;
@ -4990,54 +4983,6 @@ const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty(
NumberMaxType, 0);
}
//----------------------------------------------------------------------------
bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p,
const std::string& config) const
{
if (this->TargetTypeValue == OBJECT_LIBRARY
|| this->TargetTypeValue == INTERFACE_LIBRARY)
{
return false;
}
return this->GetCompatibleInterfaces(config).PropsBool.count(p) > 0;
}
//----------------------------------------------------------------------------
bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p,
const std::string& config) const
{
if (this->TargetTypeValue == OBJECT_LIBRARY
|| this->TargetTypeValue == INTERFACE_LIBRARY)
{
return false;
}
return this->GetCompatibleInterfaces(config).PropsString.count(p) > 0;
}
//----------------------------------------------------------------------------
bool cmTarget::IsLinkInterfaceDependentNumberMinProperty(const std::string &p,
const std::string& config) const
{
if (this->TargetTypeValue == OBJECT_LIBRARY
|| this->TargetTypeValue == INTERFACE_LIBRARY)
{
return false;
}
return this->GetCompatibleInterfaces(config).PropsNumberMin.count(p) > 0;
}
//----------------------------------------------------------------------------
bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p,
const std::string& config) const
{
if (this->TargetTypeValue == OBJECT_LIBRARY
|| this->TargetTypeValue == INTERFACE_LIBRARY)
{
return false;
}
return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0;
}
//----------------------------------------------------------------------------
void
cmTarget::GetObjectLibrariesCMP0026(std::vector<cmTarget*>& objlibs) const
@ -5724,39 +5669,6 @@ cmTarget::GetLinkImplementationClosure(const std::string& config) const
return tgts;
}
//----------------------------------------------------------------------------
cmTarget::CompatibleInterfaces const&
cmTarget::GetCompatibleInterfaces(std::string const& config) const
{
cmTargetInternals::CompatibleInterfaces& compat =
this->Internal->CompatibleInterfacesMap[config];
if(!compat.Done)
{
compat.Done = true;
compat.PropsBool.insert("POSITION_INDEPENDENT_CODE");
compat.PropsString.insert("AUTOUIC_OPTIONS");
std::vector<cmTarget const*> const& deps =
this->GetLinkImplementationClosure(config);
for(std::vector<cmTarget const*>::const_iterator li = deps.begin();
li != deps.end(); ++li)
{
#define CM_READ_COMPATIBLE_INTERFACE(X, x) \
if(const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) \
{ \
std::vector<std::string> props; \
cmSystemTools::ExpandListArgument(prop, props); \
compat.Props##x.insert(props.begin(), props.end()); \
}
CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool)
CM_READ_COMPATIBLE_INTERFACE(STRING, String)
CM_READ_COMPATIBLE_INTERFACE(NUMBER_MIN, NumberMin)
CM_READ_COMPATIBLE_INTERFACE(NUMBER_MAX, NumberMax)
#undef CM_READ_COMPATIBLE_INTERFACE
}
}
return compat;
}
//----------------------------------------------------------------------------
void
cmTargetInternals::ComputeLinkInterfaceLibraries(

View File

@ -305,16 +305,6 @@ public:
std::vector<cmTarget const*> const&
GetLinkImplementationClosure(const std::string& config) const;
struct CompatibleInterfaces
{
std::set<std::string> PropsBool;
std::set<std::string> PropsString;
std::set<std::string> PropsNumberMax;
std::set<std::string> PropsNumberMin;
};
CompatibleInterfaces const&
GetCompatibleInterfaces(std::string const& config) const;
/** The link implementation specifies the direct library
dependencies needed by the object files of the target. */
struct LinkImplementationLibraries
@ -575,15 +565,6 @@ public:
const std::string& config) const;
bool IsNullImpliedByLinkLibraries(const std::string &p) const;
bool IsLinkInterfaceDependentBoolProperty(const std::string &p,
const std::string& config) const;
bool IsLinkInterfaceDependentStringProperty(const std::string &p,
const std::string& config) const;
bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p,
const std::string& config) const;
bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p,
const std::string& config) const;
bool GetLinkInterfaceDependentBoolProperty(const std::string &p,
const std::string& config) const;