STYLE: Nightly Date Stamp
[cmake.git] / Source / cmGlobalXCodeGenerator.h
blob2e74d0d3866a4cbec2352f73a6a75ecc8e588e13
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmGlobalXCodeGenerator.h,v $
5 Language: C++
6 Date: $Date: 2008-07-03 17:28:54 $
7 Version: $Revision: 1.53 $
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* CreateXCodeSourceFile(cmLocalGenerator* gen,
156 cmSourceFile* sf,
157 cmTarget& cmtarget);
158 void CreateXCodeTargets(cmLocalGenerator* gen,
159 std::vector<cmXCodeObject*>&);
160 void AddDependTarget(cmXCodeObject* target,
161 cmXCodeObject* dependTarget);
162 void CreateXCodeDependHackTarget(std::vector<cmXCodeObject*>& targets);
163 bool SpecialTargetEmitted(std::string const& tname);
164 void SetGenerationRoot(cmLocalGenerator* root);
165 void AddExtraTargets(cmLocalGenerator* root,
166 std::vector<cmLocalGenerator*>& gens);
167 cmXCodeObject* CreateBuildPhase(const char* name,
168 const char* name2,
169 cmTarget& cmtarget,
170 const std::vector<cmCustomCommand>&);
171 void CreateReRunCMakeFile(cmLocalGenerator* root);
173 std::string LookupFlags(const char* varNamePrefix,
174 const char* varNameLang,
175 const char* varNameSuffix,
176 const char* default_flags);
178 void AppendDefines(std::string& defs, const char* defines_list,
179 bool dflag = false);
181 protected:
182 virtual const char* GetInstallTargetName() { return "install"; }
183 virtual const char* GetPackageTargetName() { return "package"; }
185 int XcodeVersion;
186 std::vector<cmXCodeObject*> XCodeObjects;
187 cmXCodeObject* RootObject;
188 private:
189 cmXCodeObject* MainGroupChildren;
190 cmXCodeObject* SourcesGroupChildren;
191 cmXCodeObject* ResourcesGroupChildren;
192 cmMakefile* CurrentMakefile;
193 cmLocalGenerator* CurrentLocalGenerator;
194 std::vector<std::string> CurrentConfigurationTypes;
195 std::string CurrentReRunCMakeMakefile;
196 std::string CurrentXCodeHackMakefile;
197 std::string CurrentProject;
198 std::set<cmStdString> TargetDoneSet;
199 std::vector<std::string> CurrentOutputDirectoryComponents;
200 std::vector<std::string> ProjectOutputDirectoryComponents;
201 std::map<cmStdString, cmXCodeObject* > GroupMap;
202 std::map<cmStdString, cmXCodeObject* > GroupNameMap;
203 std::map<cmStdString, cmXCodeObject* > TargetGroup;
204 std::map<cmStdString, cmXCodeObject* > FileRefs;
205 std::vector<std::string> Architectures;
208 #endif