From 16e24748c5092f19d53c80548083826f009aafc7 Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Thu, 4 Nov 2021 11:58:06 -0400
Subject: Ninja Multi-Config: Fix cross-config custom command dependency
 tracing

Process `CMAKE_CROSS_CONFIGS` and friends to properly configure the
generator for cross-config behavior before custom command dependency
tracing.
---
 Source/cmGlobalGenerator.cxx      | 3 +++
 Source/cmGlobalGenerator.h        | 2 ++
 Source/cmGlobalNinjaGenerator.cxx | 3 ---
 Source/cmGlobalNinjaGenerator.h   | 2 --
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index ac283ab..9914902 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1402,6 +1402,9 @@ bool cmGlobalGenerator::Compute()
                                          this->SupportsDefaultConfigs())) {
     return false;
   }
+  if (!this->InspectConfigTypeVariables()) {
+    return false;
+  }
 
   // Some generators track files replaced during the Generate.
   // Start with an empty vector:
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index cc0ad29..96696aa 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -153,6 +153,8 @@ public:
    */
   virtual void Configure();
 
+  virtual bool InspectConfigTypeVariables() { return true; }
+
   bool Compute();
   virtual void AddExtraIDETargets() {}
 
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 3f6f55e..7122b9f 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -568,9 +568,6 @@ void cmGlobalNinjaGenerator::Generate()
                                            msg.str());
     return;
   }
-  if (!this->InspectConfigTypeVariables()) {
-    return;
-  }
   if (!this->OpenBuildFileStreams()) {
     return;
   }
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index ec73475..84fc06c 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -481,8 +481,6 @@ protected:
     const std::set<std::string>& all, const std::set<std::string>& defaults,
     const std::vector<std::string>& items);
 
-  virtual bool InspectConfigTypeVariables() { return true; }
-
   std::set<std::string> CrossConfigs;
   std::set<std::string> DefaultConfigs;
   std::string DefaultFileConfig;
-- 
cgit v0.12