ENH: keep cleaning up Tcl/Tk modules
[cmake.git] / Source / cmMakefileTargetGenerator.h
blob5d36b636d46585bbd9d6682a4fb0fd111dffbdbc
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmMakefileTargetGenerator.h,v $
5 Language: C++
6 Date: $Date: 2007-12-30 21:11:38 $
7 Version: $Revision: 1.19 $
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 #ifndef cmMakefileTargetGenerator_h
18 #define cmMakefileTargetGenerator_h
20 #include "cmLocalUnixMakefileGenerator3.h"
22 class cmCustomCommand;
23 class cmDependInformation;
24 class cmDepends;
25 class cmGeneratedFileStream;
26 class cmGlobalUnixMakefileGenerator3;
27 class cmLocalUnixMakefileGenerator3;
28 class cmMakefile;
29 class cmTarget;
30 class cmSourceFile;
32 /** \class cmMakefileTargetGenerator
33 * \brief Support Routines for writing makefiles
36 class cmMakefileTargetGenerator
38 public:
39 // constructor to set the ivars
40 cmMakefileTargetGenerator();
41 virtual ~cmMakefileTargetGenerator() {};
43 // construct using this factory call
44 static cmMakefileTargetGenerator *New(cmLocalUnixMakefileGenerator3 *lg,
45 cmStdString tgtName,
46 cmTarget *tgt);
48 /* the main entry point for this class. Writes the Makefiles associated
49 with this target */
50 virtual void WriteRuleFiles() = 0;
52 /* the main entry point for this class. Writes the Makefiles associated
53 with this target */
54 virtual void WriteProgressVariables(unsigned long total,
55 unsigned long &current);
57 /* return the number of actions that have progress reporting on them */
58 virtual unsigned long GetNumberOfProgressActions() {
59 return this->NumberOfProgressActions;}
61 const char *GetTargetName() { return this->TargetName.c_str(); }
62 cmTarget* GetTarget() { return this->Target;}
63 protected:
65 // create the file and directory etc
66 void CreateRuleFile();
68 // outputs the rules for object files and custom commands used by
69 // this target
70 void WriteTargetBuildRules();
72 // write some common code at the top of build.make
73 void WriteCommonCodeRules();
74 void WriteTargetLanguageFlags();
76 // write the provide require rules for this target
77 void WriteTargetRequiresRules();
79 // write the clean rules for this target
80 void WriteTargetCleanRules();
82 // write the depend rules for this target
83 void WriteTargetDependRules();
85 // write the rules for an object
86 void WriteObjectRuleFiles(cmSourceFile& source);
88 // write the build rule for an object
89 void WriteObjectBuildFile(std::string &obj,
90 const char *lang,
91 cmSourceFile& source,
92 std::vector<std::string>& depends);
94 // write the depend.make file for an object
95 void WriteObjectDependRules(cmSourceFile& source,
96 std::vector<std::string>& depends);
98 // write the build rule for a custom command
99 void GenerateCustomRuleFile(const cmCustomCommand& cc);
101 // write a rule to drive building of more than one output from
102 // another rule
103 void GenerateExtraOutput(const char* out, const char* in,
104 bool symbolic = false);
106 // write out the variable that lists the objects for this target
107 void WriteObjectsVariable(std::string& variableName,
108 std::string& variableNameExternal);
109 void WriteObjectsString(std::string& buildObjs);
111 // write the driver rule to build target outputs
112 void WriteTargetDriverRule(const char* main_output, bool relink);
114 void DriveCustomCommands(std::vector<std::string>& depends);
116 // Return the a string with -F flags on apple
117 std::string GetFrameworkFlags();
119 // append intertarget dependencies
120 void AppendTargetDepends(std::vector<std::string>& depends);
122 /** In order to support parallel builds for custom commands with
123 multiple outputs the outputs are given a serial order, and only
124 the first output actually has the build rule. Other outputs
125 just depend on the first one. The check-build-system step must
126 remove a dependee if the depender is missing to make sure both
127 are regenerated properly. This method is used by the local
128 makefile generators to register such pairs. */
129 void AddMultipleOutputPair(const char* depender, const char* dependee);
131 /** Create a script to hold link rules and a command to invoke the
132 script at build time. */
133 void CreateLinkScript(const char* name,
134 std::vector<std::string> const& link_commands,
135 std::vector<std::string>& makefile_commands);
137 virtual void CloseFileStreams();
138 void RemoveForbiddenFlags(const char* flagVar, const char* linkLang,
139 std::string& linkFlags);
140 cmStdString TargetName;
141 cmTarget *Target;
142 cmLocalUnixMakefileGenerator3 *LocalGenerator;
143 cmGlobalUnixMakefileGenerator3 *GlobalGenerator;
144 cmMakefile *Makefile;
146 enum CustomCommandDriveType { OnBuild, OnDepends, OnUtility };
147 CustomCommandDriveType CustomCommandDriver;
149 // the full path to the build file
150 std::string BuildFileName;
151 std::string BuildFileNameFull;
153 // the full path to the progress file
154 std::string ProgressFileName;
155 std::string ProgressFileNameFull;
156 unsigned long NumberOfProgressActions;
158 // the path to the directory the build file is in
159 std::string TargetBuildDirectory;
160 std::string TargetBuildDirectoryFull;
162 // the stream for the build file
163 cmGeneratedFileStream *BuildFileStream;
165 // the stream for the flag file
166 std::string FlagFileNameFull;
167 cmGeneratedFileStream *FlagFileStream;
169 // the stream for the info file
170 std::string InfoFileNameFull;
171 cmGeneratedFileStream *InfoFileStream;
173 // files to clean
174 std::vector<std::string> CleanFiles;
176 // objects used by this target
177 std::vector<std::string> Objects;
178 std::vector<std::string> ExternalObjects;
179 std::set<std::string> ExtraContent;
181 // Set of object file names that will be built in this directory.
182 std::set<cmStdString> ObjectFiles;
184 typedef std::map<cmStdString, cmStdString> MultipleOutputPairsType;
185 MultipleOutputPairsType MultipleOutputPairs;
187 // Target-wide Fortran module output directory.
188 bool FortranModuleDirectoryComputed;
189 std::string FortranModuleDirectory;
190 const char* GetFortranModuleDirectory();
192 // Compute target-specific Fortran language flags.
193 void AddFortranFlags(std::string& flags);
195 //==================================================================
196 // Convenience routines that do nothing more than forward to
197 // implementaitons
198 std::string Convert(const char* source,
199 cmLocalGenerator::RelativeRoot relative,
200 cmLocalGenerator::OutputFormat output =
201 cmLocalGenerator::UNCHANGED,
202 bool optional = false)
204 return this->LocalGenerator->Convert(source, relative, output, optional);
209 #endif