Clarify documentation for if.
[cmake.git] / Source / cmSetTestsPropertiesCommand.cxx
blobd7f71b5eb52373abaf80b3ff9fa358147241b912
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmSetTestsPropertiesCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2009-01-05 20:00:57 $
7 Version: $Revision: 1.8 $
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 if(cmTest* test = mf->GetTest(tname))
105 // now loop through all the props and set them
106 unsigned int k;
107 for (k = 0; k < propertyPairs.size(); k = k + 2)
109 test->SetProperty(propertyPairs[k].c_str(),
110 propertyPairs[k+1].c_str());
113 else
115 errors = "Can not find test to add properties to: ";
116 errors += tname;
117 return false;
120 return true;