summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-03-13 15:20:21 (GMT)
committerBrad King <brad.king@kitware.com>2023-03-13 15:37:20 (GMT)
commit395895bda72462c59e18135e98662e47f52138ba (patch)
treeab59772430eddc1202a1bcc23587deb5795a48ac /Source
parent88bc8dfc14f02ee07654c906a0e6be5d5a33b017 (diff)
downloadCMake-395895bda72462c59e18135e98662e47f52138ba.zip
CMake-395895bda72462c59e18135e98662e47f52138ba.tar.gz
CMake-395895bda72462c59e18135e98662e47f52138ba.tar.bz2
cmMakefile: Factor out helper to get recursion depth limit
Diffstat (limited to 'Source')
-rw-r--r--Source/cmMakefile.cxx26
-rw-r--r--Source/cmMakefile.h2
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<void>(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);