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