KWSys Nightly Date Stamp
[cmake.git] / Source / cmGlobalXCodeGenerator.h
blobfac2801c33c3c7bcd2419344288fc3f1687bf8f3
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmGlobalXCodeGenerator.h,v $
5 Language: C++
6 Date: $Date: 2009-09-22 20:18:31 $
7 Version: $Revision: 1.63 $
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 cmGlobalXCodeGenerator_h
18 #define cmGlobalXCodeGenerator_h
20 #include "cmGlobalGenerator.h"
21 #include "cmXCodeObject.h"
22 #include "cmCustomCommand.h"
23 class cmTarget;
24 class cmSourceFile;
25 class cmSourceGroup;
28 /** \class cmGlobalXCodeGenerator
29 * \brief Write a Unix makefiles.
31 * cmGlobalXCodeGenerator manages UNIX build process for a tree
33 class cmGlobalXCodeGenerator : public cmGlobalGenerator
35 public:
36 cmGlobalXCodeGenerator();
37 static cmGlobalGenerator* New();
39 void SetVersion(int v) { this->XcodeVersion = v;}
40 ///! Get the name for the generator.
41 virtual const char* GetName() const {
42 return cmGlobalXCodeGenerator::GetActualName();}
43 static const char* GetActualName() {return "Xcode";}
45 /** Get the documentation entry for this generator. */
46 virtual void GetDocumentation(cmDocumentationEntry& entry) const;
48 ///! Create a local generator appropriate to this Global Generator
49 virtual cmLocalGenerator *CreateLocalGenerator();
51 /**
52 * Try to determine system infomation such as shared library
53 * extension, pthreads, byte order etc.
55 virtual void EnableLanguage(std::vector<std::string>const& languages,
56 cmMakefile *, bool optional);
57 /**
58 * Try running cmake and building a file. This is used for dynalically
59 * loaded commands, not as part of the usual build process.
61 virtual std::string GenerateBuildCommand(const char* makeProgram,
62 const char *projectName,
63 const char* additionalOptions,
64 const char *targetName,
65 const char* config,
66 bool ignoreErrors,
67 bool fast);
69 /**
70 * Generate the all required files for building this project/tree. This
71 * basically creates a series of LocalGenerators for each directory and
72 * requests that they Generate.
74 virtual void Generate();
76 /** Append the subdirectory for the given configuration. */
77 virtual void AppendDirectoryForConfig(const char* prefix,
78 const char* config,
79 const char* suffix,
80 std::string& dir);
82 ///! What is the configurations directory variable called?
83 virtual const char* GetCMakeCFGInitDirectory();
85 void GetTargetObjectFileDirectories(cmTarget* target,
86 std::vector<std::string>&
87 dirs);
88 void SetCurrentLocalGenerator(cmLocalGenerator*);
89 private:
90 cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget,
91 cmSourceGroup* sg);
92 void CreateGroups(cmLocalGenerator* root,
93 std::vector<cmLocalGenerator*>&
94 generators);
95 std::string XCodeEscapePath(const char* p);
96 std::string RelativeToSource(const char* p);
97 std::string RelativeToBinary(const char* p);
98 std::string ConvertToRelativeForXCode(const char* p);
99 std::string ConvertToRelativeForMake(const char* p);
100 void CreateCustomCommands(cmXCodeObject* buildPhases,
101 cmXCodeObject* sourceBuildPhase,
102 cmXCodeObject* headerBuildPhase,
103 cmXCodeObject* resourceBuildPhase,
104 std::vector<cmXCodeObject*> contentBuildPhases,
105 cmXCodeObject* frameworkBuildPhase,
106 cmTarget& cmtarget);
108 std::string ComputeInfoPListLocation(cmTarget& target);
110 void AddCommandsToBuildPhase(cmXCodeObject* buildphase,
111 cmTarget& target,
112 std::vector<cmCustomCommand>
113 const & commands,
114 const char* commandFileName);
116 void CreateCustomRulesMakefile(const char* makefileBasename,
117 cmTarget& target,
118 std::vector<cmCustomCommand> const & commands,
119 const char* configName,
120 const std::map<cmStdString, cmStdString>&
121 multipleOutputPairs
124 cmXCodeObject* FindXCodeTarget(cmTarget*);
125 // create cmXCodeObject from these functions so that memory can be managed
126 // correctly. All objects created are stored in this->XCodeObjects.
127 cmXCodeObject* CreateObject(cmXCodeObject::PBXType ptype);
128 cmXCodeObject* CreateObject(cmXCodeObject::Type type);
129 cmXCodeObject* CreateString(const char* s);
130 cmXCodeObject* CreateObjectReference(cmXCodeObject*);
131 cmXCodeObject* CreateXCodeTarget(cmTarget& target,
132 cmXCodeObject* buildPhases);
133 void ForceLinkerLanguages();
134 void ForceLinkerLanguage(cmTarget& cmtarget);
135 const char* GetTargetFileType(cmTarget& cmtarget);
136 const char* GetTargetProductType(cmTarget& cmtarget);
137 std::string AddConfigurations(cmXCodeObject* target, cmTarget& cmtarget);
138 void AppendOrAddBuildSetting(cmXCodeObject* settings, const char* attr,
139 const char* value);
140 void AppendBuildSettingAttribute(cmXCodeObject* target, const char* attr,
141 const char* value, const char* configName);
142 cmXCodeObject* CreateUtilityTarget(cmTarget& target);
143 void AddDependAndLinkInformation(cmXCodeObject* target);
144 void CreateBuildSettings(cmTarget& target,
145 cmXCodeObject* buildSettings,
146 const char* buildType);
147 std::string ExtractFlag(const char* flag, std::string& flags);
148 // delete all objects in the this->XCodeObjects vector.
149 void ClearXCodeObjects();
150 void CreateXCodeObjects(cmLocalGenerator* root,
151 std::vector<cmLocalGenerator*>& generators);
152 void OutputXCodeProject(cmLocalGenerator* root,
153 std::vector<cmLocalGenerator*>& generators);
154 void WriteXCodePBXProj(std::ostream& fout, cmLocalGenerator* root,
155 std::vector<cmLocalGenerator*>& generators);
156 cmXCodeObject* CreateXCodeFileReference(cmSourceFile* sf,
157 cmTarget& cmtarget);
158 cmXCodeObject* CreateXCodeSourceFile(cmLocalGenerator* gen,
159 cmSourceFile* sf,
160 cmTarget& cmtarget);
161 void CreateXCodeTargets(cmLocalGenerator* gen,
162 std::vector<cmXCodeObject*>&);
163 bool IsHeaderFile(cmSourceFile*);
164 void AddDependTarget(cmXCodeObject* target,
165 cmXCodeObject* dependTarget);
166 void CreateXCodeDependHackTarget(std::vector<cmXCodeObject*>& targets);
167 bool SpecialTargetEmitted(std::string const& tname);
168 void SetGenerationRoot(cmLocalGenerator* root);
169 void AddExtraTargets(cmLocalGenerator* root,
170 std::vector<cmLocalGenerator*>& gens);
171 cmXCodeObject* CreateBuildPhase(const char* name,
172 const char* name2,
173 cmTarget& cmtarget,
174 const std::vector<cmCustomCommand>&);
175 void CreateReRunCMakeFile(cmLocalGenerator* root);
177 std::string LookupFlags(const char* varNamePrefix,
178 const char* varNameLang,
179 const char* varNameSuffix,
180 const char* default_flags);
182 class BuildObjectListOrString;
183 friend class BuildObjectListOrString;
185 void AppendDefines(BuildObjectListOrString& defs, const char* defines_list,
186 bool dflag = false);
187 void AppendDefines(BuildObjectListOrString& defs,
188 std::vector<std::string> const& defines,
189 bool dflag = false);
190 void AppendFlag(std::string& flags, std::string const& flag);
192 protected:
193 virtual const char* GetInstallTargetName() { return "install"; }
194 virtual const char* GetPackageTargetName() { return "package"; }
196 int XcodeVersion;
197 std::vector<cmXCodeObject*> XCodeObjects;
198 cmXCodeObject* RootObject;
199 private:
200 cmXCodeObject* MainGroupChildren;
201 cmXCodeObject* SourcesGroupChildren;
202 cmXCodeObject* ResourcesGroupChildren;
203 cmMakefile* CurrentMakefile;
204 cmLocalGenerator* CurrentLocalGenerator;
205 std::vector<std::string> CurrentConfigurationTypes;
206 std::string CurrentReRunCMakeMakefile;
207 std::string CurrentXCodeHackMakefile;
208 std::string CurrentProject;
209 std::set<cmStdString> TargetDoneSet;
210 std::vector<std::string> CurrentOutputDirectoryComponents;
211 std::vector<std::string> ProjectSourceDirectoryComponents;
212 std::vector<std::string> ProjectOutputDirectoryComponents;
213 std::map<cmStdString, cmXCodeObject* > GroupMap;
214 std::map<cmStdString, cmXCodeObject* > GroupNameMap;
215 std::map<cmStdString, cmXCodeObject* > TargetGroup;
216 std::map<cmStdString, cmXCodeObject* > FileRefs;
217 std::vector<std::string> Architectures;
220 #endif