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,16 +1138,16 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
{
return linkedTargetsContent;
}
if (target->IsLinkInterfaceDependentBoolProperty(propertyName,
context->Config))
if (gtgt->IsLinkInterfaceDependentBoolProperty(propertyName,
context->Config))
{
context->HadContextSensitiveCondition = true;
return target->GetLinkInterfaceDependentBoolProperty(
propertyName,
context->Config) ? "1" : "0";
}
if (target->IsLinkInterfaceDependentStringProperty(propertyName,
context->Config))
if (gtgt->IsLinkInterfaceDependentStringProperty(propertyName,
context->Config))
{
context->HadContextSensitiveCondition = true;
const char *propContent =
@ -1153,8 +1156,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
context->Config);
return propContent ? propContent : "";
}
if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName,
context->Config))
if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName,
context->Config))
{
context->HadContextSensitiveCondition = true;
const char *propContent =
@ -1163,8 +1166,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
context->Config);
return propContent ? propContent : "";
}
if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName,
context->Config))
if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName,
context->Config))
{
context->HadContextSensitiveCondition = true;
const char *propContent =
@ -1180,8 +1183,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
if (!target->IsImported()
&& dagCheckerParent && !dagCheckerParent->EvaluatingLinkLibraries())
{
if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName,
context->Config))
if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName,
context->Config))
{
context->HadContextSensitiveCondition = true;
const char *propContent =
@ -1190,8 +1193,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
context->Config);
return propContent ? propContent : "";
}
if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName,
context->Config))
if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName,
context->Config))
{
context->HadContextSensitiveCondition = true;
const char *propContent =

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;