1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
5 #include "cmConfigure.h" // IWYU pragma: keep
12 class cmGlobalGenerator;
14 struct cmDocumentationEntry;
16 /** \class cmGlobalGeneratorFactory
17 * \brief Responable for creating cmGlobalGenerator instances
19 * Subclasses of this class generate instances of cmGlobalGenerator.
21 class cmGlobalGeneratorFactory
24 virtual ~cmGlobalGeneratorFactory() = default;
26 /** Create a GlobalGenerator */
27 virtual std::unique_ptr<cmGlobalGenerator> CreateGlobalGenerator(
28 const std::string& n, bool allowArch, cmake* cm) const = 0;
30 /** Get the documentation entry for this factory */
31 virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0;
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;
37 /** Determine whether or not this generator supports toolsets */
38 virtual bool SupportsToolset() const = 0;
40 /** Determine whether or not this generator supports platforms */
41 virtual bool SupportsPlatform() const = 0;
43 /** Get the list of supported platforms name for this generator */
44 virtual std::vector<std::string> GetKnownPlatforms() const = 0;
46 /** If the generator supports platforms, get its default. */
47 virtual std::string GetDefaultPlatformName() const = 0;
51 class cmGlobalGeneratorSimpleFactory : public cmGlobalGeneratorFactory
54 /** Create a GlobalGenerator */
55 std::unique_ptr<cmGlobalGenerator> CreateGlobalGenerator(
56 const std::string& name, bool /*allowArch*/, cmake* cm) const override
58 if (name != T::GetActualName()) {
59 return std::unique_ptr<cmGlobalGenerator>();
61 return std::unique_ptr<cmGlobalGenerator>(cm::make_unique<T>(cm));
64 /** Get the documentation entry for this factory */
65 void GetDocumentation(cmDocumentationEntry& entry) const override
67 T::GetDocumentation(entry);
70 /** Get the names of the current registered generators */
71 std::vector<std::string> GetGeneratorNames() const override
73 std::vector<std::string> names;
74 names.push_back(T::GetActualName());
77 std::vector<std::string> GetGeneratorNamesWithPlatform() const override
79 return std::vector<std::string>();
82 /** Determine whether or not this generator supports toolsets */
83 bool SupportsToolset() const override { return T::SupportsToolset(); }
85 /** Determine whether or not this generator supports platforms */
86 bool SupportsPlatform() const override { return T::SupportsPlatform(); }
88 /** Get the list of supported platforms name for this generator */
89 std::vector<std::string> GetKnownPlatforms() const override
91 // default is no platform supported
92 return std::vector<std::string>();
95 std::string GetDefaultPlatformName() const override { return std::string(); }