GenEx: Teach TARGET_PROPERTY evaluation to optionally pierce LINK_ONLY
This commit is contained in:
parent
8d1d6a1437
commit
862b8e28ad
@ -2701,7 +2701,8 @@ static const struct DeviceLinkNode : public cmGeneratorExpressionNode
|
||||
static std::string getLinkedTargetsContent(
|
||||
cmGeneratorTarget const* target, std::string const& prop,
|
||||
cmGeneratorExpressionContext* context,
|
||||
cmGeneratorExpressionDAGChecker* dagChecker)
|
||||
cmGeneratorExpressionDAGChecker* dagChecker,
|
||||
cmGeneratorTarget::LinkInterfaceFor interfaceFor)
|
||||
{
|
||||
std::string result;
|
||||
if (cmLinkImplementationLibraries const* impl =
|
||||
@ -2717,8 +2718,7 @@ static std::string getLinkedTargetsContent(
|
||||
target, context->EvaluateForBuildsystem, lib.Backtrace,
|
||||
context->Language);
|
||||
std::string libResult = lib.Target->EvaluateInterfaceProperty(
|
||||
prop, &libContext, dagChecker,
|
||||
cmGeneratorTarget::LinkInterfaceFor::Usage);
|
||||
prop, &libContext, dagChecker, interfaceFor);
|
||||
if (!libResult.empty()) {
|
||||
if (result.empty()) {
|
||||
result = std::move(libResult);
|
||||
@ -2876,11 +2876,14 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
|
||||
|
||||
std::string interfacePropertyName;
|
||||
bool isInterfaceProperty = false;
|
||||
cmGeneratorTarget::LinkInterfaceFor interfaceFor =
|
||||
cmGeneratorTarget::LinkInterfaceFor::Usage;
|
||||
|
||||
if (cm::optional<cmGeneratorTarget::TransitiveProperty> transitiveProp =
|
||||
target->IsTransitiveProperty(propertyName, context->LG)) {
|
||||
interfacePropertyName = std::string(transitiveProp->InterfaceName);
|
||||
isInterfaceProperty = transitiveProp->InterfaceName == propertyName;
|
||||
interfaceFor = transitiveProp->InterfaceFor;
|
||||
}
|
||||
|
||||
bool evaluatingLinkLibraries = false;
|
||||
@ -2910,9 +2913,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
|
||||
|
||||
if (isInterfaceProperty) {
|
||||
return cmGeneratorExpression::StripEmptyListElements(
|
||||
target->EvaluateInterfaceProperty(
|
||||
propertyName, context, dagCheckerParent,
|
||||
cmGeneratorTarget::LinkInterfaceFor::Usage));
|
||||
target->EvaluateInterfaceProperty(propertyName, context,
|
||||
dagCheckerParent, interfaceFor));
|
||||
}
|
||||
|
||||
cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, target,
|
||||
@ -2999,7 +3001,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
|
||||
this->EvaluateDependentExpression(result, context->LG, context, target,
|
||||
&dagChecker, target));
|
||||
std::string linkedTargetsContent = getLinkedTargetsContent(
|
||||
target, interfacePropertyName, context, &dagChecker);
|
||||
target, interfacePropertyName, context, &dagChecker, interfaceFor);
|
||||
if (!linkedTargetsContent.empty()) {
|
||||
result += (result.empty() ? "" : ";") + linkedTargetsContent;
|
||||
}
|
||||
|
@ -76,19 +76,29 @@ const std::string kINTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE =
|
||||
|
||||
const std::map<cm::string_view, TransitiveProperty>
|
||||
cmGeneratorTarget::BuiltinTransitiveProperties = {
|
||||
{ "AUTOMOC_MACRO_NAMES"_s, { "INTERFACE_AUTOMOC_MACRO_NAMES"_s } },
|
||||
{ "AUTOUIC_OPTIONS"_s, { "INTERFACE_AUTOUIC_OPTIONS"_s } },
|
||||
{ "COMPILE_DEFINITIONS"_s, { "INTERFACE_COMPILE_DEFINITIONS"_s } },
|
||||
{ "COMPILE_FEATURES"_s, { "INTERFACE_COMPILE_FEATURES"_s } },
|
||||
{ "COMPILE_OPTIONS"_s, { "INTERFACE_COMPILE_OPTIONS"_s } },
|
||||
{ "INCLUDE_DIRECTORIES"_s, { "INTERFACE_INCLUDE_DIRECTORIES"_s } },
|
||||
{ "LINK_DEPENDS"_s, { "INTERFACE_LINK_DEPENDS"_s } },
|
||||
{ "LINK_DIRECTORIES"_s, { "INTERFACE_LINK_DIRECTORIES"_s } },
|
||||
{ "LINK_OPTIONS"_s, { "INTERFACE_LINK_OPTIONS"_s } },
|
||||
{ "PRECOMPILE_HEADERS"_s, { "INTERFACE_PRECOMPILE_HEADERS"_s } },
|
||||
{ "SOURCES"_s, { "INTERFACE_SOURCES"_s } },
|
||||
{ "AUTOMOC_MACRO_NAMES"_s,
|
||||
{ "INTERFACE_AUTOMOC_MACRO_NAMES"_s, LinkInterfaceFor::Usage } },
|
||||
{ "AUTOUIC_OPTIONS"_s,
|
||||
{ "INTERFACE_AUTOUIC_OPTIONS"_s, LinkInterfaceFor::Usage } },
|
||||
{ "COMPILE_DEFINITIONS"_s,
|
||||
{ "INTERFACE_COMPILE_DEFINITIONS"_s, LinkInterfaceFor::Usage } },
|
||||
{ "COMPILE_FEATURES"_s,
|
||||
{ "INTERFACE_COMPILE_FEATURES"_s, LinkInterfaceFor::Usage } },
|
||||
{ "COMPILE_OPTIONS"_s,
|
||||
{ "INTERFACE_COMPILE_OPTIONS"_s, LinkInterfaceFor::Usage } },
|
||||
{ "INCLUDE_DIRECTORIES"_s,
|
||||
{ "INTERFACE_INCLUDE_DIRECTORIES"_s, LinkInterfaceFor::Usage } },
|
||||
{ "LINK_DEPENDS"_s,
|
||||
{ "INTERFACE_LINK_DEPENDS"_s, LinkInterfaceFor::Usage } },
|
||||
{ "LINK_DIRECTORIES"_s,
|
||||
{ "INTERFACE_LINK_DIRECTORIES"_s, LinkInterfaceFor::Usage } },
|
||||
{ "LINK_OPTIONS"_s,
|
||||
{ "INTERFACE_LINK_OPTIONS"_s, LinkInterfaceFor::Usage } },
|
||||
{ "PRECOMPILE_HEADERS"_s,
|
||||
{ "INTERFACE_PRECOMPILE_HEADERS"_s, LinkInterfaceFor::Usage } },
|
||||
{ "SOURCES"_s, { "INTERFACE_SOURCES"_s, LinkInterfaceFor::Usage } },
|
||||
{ "SYSTEM_INCLUDE_DIRECTORIES"_s,
|
||||
{ "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES"_s } },
|
||||
{ "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES"_s, LinkInterfaceFor::Usage } },
|
||||
};
|
||||
|
||||
template <>
|
||||
@ -1551,7 +1561,8 @@ cmGeneratorTarget::IsTransitiveProperty(cm::string_view prop,
|
||||
cmPolicies::PolicyStatus cmp0043 =
|
||||
lg->GetPolicyStatus(cmPolicies::CMP0043);
|
||||
if (cmp0043 == cmPolicies::WARN || cmp0043 == cmPolicies::OLD) {
|
||||
result = TransitiveProperty{ "INTERFACE_COMPILE_DEFINITIONS"_s };
|
||||
result = TransitiveProperty{ "INTERFACE_COMPILE_DEFINITIONS"_s,
|
||||
LinkInterfaceFor::Usage };
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -889,6 +889,7 @@ public:
|
||||
struct TransitiveProperty
|
||||
{
|
||||
cm::string_view InterfaceName;
|
||||
LinkInterfaceFor InterfaceFor;
|
||||
};
|
||||
|
||||
static const std::map<cm::string_view, TransitiveProperty>
|
||||
|
Loading…
Reference in New Issue
Block a user