diff options
Diffstat (limited to 'Source/cmForEachCommand.cxx')
-rw-r--r-- | Source/cmForEachCommand.cxx | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index fe53b12..b7f388b 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -26,13 +26,17 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf) return false; } - // at end of for each execute recorded commands - if (cmSystemTools::LowerCase(lff.Name) == "endforeach") + if (!cmSystemTools::Strucmp(lff.Name.c_str(),"foreach")) { - std::vector<std::string> expandedArguments; - mf.ExpandArguments(lff.Arguments, expandedArguments); - if(!expandedArguments.empty() && (expandedArguments[0] == this->Args[0])) + // record the number of nested foreach commands + this->Depth++; + } + else if (!cmSystemTools::Strucmp(lff.Name.c_str(),"endforeach")) + { + // if this is the endofreach for this statement + if (!this->Depth) { + // at end of for each execute recorded commands // store the old value std::string oldDef; if (mf.GetDefinition(this->Args[0].c_str())) @@ -60,6 +64,11 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf) mf.RemoveFunctionBlocker(lff); return true; } + else + { + // close out a nested foreach + this->Depth--; + } } // record the command @@ -72,11 +81,13 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf) bool cmForEachFunctionBlocker:: ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) { - if(cmSystemTools::LowerCase(lff.Name) == "endforeach") + if(!cmSystemTools::Strucmp(lff.Name.c_str(),"endforeach")) { std::vector<std::string> expandedArguments; mf.ExpandArguments(lff.Arguments, expandedArguments); - if(!expandedArguments.empty() && (expandedArguments[0] == this->Args[0])) + if ((!expandedArguments.empty() && + (expandedArguments[0] == this->Args[0])) + || mf.IsOn("CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS")) { return true; } |