1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmSetSourceFilesPropertiesCommand.cxx,v $
6 Date: $Date: 2008-01-23 15:27:59 $
7 Version: $Revision: 1.18 $
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
!= "ABSTRACT" &&
37 *j
!= "WRAP_EXCLUDE" &&
39 *j
!= "COMPILE_FLAGS" &&
40 *j
!= "OBJECT_DEPENDS" &&
47 // now call the worker function
50 cmSetSourceFilesPropertiesCommand
51 ::RunCommand(this->Makefile
,
53 args
.begin() + numFiles
,
54 args
.begin() + numFiles
,
58 this->SetError(errors
.c_str());
63 bool cmSetSourceFilesPropertiesCommand
64 ::RunCommand(cmMakefile
*mf
,
65 std::vector
<std::string
>::const_iterator filebeg
,
66 std::vector
<std::string
>::const_iterator fileend
,
67 std::vector
<std::string
>::const_iterator propbeg
,
68 std::vector
<std::string
>::const_iterator propend
,
71 std::vector
<std::string
> propertyPairs
;
72 bool generated
= false;
73 std::vector
<std::string
>::const_iterator j
;
74 // build the property pairs
75 for(j
= propbeg
; j
!= propend
;++j
)
77 // old style allows for specifier before PROPERTIES keyword
80 propertyPairs
.push_back("ABSTRACT");
81 propertyPairs
.push_back("1");
83 else if(*j
== "WRAP_EXCLUDE")
85 propertyPairs
.push_back("WRAP_EXCLUDE");
86 propertyPairs
.push_back("1");
88 else if(*j
== "GENERATED")
91 propertyPairs
.push_back("GENERATED");
92 propertyPairs
.push_back("1");
94 else if(*j
== "COMPILE_FLAGS")
96 propertyPairs
.push_back("COMPILE_FLAGS");
100 errors
= "called with incorrect number of arguments "
101 "COMPILE_FLAGS with no flags";
104 propertyPairs
.push_back(*j
);
106 else if(*j
== "OBJECT_DEPENDS")
108 propertyPairs
.push_back("OBJECT_DEPENDS");
112 errors
= "called with incorrect number of arguments "
113 "OBJECT_DEPENDS with no dependencies";
116 propertyPairs
.push_back(*j
);
118 else if(*j
== "PROPERTIES")
120 // now loop through the rest of the arguments, new style
122 bool dontPush
= false;
125 propertyPairs
.push_back(*j
);
126 if(*j
== "GENERATED")
129 if(j
!= propend
&& cmSystemTools::IsOn(j
->c_str()))
134 else if(*j
== "MACOSX_PACKAGE_LOCATION")
139 errors
= "called with incorrect number of arguments "
140 "MACOSX_PACKAGE_LOCATION with no flags";
143 propertyPairs
.push_back(*j
);
144 propertyPairs
.push_back("EXTRA_CONTENT");
145 propertyPairs
.push_back("1");
146 propertyPairs
.push_back("MACOSX_CONTENT");
147 propertyPairs
.push_back("1");
148 propertyPairs
.push_back("KEEP_EXTENSION");
149 propertyPairs
.push_back("1");
150 propertyPairs
.push_back("LANGUAGE");
151 propertyPairs
.push_back("MacOSX_Content");
160 errors
= "called with incorrect number of arguments.";
165 propertyPairs
.push_back(*j
);
170 // break out of the loop because j is already == end
175 errors
= "called with illegal arguments, maybe missing a "
176 "PROPERTIES specifier?";
181 // now loop over all the files
182 for(j
= filebeg
; j
!= fileend
;++j
)
184 // get the source file
186 mf
->GetOrCreateSource(j
->c_str(), generated
);
189 // now loop through all the props and set them
191 for (k
= 0; k
< propertyPairs
.size(); k
= k
+ 2)
193 sf
->SetProperty(propertyPairs
[k
].c_str(),propertyPairs
[k
+1].c_str());