Browse Source

Fix AUTOMOC deps file to contain correct rule name

The rule name should include the current binary path relative to
the top level binary path.

Fixes: #20298
Alexandru Croitor 5 years ago
parent
commit
7c664bb5b9
1 changed files with 8 additions and 1 deletions
  1. 8 1
      Source/cmQtAutoGenInitializer.cxx

+ 8 - 1
Source/cmQtAutoGenInitializer.cxx

@@ -1189,8 +1189,15 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
       const std::string outputFile =
         cmStrCat(this->Dir.Build, "/", timestampFileName);
       this->AutogenTarget.DepFile = cmStrCat(this->Dir.Build, "/deps");
+      auto relativeBinaryDir = cmSystemTools::RelativePath(
+        this->LocalGen->GetBinaryDirectory(),
+        this->LocalGen->GetCurrentBinaryDirectory());
+      if (!relativeBinaryDir.empty()) {
+        relativeBinaryDir = cmStrCat(relativeBinaryDir, "/");
+      }
       this->AutogenTarget.DepFileRuleName =
-        cmStrCat(this->GenTarget->GetName(), "_autogen/", timestampFileName);
+        cmStrCat(relativeBinaryDir, this->GenTarget->GetName(), "_autogen/",
+                 timestampFileName);
       commandLines.push_back(cmMakeCommandLine(
         { cmSystemTools::GetCMakeCommand(), "-E", "touch", outputFile }));