Selaa lähdekoodia

GenEx: Teach TARGET_PROPERTY evaluation to optionally pierce LINK_ONLY

Brad King 1 vuosi sitten
vanhempi
sitoutus
862b8e28ad

+ 9 - 7
Source/cmGeneratorExpressionNode.cxx

@@ -2701,7 +2701,8 @@ static const struct DeviceLinkNode : public cmGeneratorExpressionNode
 static std::string getLinkedTargetsContent(
 static std::string getLinkedTargetsContent(
   cmGeneratorTarget const* target, std::string const& prop,
   cmGeneratorTarget const* target, std::string const& prop,
   cmGeneratorExpressionContext* context,
   cmGeneratorExpressionContext* context,
-  cmGeneratorExpressionDAGChecker* dagChecker)
+  cmGeneratorExpressionDAGChecker* dagChecker,
+  cmGeneratorTarget::LinkInterfaceFor interfaceFor)
 {
 {
   std::string result;
   std::string result;
   if (cmLinkImplementationLibraries const* impl =
   if (cmLinkImplementationLibraries const* impl =
@@ -2717,8 +2718,7 @@ static std::string getLinkedTargetsContent(
           target, context->EvaluateForBuildsystem, lib.Backtrace,
           target, context->EvaluateForBuildsystem, lib.Backtrace,
           context->Language);
           context->Language);
         std::string libResult = lib.Target->EvaluateInterfaceProperty(
         std::string libResult = lib.Target->EvaluateInterfaceProperty(
-          prop, &libContext, dagChecker,
-          cmGeneratorTarget::LinkInterfaceFor::Usage);
+          prop, &libContext, dagChecker, interfaceFor);
         if (!libResult.empty()) {
         if (!libResult.empty()) {
           if (result.empty()) {
           if (result.empty()) {
             result = std::move(libResult);
             result = std::move(libResult);
@@ -2876,11 +2876,14 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
 
 
     std::string interfacePropertyName;
     std::string interfacePropertyName;
     bool isInterfaceProperty = false;
     bool isInterfaceProperty = false;
+    cmGeneratorTarget::LinkInterfaceFor interfaceFor =
+      cmGeneratorTarget::LinkInterfaceFor::Usage;
 
 
     if (cm::optional<cmGeneratorTarget::TransitiveProperty> transitiveProp =
     if (cm::optional<cmGeneratorTarget::TransitiveProperty> transitiveProp =
           target->IsTransitiveProperty(propertyName, context->LG)) {
           target->IsTransitiveProperty(propertyName, context->LG)) {
       interfacePropertyName = std::string(transitiveProp->InterfaceName);
       interfacePropertyName = std::string(transitiveProp->InterfaceName);
       isInterfaceProperty = transitiveProp->InterfaceName == propertyName;
       isInterfaceProperty = transitiveProp->InterfaceName == propertyName;
+      interfaceFor = transitiveProp->InterfaceFor;
     }
     }
 
 
     bool evaluatingLinkLibraries = false;
     bool evaluatingLinkLibraries = false;
@@ -2910,9 +2913,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
 
 
     if (isInterfaceProperty) {
     if (isInterfaceProperty) {
       return cmGeneratorExpression::StripEmptyListElements(
       return cmGeneratorExpression::StripEmptyListElements(
-        target->EvaluateInterfaceProperty(
-          propertyName, context, dagCheckerParent,
-          cmGeneratorTarget::LinkInterfaceFor::Usage));
+        target->EvaluateInterfaceProperty(propertyName, context,
+                                          dagCheckerParent, interfaceFor));
     }
     }
 
 
     cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, target,
     cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, target,
@@ -2999,7 +3001,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
         this->EvaluateDependentExpression(result, context->LG, context, target,
         this->EvaluateDependentExpression(result, context->LG, context, target,
                                           &dagChecker, target));
                                           &dagChecker, target));
       std::string linkedTargetsContent = getLinkedTargetsContent(
       std::string linkedTargetsContent = getLinkedTargetsContent(
-        target, interfacePropertyName, context, &dagChecker);
+        target, interfacePropertyName, context, &dagChecker, interfaceFor);
       if (!linkedTargetsContent.empty()) {
       if (!linkedTargetsContent.empty()) {
         result += (result.empty() ? "" : ";") + linkedTargetsContent;
         result += (result.empty() ? "" : ";") + linkedTargetsContent;
       }
       }

+ 24 - 13
Source/cmGeneratorTarget.cxx

@@ -76,19 +76,29 @@ const std::string kINTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE =
 
 
 const std::map<cm::string_view, TransitiveProperty>
 const std::map<cm::string_view, TransitiveProperty>
   cmGeneratorTarget::BuiltinTransitiveProperties = {
   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,
     { "SYSTEM_INCLUDE_DIRECTORIES"_s,
-      { "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES"_s } },
+      { "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES"_s, LinkInterfaceFor::Usage } },
   };
   };
 
 
 template <>
 template <>
@@ -1551,7 +1561,8 @@ cmGeneratorTarget::IsTransitiveProperty(cm::string_view prop,
     cmPolicies::PolicyStatus cmp0043 =
     cmPolicies::PolicyStatus cmp0043 =
       lg->GetPolicyStatus(cmPolicies::CMP0043);
       lg->GetPolicyStatus(cmPolicies::CMP0043);
     if (cmp0043 == cmPolicies::WARN || cmp0043 == cmPolicies::OLD) {
     if (cmp0043 == cmPolicies::WARN || cmp0043 == cmPolicies::OLD) {
-      result = TransitiveProperty{ "INTERFACE_COMPILE_DEFINITIONS"_s };
+      result = TransitiveProperty{ "INTERFACE_COMPILE_DEFINITIONS"_s,
+                                   LinkInterfaceFor::Usage };
     }
     }
   }
   }
   return result;
   return result;

+ 1 - 0
Source/cmGeneratorTarget.h

@@ -889,6 +889,7 @@ public:
   struct TransitiveProperty
   struct TransitiveProperty
   {
   {
     cm::string_view InterfaceName;
     cm::string_view InterfaceName;
+    LinkInterfaceFor InterfaceFor;
   };
   };
 
 
   static const std::map<cm::string_view, TransitiveProperty>
   static const std::map<cm::string_view, TransitiveProperty>