From 88bc8dfc14f02ee07654c906a0e6be5d5a33b017 Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Mon, 13 Mar 2023 11:32:03 -0400
Subject: cmMakefile: Store recursion depth limit as size_t

---
 Source/cmGlobalGenerator.cxx | 2 --
 Source/cmGlobalGenerator.h   | 2 +-
 Source/cmMakefile.cxx        | 9 ++++-----
 Source/cmMakefile.h          | 6 +++---
 4 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 72eed69..7ed68d6 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -110,8 +110,6 @@ cmGlobalGenerator::cmGlobalGenerator(cmake* cm)
   this->ConfigureDoneCMP0026AndCMP0024 = false;
   this->FirstTimeProgress = 0.0f;
 
-  this->RecursionDepth = 0;
-
   cm->GetState()->SetIsGeneratorMultiConfig(false);
   cm->GetState()->SetMinGWMake(false);
   cm->GetState()->SetMSYSShell(false);
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 66ab752..7de8215 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -586,7 +586,7 @@ public:
 
   std::string MakeSilentFlag;
 
-  int RecursionDepth;
+  size_t RecursionDepth = 0;
 
   virtual void GetQtAutoGenConfigs(std::vector<std::string>& configs) const
   {
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index a014776..d0a8958 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -99,7 +99,6 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
   this->StateSnapshot =
     this->StateSnapshot.GetState()->CreatePolicyScopeSnapshot(
       this->StateSnapshot);
-  this->RecursionDepth = 0;
 
   // Enter a policy level for this directory.
   this->PushPolicy();
@@ -454,12 +453,12 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
   static_cast<void>(stack_manager);
 
   // Check for maximum recursion depth.
-  int depth = CMake_DEFAULT_RECURSION_LIMIT;
+  size_t depth = CMake_DEFAULT_RECURSION_LIMIT;
   if (cmValue depthStr =
         this->GetDefinition("CMAKE_MAXIMUM_RECURSION_DEPTH")) {
     unsigned long depthUL;
     if (cmStrToULong(depthStr.GetCStr(), &depthUL)) {
-      depth = static_cast<int>(depthUL);
+      depth = depthUL;
     }
   }
   if (this->RecursionDepth > depth) {
@@ -2864,12 +2863,12 @@ bool cmMakefile::IsProjectFile(const char* filename) const
      !cmSystemTools::IsSubDirectory(filename, "/CMakeFiles"));
 }
 
-int cmMakefile::GetRecursionDepth() const
+size_t cmMakefile::GetRecursionDepth() const
 {
   return this->RecursionDepth;
 }
 
-void cmMakefile::SetRecursionDepth(int recursionDepth)
+void cmMakefile::SetRecursionDepth(size_t recursionDepth)
 {
   this->RecursionDepth = recursionDepth;
 }
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 6f04937..6923a77 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -1023,8 +1023,8 @@ public:
                               const char* sourceFilename) const;
   bool IsProjectFile(const char* filename) const;
 
-  int GetRecursionDepth() const;
-  void SetRecursionDepth(int recursionDepth);
+  size_t GetRecursionDepth() const;
+  void SetRecursionDepth(size_t recursionDepth);
 
   std::string NewDeferId() const;
   bool DeferCall(std::string id, std::string fileName, cmListFileFunction lff);
@@ -1090,7 +1090,7 @@ protected:
 private:
   cmStateSnapshot StateSnapshot;
   cmListFileBacktrace Backtrace;
-  int RecursionDepth;
+  size_t RecursionDepth = 0;
 
   struct DeferCommand
   {
-- 
cgit v0.12