1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
12 #include "cmSetSourceFilesPropertiesCommand.h"
14 #include "cmSourceFile.h"
16 // cmSetSourceFilesPropertiesCommand
17 bool cmSetSourceFilesPropertiesCommand
18 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
22 this->SetError("called with incorrect number of arguments");
26 // break the arguments into source file names and properties
28 std::vector<std::string>::const_iterator j;
30 // old style allows for specifier before PROPERTIES keyword
31 while (j != args.end() &&
33 *j != "WRAP_EXCLUDE" &&
35 *j != "COMPILE_FLAGS" &&
36 *j != "OBJECT_DEPENDS" &&
43 // now call the worker function
46 cmSetSourceFilesPropertiesCommand
47 ::RunCommand(this->Makefile,
49 args.begin() + numFiles,
50 args.begin() + numFiles,
54 this->SetError(errors.c_str());
59 bool cmSetSourceFilesPropertiesCommand
60 ::RunCommand(cmMakefile *mf,
61 std::vector<std::string>::const_iterator filebeg,
62 std::vector<std::string>::const_iterator fileend,
63 std::vector<std::string>::const_iterator propbeg,
64 std::vector<std::string>::const_iterator propend,
67 std::vector<std::string> propertyPairs;
68 bool generated = false;
69 std::vector<std::string>::const_iterator j;
70 // build the property pairs
71 for(j= propbeg; j != propend;++j)
73 // old style allows for specifier before PROPERTIES keyword
76 propertyPairs.push_back("ABSTRACT");
77 propertyPairs.push_back("1");
79 else if(*j == "WRAP_EXCLUDE")
81 propertyPairs.push_back("WRAP_EXCLUDE");
82 propertyPairs.push_back("1");
84 else if(*j == "GENERATED")
87 propertyPairs.push_back("GENERATED");
88 propertyPairs.push_back("1");
90 else if(*j == "COMPILE_FLAGS")
92 propertyPairs.push_back("COMPILE_FLAGS");
96 errors = "called with incorrect number of arguments "
97 "COMPILE_FLAGS with no flags";
100 propertyPairs.push_back(*j);
102 else if(*j == "OBJECT_DEPENDS")
104 propertyPairs.push_back("OBJECT_DEPENDS");
108 errors = "called with incorrect number of arguments "
109 "OBJECT_DEPENDS with no dependencies";
112 propertyPairs.push_back(*j);
114 else if(*j == "PROPERTIES")
116 // now loop through the rest of the arguments, new style
120 propertyPairs.push_back(*j);
121 if(*j == "GENERATED")
124 if(j != propend && cmSystemTools::IsOn(j->c_str()))
135 errors = "called with incorrect number of arguments.";
138 propertyPairs.push_back(*j);
141 // break out of the loop because j is already == end
146 errors = "called with illegal arguments, maybe missing a "
147 "PROPERTIES specifier?";
152 // now loop over all the files
153 for(j= filebeg; j != fileend;++j)
155 // get the source file
157 mf->GetOrCreateSource(j->c_str(), generated);
160 // now loop through all the props and set them
162 for (k = 0; k < propertyPairs.size(); k = k + 2)
164 sf->SetProperty(propertyPairs[k].c_str(),propertyPairs[k+1].c_str());