Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmMakefileTargetGenerator.h
blob0e8477e25882e529a3b3a0a4c7e7915a2efc08c3
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmMakefileTargetGenerator.h,v $
5 Language: C++
6 <<<<<<< cmMakefileTargetGenerator.h
7 Date: $Date: 2008/02/27 22:10:45 $
8 Version: $Revision: 1.24 $
9 =======
10 Date: $Date: 2008-04-08 04:06:46 $
11 Version: $Revision: 1.25 $
12 >>>>>>> 1.25
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 #ifndef cmMakefileTargetGenerator_h
23 #define cmMakefileTargetGenerator_h
25 #include "cmLocalUnixMakefileGenerator3.h"
27 class cmCustomCommand;
28 class cmDependInformation;
29 class cmDepends;
30 class cmGeneratedFileStream;
31 class cmGlobalUnixMakefileGenerator3;
32 class cmLocalUnixMakefileGenerator3;
33 class cmMakefile;
34 class cmTarget;
35 class cmSourceFile;
37 /** \class cmMakefileTargetGenerator
38 * \brief Support Routines for writing makefiles
41 class cmMakefileTargetGenerator
43 public:
44 // constructor to set the ivars
45 cmMakefileTargetGenerator(cmTarget* target);
46 virtual ~cmMakefileTargetGenerator() {};
48 // construct using this factory call
49 static cmMakefileTargetGenerator *New(cmTarget *tgt);
51 /* the main entry point for this class. Writes the Makefiles associated
52 with this target */
53 virtual void WriteRuleFiles() = 0;
55 /* the main entry point for this class. Writes the Makefiles associated
56 with this target */
57 virtual void WriteProgressVariables(unsigned long total,
58 unsigned long &current);
60 /* return the number of actions that have progress reporting on them */
61 virtual unsigned long GetNumberOfProgressActions() {
62 return this->NumberOfProgressActions;}
64 cmTarget* GetTarget() { return this->Target;}
65 protected:
67 // create the file and directory etc
68 void CreateRuleFile();
70 // outputs the rules for object files and custom commands used by
71 // this target
72 void WriteTargetBuildRules();
74 // write some common code at the top of build.make
75 void WriteCommonCodeRules();
76 void WriteTargetLanguageFlags();
78 // write the provide require rules for this target
79 void WriteTargetRequiresRules();
81 // write the clean rules for this target
82 void WriteTargetCleanRules();
84 // write the depend rules for this target
85 void WriteTargetDependRules();
87 // write rules for Mac OS X Application Bundle content.
88 void WriteMacOSXContentRules(cmSourceFile& source, const char* pkgloc);
90 // write the rules for an object
91 void WriteObjectRuleFiles(cmSourceFile& source);
93 // write the build rule for an object
94 void WriteObjectBuildFile(std::string &obj,
95 const char *lang,
96 cmSourceFile& source,
97 std::vector<std::string>& depends);
99 // write the depend.make file for an object
100 void WriteObjectDependRules(cmSourceFile& source,
101 std::vector<std::string>& depends);
103 // write the build rule for a custom command
104 void GenerateCustomRuleFile(const cmCustomCommand& cc);
106 // write a rule to drive building of more than one output from
107 // another rule
108 void GenerateExtraOutput(const char* out, const char* in,
109 bool symbolic = false);
111 // write out the variable that lists the objects for this target
112 void WriteObjectsVariable(std::string& variableName,
113 std::string& variableNameExternal);
114 void WriteObjectsString(std::string& buildObjs);
115 void WriteObjectsStrings(std::vector<std::string>& objStrings,
116 std::string::size_type limit = std::string::npos);
118 // write the driver rule to build target outputs
119 void WriteTargetDriverRule(const char* main_output, bool relink);
121 void DriveCustomCommands(std::vector<std::string>& depends);
123 // Return the a string with -F flags on apple
124 std::string GetFrameworkFlags();
126 // append intertarget dependencies
127 void AppendTargetDepends(std::vector<std::string>& depends);
129 /** In order to support parallel builds for custom commands with
130 multiple outputs the outputs are given a serial order, and only
131 the first output actually has the build rule. Other outputs
132 just depend on the first one. The check-build-system step must
133 remove a dependee if the depender is missing to make sure both
134 are regenerated properly. This method is used by the local
135 makefile generators to register such pairs. */
136 void AddMultipleOutputPair(const char* depender, const char* dependee);
138 /** Create a script to hold link rules and a command to invoke the
139 script at build time. */
140 void CreateLinkScript(const char* name,
141 std::vector<std::string> const& link_commands,
142 std::vector<std::string>& makefile_commands,
143 std::vector<std::string>& makefile_depends);
145 /** Create a response file with the given set of options. Returns
146 the relative path from the target build working directory to the
147 response file name. */
148 std::string CreateResponseFile(const char* name,
149 std::string const& options,
150 std::vector<std::string>& makefile_depends);
152 virtual void CloseFileStreams();
153 void RemoveForbiddenFlags(const char* flagVar, const char* linkLang,
154 std::string& linkFlags);
155 cmTarget *Target;
156 cmLocalUnixMakefileGenerator3 *LocalGenerator;
157 cmGlobalUnixMakefileGenerator3 *GlobalGenerator;
158 cmMakefile *Makefile;
160 enum CustomCommandDriveType { OnBuild, OnDepends, OnUtility };
161 CustomCommandDriveType CustomCommandDriver;
163 // the full path to the build file
164 std::string BuildFileName;
165 std::string BuildFileNameFull;
167 // the full path to the progress file
168 std::string ProgressFileName;
169 std::string ProgressFileNameFull;
170 unsigned long NumberOfProgressActions;
172 // the path to the directory the build file is in
173 std::string TargetBuildDirectory;
174 std::string TargetBuildDirectoryFull;
176 // the stream for the build file
177 cmGeneratedFileStream *BuildFileStream;
179 // the stream for the flag file
180 std::string FlagFileNameFull;
181 cmGeneratedFileStream *FlagFileStream;
183 // the stream for the info file
184 std::string InfoFileNameFull;
185 cmGeneratedFileStream *InfoFileStream;
187 // files to clean
188 std::vector<std::string> CleanFiles;
190 // objects used by this target
191 std::vector<std::string> Objects;
192 std::vector<std::string> ExternalObjects;
194 // Set of object file names that will be built in this directory.
195 std::set<cmStdString> ObjectFiles;
197 // Set of extra output files to be driven by the build.
198 std::set<cmStdString> ExtraFiles;
200 typedef std::map<cmStdString, cmStdString> MultipleOutputPairsType;
201 MultipleOutputPairsType MultipleOutputPairs;
203 // Target name info.
204 std::string TargetNameOut;
205 std::string TargetNameSO;
206 std::string TargetNameReal;
207 std::string TargetNameImport;
208 std::string TargetNamePDB;
210 // Mac OS X content info.
211 std::string MacContentDirectory;
212 std::set<cmStdString> MacContentFolders;
214 // Target-wide Fortran module output directory.
215 bool FortranModuleDirectoryComputed;
216 std::string FortranModuleDirectory;
217 const char* GetFortranModuleDirectory();
219 // Compute target-specific Fortran language flags.
220 void AddFortranFlags(std::string& flags);
222 //==================================================================
223 // Convenience routines that do nothing more than forward to
224 // implementaitons
225 std::string Convert(const char* source,
226 cmLocalGenerator::RelativeRoot relative,
227 cmLocalGenerator::OutputFormat output =
228 cmLocalGenerator::UNCHANGED,
229 bool optional = false)
231 return this->LocalGenerator->Convert(source, relative, output, optional);
236 #endif