cmGlobalGenerator.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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 cmGlobalGenerator_h
  14. #define cmGlobalGenerator_h
  15. #include "cmStandardIncludes.h"
  16. class cmake;
  17. class cmMakefile;
  18. class cmLocalGenerator;
  19. class cmTarget;
  20. /** \class cmGlobalGenerator
  21. * \brief Responable for overseeing the generation process for the entire tree
  22. *
  23. * Subclasses of this class generate makefiles for various
  24. * platforms.
  25. */
  26. class cmGlobalGenerator
  27. {
  28. public:
  29. ///! Free any memory allocated with the GlobalGenerator
  30. cmGlobalGenerator();
  31. virtual ~cmGlobalGenerator();
  32. ///! Create a local generator appropriate to this Global Generator
  33. virtual cmLocalGenerator *CreateLocalGenerator();
  34. ///! Get the name for this generator
  35. virtual const char *GetName() const { return "Generic"; };
  36. /** Get the documentation entry for this generator. */
  37. virtual void GetDocumentation(cmDocumentationEntry& entry) const;
  38. /**
  39. * Create LocalGenerators and process the CMakeLists files. This does not
  40. * actually produce any makefiles, DSPs, etc.
  41. */
  42. virtual void Configure();
  43. /**
  44. * Generate the all required files for building this project/tree. This
  45. * basically creates a series of LocalGenerators for each directory and
  46. * requests that they Generate.
  47. */
  48. virtual void Generate();
  49. /**
  50. * Generate the required files for building this directory. This
  51. * basically creates a single LocalGenerators and
  52. * requests that it Generate.
  53. */
  54. virtual void LocalGenerate();
  55. /**
  56. * Set/Get and Clear the enabled languages.
  57. */
  58. void SetLanguageEnabled(const char*, cmMakefile* mf);
  59. bool GetLanguageEnabled(const char*);
  60. void ClearEnabledLanguages();
  61. void GetEnabledLanguages(std::vector<std::string>& lang);
  62. /**
  63. * Try to determine system infomation such as shared library
  64. * extension, pthreads, byte order etc.
  65. */
  66. virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *);
  67. /**
  68. * Try to determine system infomation, get it from another generator
  69. */
  70. virtual void EnableLanguagesFromGenerator(cmGlobalGenerator *gen);
  71. /**
  72. * Try running cmake and building a file. This is used for dynalically
  73. * loaded commands, not as part of the usual build process.
  74. */
  75. virtual int TryCompile(const char *srcdir, const char *bindir,
  76. const char *projectName, const char *targetName,
  77. std::string *output, cmMakefile* mf);
  78. ///! Set the CMake instance
  79. void SetCMakeInstance(cmake *cm) {
  80. this->m_CMakeInstance = cm; };
  81. ///! Get the CMake instance
  82. cmake *GetCMakeInstance() {
  83. return this->m_CMakeInstance; };
  84. void SetConfiguredFilesPath(const char* s){m_ConfiguredFilesPath = s;}
  85. void GetLocalGenerators(std::vector<cmLocalGenerator *>&g) { g = m_LocalGenerators;}
  86. static int s_TryCompileTimeout;
  87. bool GetForceUnixPaths() {return m_ForceUnixPaths;}
  88. ///! return the language for the given extension
  89. const char* GetLanguageFromExtension(const char* ext);
  90. ///! is an extension to be ignored
  91. bool IgnoreFile(const char* ext);
  92. ///! What is the preference for linkers and this language (None or Prefered)
  93. const char* GetLinkerPreference(const char* lang);
  94. ///! What is the output extension for a given language.
  95. const char* GetLanguageOutputExtensionForLanguage(const char* lang);
  96. ///! What is the output extension for a given source file extension.
  97. const char* GetLanguageOutputExtensionFromExtension(const char* lang);
  98. protected:
  99. // Fill the m_ProjectMap, this must be called after m_LocalGenerators has been populated.
  100. void FillProjectMap();
  101. bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen);
  102. void FindMakeProgram(cmMakefile*);
  103. bool m_ForceUnixPaths;
  104. cmStdString m_FindMakeProgramFile;
  105. cmStdString m_ConfiguredFilesPath;
  106. cmake *m_CMakeInstance;
  107. std::vector<cmLocalGenerator *> m_LocalGenerators;
  108. // map from project name to vector of local generators in that project
  109. std::map<cmStdString, std::vector<cmLocalGenerator*> > m_ProjectMap;
  110. ///! used by Configure()
  111. void RecursiveConfigure(cmLocalGenerator *lg, float start, float end);
  112. ///! Find a target by name by searching the local generators.
  113. cmTarget* FindTarget(const char* name);
  114. private:
  115. // If you add a new map here, make sure it is copied
  116. // in EnableLanguagesFromGenerator
  117. std::map<cmStdString, bool> m_IgnoreExtensions;
  118. std::map<cmStdString, bool> m_LanguageEnabled;
  119. std::map<cmStdString, cmStdString> m_OutputExtensions;
  120. std::map<cmStdString, cmStdString> m_LanguageToOutputExtension;
  121. std::map<cmStdString, cmStdString> m_ExtensionToLanguage;
  122. std::map<cmStdString, cmStdString> m_LanguageToLinkerPreference;
  123. };
  124. #endif