1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmSetSourceFilesPropertiesCommand.cxx,v $
6 Date: $Date: 2008-05-08 19:49:53 $
7 Version: $Revision: 1.20 $
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 "cmSetSourceFilesPropertiesCommand.h"
19 #include "cmSourceFile.h"
21 // cmSetSourceFilesPropertiesCommand
22 bool cmSetSourceFilesPropertiesCommand
23 ::InitialPass(std::vector
<std::string
> const& args
, cmExecutionStatus
&)
27 this->SetError("called with incorrect number of arguments");
31 // break the arguments into source file names and properties
33 std::vector
<std::string
>::const_iterator j
;
35 // old style allows for specifier before PROPERTIES keyword
36 while (j
!= args
.end() &&
38 *j
!= "WRAP_EXCLUDE" &&
40 *j
!= "COMPILE_FLAGS" &&
41 *j
!= "OBJECT_DEPENDS" &&
48 // now call the worker function
51 cmSetSourceFilesPropertiesCommand
52 ::RunCommand(this->Makefile
,
54 args
.begin() + numFiles
,
55 args
.begin() + numFiles
,
59 this->SetError(errors
.c_str());
64 bool cmSetSourceFilesPropertiesCommand
65 ::RunCommand(cmMakefile
*mf
,
66 std::vector
<std::string
>::const_iterator filebeg
,
67 std::vector
<std::string
>::const_iterator fileend
,
68 std::vector
<std::string
>::const_iterator propbeg
,
69 std::vector
<std::string
>::const_iterator propend
,
72 std::vector
<std::string
> propertyPairs
;
73 bool generated
= false;
74 std::vector
<std::string
>::const_iterator j
;
75 // build the property pairs
76 for(j
= propbeg
; j
!= propend
;++j
)
78 // old style allows for specifier before PROPERTIES keyword
81 propertyPairs
.push_back("ABSTRACT");
82 propertyPairs
.push_back("1");
84 else if(*j
== "WRAP_EXCLUDE")
86 propertyPairs
.push_back("WRAP_EXCLUDE");
87 propertyPairs
.push_back("1");
89 else if(*j
== "GENERATED")
92 propertyPairs
.push_back("GENERATED");
93 propertyPairs
.push_back("1");
95 else if(*j
== "COMPILE_FLAGS")
97 propertyPairs
.push_back("COMPILE_FLAGS");
101 errors
= "called with incorrect number of arguments "
102 "COMPILE_FLAGS with no flags";
105 propertyPairs
.push_back(*j
);
107 else if(*j
== "OBJECT_DEPENDS")
109 propertyPairs
.push_back("OBJECT_DEPENDS");
113 errors
= "called with incorrect number of arguments "
114 "OBJECT_DEPENDS with no dependencies";
117 propertyPairs
.push_back(*j
);
119 else if(*j
== "PROPERTIES")
121 // now loop through the rest of the arguments, new style
125 propertyPairs
.push_back(*j
);
126 if(*j
== "GENERATED")
129 if(j
!= propend
&& cmSystemTools::IsOn(j
->c_str()))
140 errors
= "called with incorrect number of arguments.";
143 propertyPairs
.push_back(*j
);
146 // break out of the loop because j is already == end
151 errors
= "called with illegal arguments, maybe missing a "
152 "PROPERTIES specifier?";
157 // now loop over all the files
158 for(j
= filebeg
; j
!= fileend
;++j
)
160 // get the source file
162 mf
->GetOrCreateSource(j
->c_str(), generated
);
165 // now loop through all the props and set them
167 for (k
= 0; k
< propertyPairs
.size(); k
= k
+ 2)
169 sf
->SetProperty(propertyPairs
[k
].c_str(),propertyPairs
[k
+1].c_str());