Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmSetSourceFilesPropertiesCommand.cxx
blob61244147980dfbdb88d58bbf73467e952f87799a
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmSetSourceFilesPropertiesCommand.cxx,v $
5 Language: C++
6 <<<<<<< cmSetSourceFilesPropertiesCommand.cxx
7 Date: $Date: 2008/02/15 16:22:23 $
8 Version: $Revision: 1.19 $
9 =======
10 Date: $Date: 2008-05-08 19:49:53 $
11 Version: $Revision: 1.20 $
12 >>>>>>> 1.20
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 "cmSetSourceFilesPropertiesCommand.h"
24 #include "cmSourceFile.h"
26 // cmSetSourceFilesPropertiesCommand
27 bool cmSetSourceFilesPropertiesCommand
28 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
30 if(args.size() < 2 )
32 this->SetError("called with incorrect number of arguments");
33 return false;
36 // break the arguments into source file names and properties
37 int numFiles = 0;
38 std::vector<std::string>::const_iterator j;
39 j = args.begin();
40 // old style allows for specifier before PROPERTIES keyword
41 while (j != args.end() &&
42 *j != "ABSTRACT" &&
43 *j != "WRAP_EXCLUDE" &&
44 *j != "GENERATED" &&
45 *j != "COMPILE_FLAGS" &&
46 *j != "OBJECT_DEPENDS" &&
47 *j != "PROPERTIES")
49 numFiles++;
50 ++j;
53 // now call the worker function
54 std::string errors;
55 bool ret =
56 cmSetSourceFilesPropertiesCommand
57 ::RunCommand(this->Makefile,
58 args.begin(),
59 args.begin() + numFiles,
60 args.begin() + numFiles,
61 args.end(), errors);
62 if (!ret)
64 this->SetError(errors.c_str());
66 return ret;
69 bool cmSetSourceFilesPropertiesCommand
70 ::RunCommand(cmMakefile *mf,
71 std::vector<std::string>::const_iterator filebeg,
72 std::vector<std::string>::const_iterator fileend,
73 std::vector<std::string>::const_iterator propbeg,
74 std::vector<std::string>::const_iterator propend,
75 std::string &errors)
77 std::vector<std::string> propertyPairs;
78 bool generated = false;
79 std::vector<std::string>::const_iterator j;
80 // build the property pairs
81 for(j= propbeg; j != propend;++j)
83 // old style allows for specifier before PROPERTIES keyword
84 if(*j == "ABSTRACT")
86 propertyPairs.push_back("ABSTRACT");
87 propertyPairs.push_back("1");
89 else if(*j == "WRAP_EXCLUDE")
91 propertyPairs.push_back("WRAP_EXCLUDE");
92 propertyPairs.push_back("1");
94 else if(*j == "GENERATED")
96 generated = true;
97 propertyPairs.push_back("GENERATED");
98 propertyPairs.push_back("1");
100 else if(*j == "COMPILE_FLAGS")
102 propertyPairs.push_back("COMPILE_FLAGS");
103 ++j;
104 if(j == propend)
106 errors = "called with incorrect number of arguments "
107 "COMPILE_FLAGS with no flags";
108 return false;
110 propertyPairs.push_back(*j);
112 else if(*j == "OBJECT_DEPENDS")
114 propertyPairs.push_back("OBJECT_DEPENDS");
115 ++j;
116 if(j == propend)
118 errors = "called with incorrect number of arguments "
119 "OBJECT_DEPENDS with no dependencies";
120 return false;
122 propertyPairs.push_back(*j);
124 else if(*j == "PROPERTIES")
126 // now loop through the rest of the arguments, new style
127 ++j;
128 while (j != propend)
130 propertyPairs.push_back(*j);
131 if(*j == "GENERATED")
133 ++j;
134 if(j != propend && cmSystemTools::IsOn(j->c_str()))
136 generated = true;
139 else
141 ++j;
143 if(j == propend)
145 errors = "called with incorrect number of arguments.";
146 return false;
148 propertyPairs.push_back(*j);
149 ++j;
151 // break out of the loop because j is already == end
152 break;
154 else
156 errors = "called with illegal arguments, maybe missing a "
157 "PROPERTIES specifier?";
158 return false;
162 // now loop over all the files
163 for(j= filebeg; j != fileend;++j)
165 // get the source file
166 cmSourceFile* sf =
167 mf->GetOrCreateSource(j->c_str(), generated);
168 if(sf)
170 // now loop through all the props and set them
171 unsigned int k;
172 for (k = 0; k < propertyPairs.size(); k = k + 2)
174 sf->SetProperty(propertyPairs[k].c_str(),propertyPairs[k+1].c_str());
178 return true;