cmExternalMakefileProjectGenerator.h 3.5 KB

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