浏览代码

Android.mk: Fix export of static libraries with PRIVATE dependencies

The `LINK_ONLY` generator expression is used to represent private
dependencies of static libraries in their `INTERFACE_LINK_LIBRARIES`
property value.  Fix evaluation of generator expressions during export
to support the `LINK_ONLY` genex.  Extend the RunCMake.AndroidMK test
with a case for this.
Brad King 7 年之前
父节点
当前提交
b6d68766b1
共有 2 个文件被更改,包括 6 次插入3 次删除
  1. 5 2
      Source/cmExportBuildAndroidMKGenerator.cxx
  2. 1 1
      Tests/RunCMake/AndroidMK/AndroidMK.cmake

+ 5 - 2
Source/cmExportBuildAndroidMKGenerator.cxx

@@ -8,6 +8,7 @@
 #include <utility>
 
 #include "cmGeneratorExpression.h"
+#include "cmGeneratorExpressionDAGChecker.h"
 #include "cmGeneratorTarget.h"
 #include "cmLinkItem.h"
 #include "cmLocalGenerator.h"
@@ -104,10 +105,12 @@ void cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties(
         // evaluate any generator expressions with the current
         // build type of the makefile
         cmGeneratorExpression ge;
+        cmGeneratorExpressionDAGChecker dagChecker(
+          target->GetName(), "INTERFACE_LINK_LIBRARIES", nullptr, nullptr);
         std::unique_ptr<cmCompiledGeneratorExpression> cge =
           ge.Parse(property.second);
-        std::string evaluated =
-          cge->Evaluate(target->GetLocalGenerator(), config);
+        std::string evaluated = cge->Evaluate(
+          target->GetLocalGenerator(), config, false, target, &dagChecker);
         // need to look at list in pi->second and see if static or shared
         // FindTargetToLink
         // target->GetLocalGenerator()->FindGeneratorTargetToUse()

+ 1 - 1
Tests/RunCMake/AndroidMK/AndroidMK.cmake

@@ -4,7 +4,7 @@ add_library(foo foo.cxx)
 add_library(car foo.cxx)
 add_library(bar bar.c)
 add_library(dog  foo.cxx)
-target_link_libraries(foo car bar dog debug -lm)
+target_link_libraries(foo PRIVATE car bar dog debug -lm)
 export(TARGETS bar dog car foo  ANDROID_MK
   ${build_BINARY_DIR}/Android.mk)
 install(TARGETS bar dog car foo DESTINATION lib EXPORT myexp)