1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmGlobalXCodeGenerator.h,v $
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"
28 /** \class cmGlobalXCodeGenerator
29 * \brief Write a Unix makefiles.
31 * cmGlobalXCodeGenerator manages UNIX build process for a tree
33 class cmGlobalXCodeGenerator
: public cmGlobalGenerator
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();
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
);
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
,
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
,
82 ///! What is the configurations directory variable called?
83 virtual const char* GetCMakeCFGInitDirectory() { return "."; }
85 void GetTargetObjectFileDirectories(cmTarget
* target
,
86 std::vector
<std::string
>&
88 void SetCurrentLocalGenerator(cmLocalGenerator
*);
90 cmXCodeObject
* CreateOrGetPBXGroup(cmTarget
& cmtarget
,
92 void CreateGroups(cmLocalGenerator
* root
,
93 std::vector
<cmLocalGenerator
*>&
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
,
106 std::string
ComputeInfoPListLocation(cmTarget
& target
);
108 void AddCommandsToBuildPhase(cmXCodeObject
* buildphase
,
110 std::vector
<cmCustomCommand
>
112 const char* commandFileName
);
114 void CreateCustomRulesMakefile(const char* makefileBasename
,
116 std::vector
<cmCustomCommand
> const & commands
,
117 const char* configName
,
118 const std::map
<cmStdString
, cmStdString
>&
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
,
133 void AppendOrAddBuildSetting(cmXCodeObject
* settings
, const char* attr
,
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
,
157 cmXCodeObject
* CreateXCodeSourceFile(cmLocalGenerator
* gen
,
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
,
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
,
185 virtual const char* GetInstallTargetName() { return "install"; }
186 virtual const char* GetPackageTargetName() { return "package"; }
189 std::vector
<cmXCodeObject
*> XCodeObjects
;
190 cmXCodeObject
* RootObject
;
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
;