cmGlobalXCodeGenerator.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmGlobalXCodeGenerator_h
  14. #define cmGlobalXCodeGenerator_h
  15. #include "cmGlobalGenerator.h"
  16. #include "cmXCodeObject.h"
  17. #include "cmCustomCommand.h"
  18. class cmTarget;
  19. class cmSourceFile;
  20. class cmSourceGroup;
  21. /** \class cmGlobalXCodeGenerator
  22. * \brief Write a Unix makefiles.
  23. *
  24. * cmGlobalXCodeGenerator manages UNIX build process for a tree
  25. */
  26. class cmGlobalXCodeGenerator : public cmGlobalGenerator
  27. {
  28. public:
  29. cmGlobalXCodeGenerator();
  30. static cmGlobalGenerator* New() { return new cmGlobalXCodeGenerator; }
  31. ///! Get the name for the generator.
  32. virtual const char* GetName() const {
  33. return cmGlobalXCodeGenerator::GetActualName();}
  34. static const char* GetActualName() {return "XCode";}
  35. /** Get the documentation entry for this generator. */
  36. virtual void GetDocumentation(cmDocumentationEntry& entry) const;
  37. ///! Create a local generator appropriate to this Global Generator
  38. virtual cmLocalGenerator *CreateLocalGenerator();
  39. /**
  40. * Try to determine system infomation such as shared library
  41. * extension, pthreads, byte order etc.
  42. */
  43. virtual void EnableLanguage(std::vector<std::string>const& languages,
  44. cmMakefile *);
  45. /**
  46. * Try running cmake and building a file. This is used for dynalically
  47. * loaded commands, not as part of the usual build process.
  48. */
  49. virtual std::string GenerateBuildCommand(const char* makeProgram,
  50. const char *projectName, const char *targetName, const char* config,
  51. bool ignoreErrors);
  52. /**
  53. * Generate the all required files for building this project/tree. This
  54. * basically creates a series of LocalGenerators for each directory and
  55. * requests that they Generate.
  56. */
  57. virtual void Generate();
  58. private:
  59. cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget,
  60. cmSourceGroup* sg);
  61. void CreateGroups(cmLocalGenerator* root,
  62. std::vector<cmLocalGenerator*>&
  63. generators);
  64. void SetCurrentLocalGenerator(cmLocalGenerator*);
  65. std::string XCodeEscapePath(const char* p);
  66. std::string ConvertToRelativeForXCode(const char* p);
  67. std::string ConvertToRelativeForMake(const char* p);
  68. void CreateCustomCommands(cmXCodeObject* buildPhases,
  69. cmXCodeObject* sourceBuildPhase,
  70. cmXCodeObject* headerBuildPhase,
  71. cmXCodeObject* frameworkBuildPhase,
  72. cmTarget& cmtarget);
  73. void AddCommandsToBuildPhase(cmXCodeObject* buildphase,
  74. cmTarget& target,
  75. std::vector<cmCustomCommand>
  76. const & commands,
  77. const char* commandFileName);
  78. cmXCodeObject* FindXCodeTarget(cmTarget*);
  79. // create cmXCodeObject from these functions so that memory can be managed
  80. // correctly. All objects created are stored in m_XCodeObjects.
  81. cmXCodeObject* CreateObject(cmXCodeObject::PBXType ptype);
  82. cmXCodeObject* CreateObject(cmXCodeObject::Type type);
  83. cmXCodeObject* CreateString(const char* s);
  84. cmXCodeObject* CreateObjectReference(cmXCodeObject*);
  85. cmXCodeObject* CreateXCodeTarget(cmTarget& target,
  86. cmXCodeObject* buildPhases);
  87. cmXCodeObject* CreateUtilityTarget(cmTarget& target);
  88. void AddDependAndLinkInformation(cmXCodeObject* target);
  89. void CreateBuildSettings(cmTarget& target,
  90. cmXCodeObject* buildSettings,
  91. std::string& fileType,
  92. std::string& productType,
  93. std::string& projectName);
  94. // delete all objects in the m_XCodeObjects vector.
  95. void ClearXCodeObjects();
  96. void CreateXCodeObjects(cmLocalGenerator* root,
  97. std::vector<cmLocalGenerator*>& generators);
  98. void OutputXCodeProject(cmLocalGenerator* root,
  99. std::vector<cmLocalGenerator*>& generators);
  100. void WriteXCodePBXProj(std::ostream& fout,
  101. cmLocalGenerator* root,
  102. std::vector<cmLocalGenerator*>& generators);
  103. cmXCodeObject* CreateXCodeSourceFile(cmLocalGenerator* gen,
  104. cmSourceFile* sf);
  105. void CreateXCodeTargets(cmLocalGenerator* gen, std::vector<cmXCodeObject*>&);
  106. void AddDependTarget(cmXCodeObject* target,
  107. cmXCodeObject* dependTarget);
  108. void AddLinkLibrary(cmXCodeObject* target,
  109. const char* lib, cmTarget* dtarget = 0);
  110. void ConfigureOutputPaths();
  111. void CreateXCodeDependHackTarget(std::vector<cmXCodeObject*>& targets);
  112. std::string GetTargetFullPath(cmTarget*);
  113. bool SpecialTargetEmitted(std::string const& tname);
  114. void AddExtraTargets(cmLocalGenerator* root,
  115. std::vector<cmLocalGenerator*>& gens);
  116. cmXCodeObject* CreateBuildPhase(const char* name,
  117. const char* name2,
  118. cmTarget& cmtarget,
  119. const std::vector<cmCustomCommand>&);
  120. void CreateReRunCMakeFile(cmLocalGenerator* root);
  121. private:
  122. std::vector<cmXCodeObject*> m_XCodeObjects;
  123. cmXCodeObject* m_RootObject;
  124. cmXCodeObject* m_MainGroupChildren;
  125. cmXCodeObject* m_SourcesGroupChildren;
  126. cmMakefile* m_CurrentMakefile;
  127. cmLocalGenerator* m_CurrentLocalGenerator;
  128. std::string m_CurrentReRunCMakeMakefile;
  129. std::string m_CurrentXCodeHackMakefile;
  130. std::string m_CurrentProject;
  131. std::string m_OutputDir;
  132. std::string m_LibraryOutputPath;
  133. std::string m_ExecutableOutputPath;
  134. std::set<cmStdString> m_TargetDoneSet;
  135. std::vector<std::string> m_CurrentOutputDirectoryComponents;
  136. std::vector<std::string> m_ProjectOutputDirectoryComponents;
  137. std::map<cmSourceFile*, cmXCodeObject* > m_GroupMap;
  138. std::map<cmStdString, cmXCodeObject* > m_GroupNameMap;
  139. std::map<cmStdString, cmXCodeObject* > m_TargetGroup;
  140. };
  141. #endif