summaryrefslogtreecommitdiffstats
path: root/Source/cmForEachCommand.cxx
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2006-05-18 17:50:01 (GMT)
committerKen Martin <ken.martin@kitware.com>2006-05-18 17:50:01 (GMT)
commit29a03db7ce5150c30610d4a9b0e7c6d38f923f35 (patch)
tree283a237abcb57f0a2af8b3a4f8f4c0019f190188 /Source/cmForEachCommand.cxx
parent095e975c812c7962fa865f04444ac489f1ee8643 (diff)
downloadCMake-29a03db7ce5150c30610d4a9b0e7c6d38f923f35.zip
CMake-29a03db7ce5150c30610d4a9b0e7c6d38f923f35.tar.gz
CMake-29a03db7ce5150c30610d4a9b0e7c6d38f923f35.tar.bz2
ENH: allow loose loop constructs
Diffstat (limited to 'Source/cmForEachCommand.cxx')
-rw-r--r--Source/cmForEachCommand.cxx27
1 files changed, 19 insertions, 8 deletions
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index fe53b12..5f03c43 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -25,14 +25,18 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf)
{
return false;
}
-
- // at end of for each execute recorded commands
- if (cmSystemTools::LowerCase(lff.Name) == "endforeach")
+
+ if (cmSystemTools::LowerCase(lff.Name) == "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::LowerCase(lff.Name) == "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,8 +64,13 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf)
mf.RemoveFunctionBlocker(lff);
return true;
}
+ else
+ {
+ // close out a nested foreach
+ this->Depth--;
+ }
}
-
+
// record the command
this->Functions.push_back(lff);
@@ -76,7 +85,9 @@ ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf)
{
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;
}