summaryrefslogtreecommitdiffstats
path: root/Source/cmListCommand.cxx
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2007-07-12 15:56:45 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2007-07-12 15:56:45 (GMT)
commitc8010cd7fb0f87dd6ceb07679a2840029f4238a3 (patch)
tree1fbdffa0e4b323119760c3693bbd226d301eac33 /Source/cmListCommand.cxx
parenta5be2b77823d6dd2ce1fd6859eb037dd2c939134 (diff)
downloadCMake-c8010cd7fb0f87dd6ceb07679a2840029f4238a3.zip
CMake-c8010cd7fb0f87dd6ceb07679a2840029f4238a3.tar.gz
CMake-c8010cd7fb0f87dd6ceb07679a2840029f4238a3.tar.bz2
ENH: add LIST(CONTAINS ...) patch from "Miguel A. Figueroa-Villanueva, miguelf (AT) ieee.org
added tests for LIST(CONTAINS, SORT, REVERSE) Alex
Diffstat (limited to 'Source/cmListCommand.cxx')
-rw-r--r--Source/cmListCommand.cxx37
1 files changed, 37 insertions, 0 deletions
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index b546d20..f0df03b 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -42,6 +42,10 @@ bool cmListCommand::InitialPass(std::vector<std::string> const& args)
{
return this->HandleAppendCommand(args);
}
+ if(subCommand == "CONTAINS")
+ {
+ return this->HandleContainsCommand(args);
+ }
if(subCommand == "INSERT")
{
return this->HandleInsertCommand(args);
@@ -200,6 +204,39 @@ bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args)
}
//----------------------------------------------------------------------------
+bool cmListCommand::HandleContainsCommand(std::vector<std::string> const& args)
+{
+ if(args.size() != 4)
+ {
+ this->SetError("sub-command CONTAINS requires three arguments.");
+ return false;
+ }
+
+ const std::string& listName = args[1];
+ const std::string& variableName = args[args.size() - 1];
+ // expand the variable
+ std::vector<std::string> varArgsExpanded;
+ if ( !this->GetList(varArgsExpanded, listName.c_str()) )
+ {
+ this->Makefile->AddDefinition(variableName.c_str(), "FALSE");
+ return true;
+ }
+
+ std::vector<std::string>::iterator it;
+ for ( it = varArgsExpanded.begin(); it != varArgsExpanded.end(); ++ it )
+ {
+ if ( *it == args[2] )
+ {
+ this->Makefile->AddDefinition(variableName.c_str(), "TRUE");
+ return true;
+ }
+ }
+
+ this->Makefile->AddDefinition(variableName.c_str(), "FALSE");
+ return true;
+}
+
+//----------------------------------------------------------------------------
bool cmListCommand::HandleInsertCommand(std::vector<std::string> const& args)
{
if(args.size() < 4)