Browse Source

Merge topic 'fix-genex-HEAD-target'

5b22235 Genex: Fix the HEAD target used for evaluated expressions
Brad King 12 years ago
parent
commit
d3c8688ecd

+ 9 - 4
Source/cmGeneratorExpressionEvaluator.cxx

@@ -500,6 +500,7 @@ static const char* targetPropertyTransitiveWhitelist[] = {
 
 std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
                                   cmTarget *target,
+                                  cmTarget *headTarget,
                                   cmGeneratorExpressionContext *context,
                                   cmGeneratorExpressionDAGChecker *dagChecker,
                                   const std::string &interfacePropertyName)
@@ -530,7 +531,7 @@ std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
   std::string linkedTargetsContent = cge->Evaluate(context->Makefile,
                       context->Config,
                       context->Quiet,
-                      context->HeadTarget,
+                      headTarget,
                       target,
                       dagChecker);
   if (cge->GetHadContextSensitiveCondition())
@@ -729,6 +730,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
       interfacePropertyName = "INTERFACE_COMPILE_OPTIONS";
       }
 
+    cmTarget *headTarget = context->HeadTarget ? context->HeadTarget : target;
+
     const char **transBegin = targetPropertyTransitiveWhitelist;
     const char **transEnd = targetPropertyTransitiveWhitelist
               + (sizeof(targetPropertyTransitiveWhitelist) /
@@ -738,11 +741,12 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
       {
       const cmTarget::LinkInterface *iface = target->GetLinkInterface(
                                                     context->Config,
-                                                    context->HeadTarget);
+                                                    headTarget);
       if(iface)
         {
         linkedTargetsContent =
                   getLinkedTargetsContent(iface->Libraries, target,
+                                          headTarget,
                                           context, &dagChecker,
                                           interfacePropertyName);
         }
@@ -752,11 +756,12 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
       {
       const cmTarget::LinkImplementation *impl = target->GetLinkImplementation(
                                                     context->Config,
-                                                    context->HeadTarget);
+                                                    headTarget);
       if(impl)
         {
         linkedTargetsContent =
                   getLinkedTargetsContent(impl->Libraries, target,
+                                          headTarget,
                                           context, &dagChecker,
                                           interfacePropertyName);
         }
@@ -805,7 +810,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
         std::string result = cge->Evaluate(context->Makefile,
                             context->Config,
                             context->Quiet,
-                            context->HeadTarget,
+                            headTarget,
                             target,
                             &dagChecker);
 

+ 5 - 0
Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt

@@ -109,6 +109,11 @@ set_property(TARGET libbad APPEND PROPERTY
   INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/bad"
 )
 
+add_library(lib6 SHARED other.cpp)
+add_library(lib7 SHARED other.cpp)
+target_link_libraries(lib7 $<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:lib6>)
+target_include_directories(lib7 PUBLIC $<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:/lib7/include>)
+add_custom_target(head_target_test "some_bogus_custom_tool \"$<TARGET_PROPERTY:lib7,INCLUDE_DIRECTORIES>$<TARGET_PROPERTY:lib7,INTERFACE_INCLUDE_DIRECTORIES>\"")
 
 add_library(includes_source_good empty.cpp)
 target_include_directories(includes_source_good

+ 6 - 0
Tests/IncludeDirectories/TargetIncludeDirectories/other.cpp

@@ -0,0 +1,6 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int other() {
+  return 0;
+}