Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmGlobalXCodeGenerator.h
blob54b13a8a0dd4e2c9ce80922998e8ea67f24fdeeb
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmGlobalXCodeGenerator.h,v $
5 Language: C++
6 Date: $Date: 2009-03-16 18:30:24 $
7 Version: $Revision: 1.56 $
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() { return "."; }
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 ConvertToRelativeForXCode(const char* p);
97 std::string ConvertToRelativeForMake(const char* p);
98 void CreateCustomCommands(cmXCodeObject* buildPhases,
99 cmXCodeObject* sourceBuildPhase,
100 cmXCodeObject* headerBuildPhase,
101 cmXCodeObject* resourceBuildPhase,
102 std::vector<cmXCodeObject*> contentBuildPhases,
103 cmXCodeObject* frameworkBuildPhase,
104 cmTarget& cmtarget);
106 std::string ComputeInfoPListLocation(cmTarget& target);
108 void AddCommandsToBuildPhase(cmXCodeObject* buildphase,
109 cmTarget& target,
110 std::vector<cmCustomCommand>
111 const & commands,
112 const char* commandFileName);
114 void CreateCustomRulesMakefile(const char* makefileBasename,
115 cmTarget& target,
116 std::vector<cmCustomCommand> const & commands,
117 const char* configName,
118 const std::map<cmStdString, cmStdString>&
119 multipleOutputPairs
122 cmXCodeObject* FindXCodeTarget(cmTarget*);
123 // create cmXCodeObject from these functions so that memory can be managed
124 // correctly. All objects created are stored in this->XCodeObjects.
125 cmXCodeObject* CreateObject(cmXCodeObject::PBXType ptype);
126 cmXCodeObject* CreateObject(cmXCodeObject::Type type);
127 cmXCodeObject* CreateString(const char* s);
128 cmXCodeObject* CreateObjectReference(cmXCodeObject*);
129 cmXCodeObject* CreateXCodeTarget(cmTarget& target,
130 cmXCodeObject* buildPhases);
131 void AddConfigurations(cmXCodeObject* target,
132 cmTarget& cmtarget);
133 void AppendOrAddBuildSetting(cmXCodeObject* settings, const char* attr,
134 const char* value);
135 void AppendBuildSettingAttribute(cmXCodeObject* target, const char* attr,
136 const char* value, const char* configName);
137 cmXCodeObject* CreateUtilityTarget(cmTarget& target);
138 void AddDependAndLinkInformation(cmXCodeObject* target);
139 void CreateBuildSettings(cmTarget& target,
140 cmXCodeObject* buildSettings,
141 std::string& fileType,
142 std::string& productType,
143 std::string& projectName,
144 const char* buildType);
145 std::string ExtractFlag(const char* flag, std::string& flags);
146 // delete all objects in the this->XCodeObjects vector.
147 void ClearXCodeObjects();
148 void CreateXCodeObjects(cmLocalGenerator* root,
149 std::vector<cmLocalGenerator*>& generators);
150 void OutputXCodeProject(cmLocalGenerator* root,
151 std::vector<cmLocalGenerator*>& generators);
152 virtual void WriteXCodePBXProj(std::ostream& fout,
153 cmLocalGenerator* root,
154 std::vector<cmLocalGenerator*>& generators);
155 cmXCodeObject* CreateXCodeFileReference(cmSourceFile* sf,
156 cmTarget& cmtarget);
157 cmXCodeObject* CreateXCodeSourceFile(cmLocalGenerator* gen,
158 cmSourceFile* sf,
159 cmTarget& cmtarget);
160 void CreateXCodeTargets(cmLocalGenerator* gen,
161 std::vector<cmXCodeObject*>&);
162 bool IsHeaderFile(cmSourceFile*);
163 void AddDependTarget(cmXCodeObject* target,
164 cmXCodeObject* dependTarget);
165 void CreateXCodeDependHackTarget(std::vector<cmXCodeObject*>& targets);
166 bool SpecialTargetEmitted(std::string const& tname);
167 void SetGenerationRoot(cmLocalGenerator* root);
168 void AddExtraTargets(cmLocalGenerator* root,
169 std::vector<cmLocalGenerator*>& gens);
170 cmXCodeObject* CreateBuildPhase(const char* name,
171 const char* name2,
172 cmTarget& cmtarget,
173 const std::vector<cmCustomCommand>&);
174 void CreateReRunCMakeFile(cmLocalGenerator* root);
176 std::string LookupFlags(const char* varNamePrefix,
177 const char* varNameLang,
178 const char* varNameSuffix,
179 const char* default_flags);
181 void AppendDefines(std::string& defs, const char* defines_list,
182 bool dflag = false);
184 protected:
185 virtual const char* GetInstallTargetName() { return "install"; }
186 virtual const char* GetPackageTargetName() { return "package"; }
188 int XcodeVersion;
189 std::vector<cmXCodeObject*> XCodeObjects;
190 cmXCodeObject* RootObject;
191 private:
192 cmXCodeObject* MainGroupChildren;
193 cmXCodeObject* SourcesGroupChildren;
194 cmXCodeObject* ResourcesGroupChildren;
195 cmMakefile* CurrentMakefile;
196 cmLocalGenerator* CurrentLocalGenerator;
197 std::vector<std::string> CurrentConfigurationTypes;
198 std::string CurrentReRunCMakeMakefile;
199 std::string CurrentXCodeHackMakefile;
200 std::string CurrentProject;
201 std::set<cmStdString> TargetDoneSet;
202 std::vector<std::string> CurrentOutputDirectoryComponents;
203 std::vector<std::string> ProjectOutputDirectoryComponents;
204 std::map<cmStdString, cmXCodeObject* > GroupMap;
205 std::map<cmStdString, cmXCodeObject* > GroupNameMap;
206 std::map<cmStdString, cmXCodeObject* > TargetGroup;
207 std::map<cmStdString, cmXCodeObject* > FileRefs;
208 std::vector<std::string> Architectures;
211 #endif