Преглед на файлове

Merge branch 'backport-4.2-find_package-stack' into find_package-stack

Brad King преди 1 седмица
родител
ревизия
a789c21100
променени са 1 файла, в които са добавени 13 реда и са изтрити 3 реда
  1. 13 3
      Source/cmMakefile.cxx

+ 13 - 3
Source/cmMakefile.cxx

@@ -4267,14 +4267,24 @@ cmFindPackageStackRAII::~cmFindPackageStackRAII()
   this->Makefile->FindPackageStack = this->Makefile->FindPackageStack.Pop();
 
   if (!this->Makefile->FindPackageStack.Empty()) {
-    auto top = this->Makefile->FindPackageStack.Top();
+    // We have just finished an inner package found as a dependency of an
+    // outer package.  Targets created in the outer package after this
+    // point may depend on the inner package, so if they are exported,
+    // their find_dependency call for the outer package should be
+    // ordered after the find_dependency call for the inner package.
+    //
+    // Any targets created by the outer package before the inner package
+    // was loaded will have already saved a copy of the outer package
+    // stack with its original index.  Replace the top entry with a new
+    // one representing the same outer package with a new index.
+    cmFindPackageCall outer = this->Makefile->FindPackageStack.Top();
     this->Makefile->FindPackageStack = this->Makefile->FindPackageStack.Pop();
 
-    top.Index = this->Makefile->FindPackageStackNextIndex;
+    outer.Index = this->Makefile->FindPackageStackNextIndex;
     this->Makefile->FindPackageStackNextIndex++;
 
     this->Makefile->FindPackageStack =
-      this->Makefile->FindPackageStack.Push(top);
+      this->Makefile->FindPackageStack.Push(outer);
   }
 }