summaryrefslogtreecommitdiffstats
path: root/Source/cmForEachCommand.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmForEachCommand.cxx')
-rw-r--r--Source/cmForEachCommand.cxx48
1 files changed, 48 insertions, 0 deletions
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index 7a826c6..7a03523 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -16,6 +16,8 @@
=========================================================================*/
#include "cmForEachCommand.h"
+#include <cmsys/auto_ptr.hxx>
+
bool cmForEachFunctionBlocker::
IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
cmExecutionStatus &inStatus)
@@ -116,6 +118,10 @@ bool cmForEachCommand
this->SetError("called with incorrect number of arguments");
return false;
}
+ if(args.size() > 1 && args[1] == "IN")
+ {
+ return this->HandleInMode(args);
+ }
// create a function blocker
cmForEachFunctionBlocker *f = new cmForEachFunctionBlocker();
@@ -197,3 +203,45 @@ bool cmForEachCommand
return true;
}
+//----------------------------------------------------------------------------
+bool cmForEachCommand::HandleInMode(std::vector<std::string> const& args)
+{
+ cmsys::auto_ptr<cmForEachFunctionBlocker> f(new cmForEachFunctionBlocker());
+ f->Args.push_back(args[0]);
+
+ enum Doing { DoingNone, DoingLists, DoingItems };
+ Doing doing = DoingNone;
+ for(unsigned int i=2; i < args.size(); ++i)
+ {
+ if(doing == DoingItems)
+ {
+ f->Args.push_back(args[i]);
+ }
+ else if(args[i] == "LISTS")
+ {
+ doing = DoingLists;
+ }
+ else if(args[i] == "ITEMS")
+ {
+ doing = DoingItems;
+ }
+ else if(doing == DoingLists)
+ {
+ const char* value = this->Makefile->GetDefinition(args[i].c_str());
+ if(value && *value)
+ {
+ cmSystemTools::ExpandListArgument(value, f->Args, true);
+ }
+ }
+ else
+ {
+ cmOStringStream e;
+ e << "Unknown argument:\n" << " " << args[i] << "\n";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return true;
+ }
+ }
+
+ this->Makefile->AddFunctionBlocker(f.release()); // TODO: pass auto_ptr
+ return true;
+}