resolve cyclic dependency with zstd
[platform/upstream/cmake.git] / Source / cmGlobalGeneratorFactory.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 <string>
8 #include <vector>
9
10 #include <cm/memory>
11
12 class cmGlobalGenerator;
13 class cmake;
14 struct cmDocumentationEntry;
15
16 /** \class cmGlobalGeneratorFactory
17  * \brief Responable for creating cmGlobalGenerator instances
18  *
19  * Subclasses of this class generate instances of cmGlobalGenerator.
20  */
21 class cmGlobalGeneratorFactory
22 {
23 public:
24   virtual ~cmGlobalGeneratorFactory() = default;
25
26   /** Create a GlobalGenerator */
27   virtual std::unique_ptr<cmGlobalGenerator> CreateGlobalGenerator(
28     const std::string& n, bool allowArch, cmake* cm) const = 0;
29
30   /** Get the documentation entry for this factory */
31   virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0;
32
33   /** Get the names of the current registered generators */
34   virtual std::vector<std::string> GetGeneratorNames() const = 0;
35   virtual std::vector<std::string> GetGeneratorNamesWithPlatform() const = 0;
36
37   /** Determine whether or not this generator supports toolsets */
38   virtual bool SupportsToolset() const = 0;
39
40   /** Determine whether or not this generator supports platforms */
41   virtual bool SupportsPlatform() const = 0;
42
43   /** Get the list of supported platforms name for this generator */
44   virtual std::vector<std::string> GetKnownPlatforms() const = 0;
45
46   /** If the generator supports platforms, get its default.  */
47   virtual std::string GetDefaultPlatformName() const = 0;
48 };
49
50 template <class T>
51 class cmGlobalGeneratorSimpleFactory : public cmGlobalGeneratorFactory
52 {
53 public:
54   /** Create a GlobalGenerator */
55   std::unique_ptr<cmGlobalGenerator> CreateGlobalGenerator(
56     const std::string& name, bool /*allowArch*/, cmake* cm) const override
57   {
58     if (name != T::GetActualName()) {
59       return std::unique_ptr<cmGlobalGenerator>();
60     }
61     return std::unique_ptr<cmGlobalGenerator>(cm::make_unique<T>(cm));
62   }
63
64   /** Get the documentation entry for this factory */
65   void GetDocumentation(cmDocumentationEntry& entry) const override
66   {
67     T::GetDocumentation(entry);
68   }
69
70   /** Get the names of the current registered generators */
71   std::vector<std::string> GetGeneratorNames() const override
72   {
73     std::vector<std::string> names;
74     names.push_back(T::GetActualName());
75     return names;
76   }
77   std::vector<std::string> GetGeneratorNamesWithPlatform() const override
78   {
79     return std::vector<std::string>();
80   }
81
82   /** Determine whether or not this generator supports toolsets */
83   bool SupportsToolset() const override { return T::SupportsToolset(); }
84
85   /** Determine whether or not this generator supports platforms */
86   bool SupportsPlatform() const override { return T::SupportsPlatform(); }
87
88   /** Get the list of supported platforms name for this generator */
89   std::vector<std::string> GetKnownPlatforms() const override
90   {
91     // default is no platform supported
92     return std::vector<std::string>();
93   }
94
95   std::string GetDefaultPlatformName() const override { return std::string(); }
96 };