From 395895bda72462c59e18135e98662e47f52138ba Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 13 Mar 2023 11:20:21 -0400 Subject: cmMakefile: Factor out helper to get recursion depth limit --- Source/cmMakefile.cxx | 26 ++++++++++++++++---------- Source/cmMakefile.h | 2 ++ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index d0a8958..383a818 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -453,17 +453,10 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, static_cast(stack_manager); // Check for maximum recursion depth. - 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 = depthUL; - } - } - if (this->RecursionDepth > depth) { + size_t depthLimit = this->GetRecursionDepthLimit(); + if (this->RecursionDepth > depthLimit) { std::ostringstream e; - e << "Maximum recursion depth of " << depth << " exceeded"; + e << "Maximum recursion depth of " << depthLimit << " exceeded"; this->IssueMessage(MessageType::FATAL_ERROR, e.str()); cmSystemTools::SetFatalErrorOccurred(); return false; @@ -2863,6 +2856,19 @@ bool cmMakefile::IsProjectFile(const char* filename) const !cmSystemTools::IsSubDirectory(filename, "/CMakeFiles")); } +size_t cmMakefile::GetRecursionDepthLimit() const +{ + 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 = depthUL; + } + } + return depth; +} + size_t cmMakefile::GetRecursionDepth() const { return this->RecursionDepth; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 6923a77..a43ff41 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -1023,6 +1023,8 @@ public: const char* sourceFilename) const; bool IsProjectFile(const char* filename) const; + size_t GetRecursionDepthLimit() const; + size_t GetRecursionDepth() const; void SetRecursionDepth(size_t recursionDepth); -- cgit v0.12