Updated formatting of documentation plus a little reorganization.
[cmake.git] / Source / cmGlobalUnixMakefileGenerator3.h
blobfad360625628433d339d39ae979933a95815e35d
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator3
4 Module: $RCSfile: cmGlobalUnixMakefileGenerator3.h,v $
5 Language: C++
6 Date: $Date: 2009-06-25 13:58:50 $
7 Version: $Revision: 1.58 $
9 Copyright (c) 2005 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 cmGlobalUnixMakefileGenerator3_h
18 #define cmGlobalUnixMakefileGenerator3_h
20 #include "cmGlobalGenerator.h"
22 class cmGeneratedFileStream;
23 class cmMakefileTargetGenerator;
24 class cmLocalUnixMakefileGenerator3;
26 /** \class cmGlobalUnixMakefileGenerator3
27 * \brief Write a Unix makefiles.
29 * cmGlobalUnixMakefileGenerator3 manages UNIX build process for a tree
32 The basic approach of this generator is to produce Makefiles that will all
33 be run with the current working directory set to the Home Output
34 directory. The one exception to this is the subdirectory Makefiles which are
35 created as a convenience and just cd up to the Home Output directory and
36 invoke the main Makefiles.
38 The make process starts with Makefile. Makefile should only contain the
39 targets the user is likely to invoke directly from a make command line. No
40 internal targets should be in this file. Makefile2 contains the internal
41 targets that are required to make the process work.
43 Makefile2 in turn will recursively make targets in the correct order. Each
44 target has its own directory <target>.dir and its own makefile build.make in
45 that directory. Also in that directory is a couple makefiles per source file
46 used by the target. Typically these are named source.obj.build.make and
47 source.obj.build.depend.make. The source.obj.build.make contains the rules
48 for building, cleaning, and computing dependencies for the given source
49 file. The build.depend.make contains additional dependencies that were
50 computed during dependency scanning. An additional file called
51 source.obj.depend is used as a marker to indicate when dependencies must be
52 rescanned.
54 Rules for custom commands follow the same model as rules for source files.
58 class cmGlobalUnixMakefileGenerator3 : public cmGlobalGenerator
60 public:
61 cmGlobalUnixMakefileGenerator3();
62 static cmGlobalGenerator* New() {
63 return new cmGlobalUnixMakefileGenerator3; }
65 ///! Get the name for the generator.
66 virtual const char* GetName() const {
67 return cmGlobalUnixMakefileGenerator3::GetActualName();}
68 static const char* GetActualName() {return "Unix Makefiles";}
70 /** Get the documentation entry for this generator. */
71 virtual void GetDocumentation(cmDocumentationEntry& entry) const;
73 ///! Create a local generator appropriate to this Global Generator3
74 virtual cmLocalGenerator *CreateLocalGenerator();
76 /**
77 * Try to determine system infomation such as shared library
78 * extension, pthreads, byte order etc.
80 virtual void EnableLanguage(std::vector<std::string>const& languages,
81 cmMakefile *, bool optional);
83 /**
84 * Generate the all required files for building this project/tree. This
85 * basically creates a series of LocalGenerators for each directory and
86 * requests that they Generate.
88 virtual void Generate();
91 void WriteMainCMakefileLanguageRules(cmGeneratedFileStream& cmakefileStream,
92 std::vector<cmLocalGenerator *> &);
94 // write out the help rule listing the valid targets
95 void WriteHelpRule(std::ostream& ruleFileStream,
96 cmLocalUnixMakefileGenerator3 *);
98 // write the top lvel target rules
99 void WriteConvenienceRules(std::ostream& ruleFileStream,
100 std::set<cmStdString> &emitted);
102 /** Get the command to use for a target that has no rule. This is
103 used for multiple output dependencies and for cmake_force. */
104 std::string GetEmptyRuleHackCommand() { return this->EmptyRuleHackCommand; }
106 /** Get the fake dependency to use when a rule has no real commands
107 or dependencies. */
108 std::string GetEmptyRuleHackDepends() { return this->EmptyRuleHackDepends; }
110 // change the build command for speed
111 virtual std::string GenerateBuildCommand
112 (const char* makeProgram,
113 const char *projectName, const char* additionalOptions,
114 const char *targetName,
115 const char* config, bool ignoreErrors, bool fast);
117 /** Record per-target progress information. */
118 void RecordTargetProgress(cmMakefileTargetGenerator* tg);
121 * If true, the CMake variable CMAKE_VERBOSE_MAKEFILES doesn't have effect
122 * anymore. Set it to true when writing a generator where short output
123 * doesn't make sense, e.g. because the full output is parsed by an
124 * IDE/editor.
126 bool GetForceVerboseMakefiles() { return this->ForceVerboseMakefiles; }
127 void SetForceVerboseMakefiles(bool enable)
128 {this->ForceVerboseMakefiles=enable;}
130 protected:
131 void WriteMainMakefile2();
132 void WriteMainCMakefile();
134 void WriteConvenienceRules2(std::ostream& ruleFileStream,
135 cmLocalUnixMakefileGenerator3*);
137 void WriteDirectoryRule2(std::ostream& ruleFileStream,
138 cmLocalUnixMakefileGenerator3* lg,
139 const char* pass, bool check_all,
140 bool check_relink);
141 void WriteDirectoryRules2(std::ostream& ruleFileStream,
142 cmLocalUnixMakefileGenerator3* lg);
144 void AppendGlobalTargetDepends(std::vector<std::string>& depends,
145 cmTarget& target);
147 // does this generator need a requires step for any of its targets
148 bool NeedRequiresStep(cmTarget const&);
150 // Setup target names
151 virtual const char* GetAllTargetName() { return "all"; }
152 virtual const char* GetInstallTargetName() { return "install"; }
153 virtual const char* GetInstallLocalTargetName() { return "install/local"; }
154 virtual const char* GetInstallStripTargetName() { return "install/strip"; }
155 virtual const char* GetPreinstallTargetName() { return "preinstall"; }
156 virtual const char* GetTestTargetName() { return "test"; }
157 virtual const char* GetPackageTargetName() { return "package"; }
158 virtual const char* GetPackageSourceTargetName(){ return "package_source"; }
159 virtual const char* GetEditCacheTargetName() { return "edit_cache"; }
160 virtual const char* GetRebuildCacheTargetName() { return "rebuild_cache"; }
161 virtual const char* GetCleanTargetName() { return "clean"; }
163 virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() { return true; }
165 // Some make programs (Borland) do not keep a rule if there are no
166 // dependencies or commands. This is a problem for creating rules
167 // that might not do anything but might have other dependencies
168 // added later. If non-empty this variable holds a fake dependency
169 // that can be added.
170 std::string EmptyRuleHackDepends;
172 // Some make programs (Watcom) do not like rules with no commands.
173 // If non-empty this variable holds a bogus command that may be put
174 // in the rule to satisfy the make program.
175 std::string EmptyRuleHackCommand;
177 bool ForceVerboseMakefiles;
179 // Store per-target progress counters.
180 struct TargetProgress
182 TargetProgress(): NumberOfActions(0) {}
183 unsigned long NumberOfActions;
184 std::string VariableFile;
185 std::vector<int> Marks;
186 void WriteProgressVariables(unsigned long total, unsigned long& current);
188 typedef std::map<cmStdString, TargetProgress> ProgressMapType;
189 ProgressMapType ProgressMap;
191 size_t CountProgressMarksInTarget(cmTarget* target,
192 std::set<cmTarget*>& emitted);
193 size_t CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg);
196 #endif