summaryrefslogtreecommitdiffstats
path: root/Source/cmExternalMakefileProjectGenerator.h
blob: 6b8903790fada7fab4e0f37f2e082af6a1aff02b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing for details.  */
#ifndef cmExternalMakefileProjectGenerator_h
#define cmExternalMakefileProjectGenerator_h

#include "cmConfigure.h" // IWYU pragma: keep

#include <string>
#include <vector>

class cmGlobalGenerator;
class cmMakefile;

/** \class cmExternalMakefileProjectGenerator
 * \brief Base class for generators for "External Makefile based IDE projects".
 *
 * cmExternalMakefileProjectGenerator is a base class for generators
 * for "external makefile based projects", i.e. IDE projects which work
 * an already existing makefiles.
 * See cmGlobalKdevelopGenerator as an example.
 * After the makefiles have been generated by one of the Makefile
 * generators, the Generate() method is called and this generator
 * can iterate over the local generators and/or projects to produce the
 * project files for the IDE.
 */
class cmExternalMakefileProjectGenerator
{
public:
  virtual ~cmExternalMakefileProjectGenerator() {}

  virtual void EnableLanguage(std::vector<std::string> const& languages,
                              cmMakefile*, bool optional);

  ///! set the global generator which will generate the makefiles
  virtual void SetGlobalGenerator(cmGlobalGenerator* generator)
  {
    this->GlobalGenerator = generator;
  }

  ///! Return the list of global generators supported by this extra generator
  const std::vector<std::string>& GetSupportedGlobalGenerators() const
  {
    return this->SupportedGlobalGenerators;
  }

  /** Create a full name from the given global generator name and the
   * extra generator name
   */
  static std::string CreateFullGeneratorName(
    const std::string& globalGenerator, const std::string& extraGenerator);

  ///! Generate the project files, the Makefiles have already been generated
  virtual void Generate() = 0;

  void SetName(const std::string& n) { Name = n; }
  std::string GetName() const { return Name; }

protected:
  ///! Contains the names of the global generators support by this generator.
  std::vector<std::string> SupportedGlobalGenerators;
  ///! the global generator which creates the makefiles
  const cmGlobalGenerator* GlobalGenerator;

  std::string Name;
};

class cmExternalMakefileProjectGeneratorFactory
{
public:
  cmExternalMakefileProjectGeneratorFactory(const std::string& n,
                                            const std::string& doc);
  virtual ~cmExternalMakefileProjectGeneratorFactory();

  std::string GetName() const;
  std::string GetDocumentation() const;
  std::vector<std::string> GetSupportedGlobalGenerators() const;
  std::vector<std::string> Aliases;

  virtual cmExternalMakefileProjectGenerator*
  CreateExternalMakefileProjectGenerator() const = 0;

  void AddSupportedGlobalGenerator(const std::string& base);

private:
  std::string Name;
  std::string Documentation;
  std::vector<std::string> SupportedGlobalGenerators;
};

template <class T>
class cmExternalMakefileProjectGeneratorSimpleFactory
  : public cmExternalMakefileProjectGeneratorFactory
{
public:
  cmExternalMakefileProjectGeneratorSimpleFactory(const std::string& n,
                                                  const std::string& doc)
    : cmExternalMakefileProjectGeneratorFactory(n, doc)
  {
  }

  cmExternalMakefileProjectGenerator* CreateExternalMakefileProjectGenerator()
    const CM_OVERRIDE
  {
    T* p = new T;
    p->SetName(GetName());
    return p;
  }
};

#endif