Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmSetTestsPropertiesCommand.cxx
blob795a9b37b4c62b72e65b434c1fa0fa78140eeb66
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmSetTestsPropertiesCommand.cxx,v $
5 Language: C++
6 <<<<<<< cmSetTestsPropertiesCommand.cxx
7 Date: $Date: 2008/01/23 15:27:59 $
8 Version: $Revision: 1.7 $
9 =======
10 Date: $Date: 2009-01-05 20:00:57 $
11 Version: $Revision: 1.8 $
12 >>>>>>> 1.8
14 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
15 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
17 This software is distributed WITHOUT ANY WARRANTY; without even
18 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
19 PURPOSE. See the above copyright notices for more information.
21 =========================================================================*/
22 #include "cmSetTestsPropertiesCommand.h"
24 #include "cmake.h"
25 #include "cmTest.h"
27 // cmSetTestsPropertiesCommand
28 bool cmSetTestsPropertiesCommand
29 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
31 if(args.size() < 1 )
33 this->SetError("called with incorrect number of arguments");
34 return false;
37 // first collect up the list of files
38 std::vector<std::string> propertyPairs;
39 bool doingFiles = true;
40 int numFiles = 0;
41 std::vector<std::string>::const_iterator j;
42 for(j= args.begin(); j != args.end();++j)
44 if(*j == "PROPERTIES")
46 doingFiles = false;
47 // now loop through the rest of the arguments, new style
48 ++j;
49 while (j != args.end())
51 propertyPairs.push_back(*j);
52 ++j;
53 if(j == args.end())
55 this->SetError("called with incorrect number of arguments.");
56 return false;
58 propertyPairs.push_back(*j);
59 ++j;
61 // break out of the loop because j is already == end
62 break;
64 else if (doingFiles)
66 numFiles++;
68 else
70 this->SetError("called with illegal arguments, maybe "
71 "missing a PROPERTIES specifier?");
72 return false;
75 if(propertyPairs.size() == 0)
77 this->SetError("called with illegal arguments, maybe "
78 "missing a PROPERTIES specifier?");
79 return false;
83 // now loop over all the targets
84 int i;
85 for(i = 0; i < numFiles; ++i)
87 std::string errors;
88 bool ret =
89 cmSetTestsPropertiesCommand::SetOneTest(args[i].c_str(),
90 propertyPairs,
91 this->Makefile, errors);
92 if (!ret)
94 this->SetError(errors.c_str());
95 return ret;
99 return true;
103 bool cmSetTestsPropertiesCommand
104 ::SetOneTest(const char *tname,
105 std::vector<std::string> &propertyPairs,
106 cmMakefile *mf, std::string &errors)
108 if(cmTest* test = mf->GetTest(tname))
110 // now loop through all the props and set them
111 unsigned int k;
112 for (k = 0; k < propertyPairs.size(); k = k + 2)
114 test->SetProperty(propertyPairs[k].c_str(),
115 propertyPairs[k+1].c_str());
118 else
120 errors = "Can not find test to add properties to: ";
121 errors += tname;
122 return false;
125 return true;