cmExternalMakefileProjectGenerator.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmExternalMakefileProjectGenerator_h
  11. #define cmExternalMakefileProjectGenerator_h
  12. #include <cmConfigure.h> // IWYU pragma: keep
  13. #include <string>
  14. #include <vector>
  15. class cmGlobalGenerator;
  16. class cmMakefile;
  17. /** \class cmExternalMakefileProjectGenerator
  18. * \brief Base class for generators for "External Makefile based IDE projects".
  19. *
  20. * cmExternalMakefileProjectGenerator is a base class for generators
  21. * for "external makefile based projects", i.e. IDE projects which work
  22. * an already existing makefiles.
  23. * See cmGlobalKdevelopGenerator as an example.
  24. * After the makefiles have been generated by one of the Makefile
  25. * generators, the Generate() method is called and this generator
  26. * can iterate over the local generators and/or projects to produce the
  27. * project files for the IDE.
  28. */
  29. class cmExternalMakefileProjectGenerator
  30. {
  31. public:
  32. virtual ~cmExternalMakefileProjectGenerator() {}
  33. virtual void EnableLanguage(std::vector<std::string> const& languages,
  34. cmMakefile*, bool optional);
  35. ///! set the global generator which will generate the makefiles
  36. virtual void SetGlobalGenerator(cmGlobalGenerator* generator)
  37. {
  38. this->GlobalGenerator = generator;
  39. }
  40. ///! Return the list of global generators supported by this extra generator
  41. const std::vector<std::string>& GetSupportedGlobalGenerators() const
  42. {
  43. return this->SupportedGlobalGenerators;
  44. }
  45. /** Create a full name from the given global generator name and the
  46. * extra generator name
  47. */
  48. static std::string CreateFullGeneratorName(
  49. const std::string& globalGenerator, const std::string& extraGenerator);
  50. ///! Generate the project files, the Makefiles have already been generated
  51. virtual void Generate() = 0;
  52. void SetName(const std::string& n) { Name = n; }
  53. std::string GetName() const { return Name; }
  54. protected:
  55. ///! Contains the names of the global generators support by this generator.
  56. std::vector<std::string> SupportedGlobalGenerators;
  57. ///! the global generator which creates the makefiles
  58. const cmGlobalGenerator* GlobalGenerator;
  59. std::string Name;
  60. };
  61. class cmExternalMakefileProjectGeneratorFactory
  62. {
  63. public:
  64. cmExternalMakefileProjectGeneratorFactory(const std::string& n,
  65. const std::string& doc);
  66. virtual ~cmExternalMakefileProjectGeneratorFactory();
  67. std::string GetName() const;
  68. std::string GetDocumentation() const;
  69. std::vector<std::string> GetSupportedGlobalGenerators() const;
  70. std::vector<std::string> Aliases;
  71. virtual cmExternalMakefileProjectGenerator*
  72. CreateExternalMakefileProjectGenerator() const = 0;
  73. void AddSupportedGlobalGenerator(const std::string& base);
  74. private:
  75. std::string Name;
  76. std::string Documentation;
  77. std::vector<std::string> SupportedGlobalGenerators;
  78. };
  79. template <class T>
  80. class cmExternalMakefileProjectGeneratorSimpleFactory
  81. : public cmExternalMakefileProjectGeneratorFactory
  82. {
  83. public:
  84. cmExternalMakefileProjectGeneratorSimpleFactory(const std::string& n,
  85. const std::string& doc)
  86. : cmExternalMakefileProjectGeneratorFactory(n, doc)
  87. {
  88. }
  89. cmExternalMakefileProjectGenerator* CreateExternalMakefileProjectGenerator()
  90. const
  91. {
  92. T* p = new T;
  93. p->SetName(GetName());
  94. return p;
  95. }
  96. };
  97. #endif