Initial commit.
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmSetTestsPropertiesCommand.cxx
blob325a2d1eb38cb4ed2d34862fc6a4a27267085957
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmSetTestsPropertiesCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2008/01/23 15:27:59 $
7 Version: $Revision: 1.7 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmSetTestsPropertiesCommand.h"
19 #include "cmake.h"
20 #include "cmTest.h"
22 // cmSetTestsPropertiesCommand
23 bool cmSetTestsPropertiesCommand
24 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
26 if(args.size() < 1 )
28 this->SetError("called with incorrect number of arguments");
29 return false;
32 // first collect up the list of files
33 std::vector<std::string> propertyPairs;
34 bool doingFiles = true;
35 int numFiles = 0;
36 std::vector<std::string>::const_iterator j;
37 for(j= args.begin(); j != args.end();++j)
39 if(*j == "PROPERTIES")
41 doingFiles = false;
42 // now loop through the rest of the arguments, new style
43 ++j;
44 while (j != args.end())
46 propertyPairs.push_back(*j);
47 ++j;
48 if(j == args.end())
50 this->SetError("called with incorrect number of arguments.");
51 return false;
53 propertyPairs.push_back(*j);
54 ++j;
56 // break out of the loop because j is already == end
57 break;
59 else if (doingFiles)
61 numFiles++;
63 else
65 this->SetError("called with illegal arguments, maybe "
66 "missing a PROPERTIES specifier?");
67 return false;
70 if(propertyPairs.size() == 0)
72 this->SetError("called with illegal arguments, maybe "
73 "missing a PROPERTIES specifier?");
74 return false;
78 // now loop over all the targets
79 int i;
80 for(i = 0; i < numFiles; ++i)
82 std::string errors;
83 bool ret =
84 cmSetTestsPropertiesCommand::SetOneTest(args[i].c_str(),
85 propertyPairs,
86 this->Makefile, errors);
87 if (!ret)
89 this->SetError(errors.c_str());
90 return ret;
94 return true;
98 bool cmSetTestsPropertiesCommand
99 ::SetOneTest(const char *tname,
100 std::vector<std::string> &propertyPairs,
101 cmMakefile *mf, std::string &errors)
103 std::vector<cmTest*> &tests = *mf->GetTests();
104 // now loop over all the targets
105 unsigned int k;
106 bool found = false;
107 // if the file is already in the makefile just set properites on it
108 std::vector<cmTest*>::iterator it;
109 for ( it = tests.begin(); it != tests.end(); ++ it )
111 cmTest* test = *it;
112 if ( !strcmp(test->GetName(),tname ))
114 // now loop through all the props and set them
115 for (k = 0; k < propertyPairs.size(); k = k + 2)
117 test->SetProperty(propertyPairs[k].c_str(),
118 propertyPairs[k+1].c_str());
120 found = true;
121 break;
125 // if file is not already in the makefile, then add it
126 if ( ! found )
128 errors = "Can not find test to add properties to: ";
129 errors += tname;
130 return false;
133 return true;