cmake/Source/cmGlobalGeneratorFactory.h

100 lines
3.1 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2013-03-16 19:13:01 +02:00
#ifndef cmGlobalGeneratorFactory_h
#define cmGlobalGeneratorFactory_h
2018-01-26 17:06:56 +01:00
#include "cmConfigure.h" // IWYU pragma: keep
2016-10-30 18:24:19 +01:00
2017-04-14 19:02:05 +02:00
#include <string>
#include <vector>
2013-03-16 19:13:01 +02:00
2020-08-30 11:54:41 +02:00
#include <cm/memory>
2013-03-16 19:13:01 +02:00
class cmGlobalGenerator;
2017-04-14 19:02:05 +02:00
class cmake;
2013-03-16 19:13:01 +02:00
struct cmDocumentationEntry;
/** \class cmGlobalGeneratorFactory
* \brief Responable for creating cmGlobalGenerator instances
*
* Subclasses of this class generate instances of cmGlobalGenerator.
*/
class cmGlobalGeneratorFactory
{
public:
2019-11-11 23:01:05 +01:00
virtual ~cmGlobalGeneratorFactory() = default;
2013-03-16 19:13:01 +02:00
/** Create a GlobalGenerator */
2020-08-30 11:54:41 +02:00
virtual std::unique_ptr<cmGlobalGenerator> CreateGlobalGenerator(
const std::string& n, cmake* cm) const = 0;
2013-03-16 19:13:01 +02:00
/** Get the documentation entry for this factory */
virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0;
/** Get the names of the current registered generators */
2019-11-11 23:01:05 +01:00
virtual std::vector<std::string> GetGeneratorNames() const = 0;
virtual std::vector<std::string> GetGeneratorNamesWithPlatform() const = 0;
2016-03-13 13:35:51 +01:00
/** Determine whether or not this generator supports toolsets */
virtual bool SupportsToolset() const = 0;
2016-10-30 18:24:19 +01:00
/** Determine whether or not this generator supports platforms */
virtual bool SupportsPlatform() const = 0;
2019-11-11 23:01:05 +01:00
/** Get the list of supported platforms name for this generator */
virtual std::vector<std::string> GetKnownPlatforms() const = 0;
/** If the generator suports platforms, get its default. */
virtual std::string GetDefaultPlatformName() const = 0;
2013-03-16 19:13:01 +02:00
};
2016-07-09 11:21:54 +02:00
template <class T>
2013-03-16 19:13:01 +02:00
class cmGlobalGeneratorSimpleFactory : public cmGlobalGeneratorFactory
{
public:
/** Create a GlobalGenerator */
2020-08-30 11:54:41 +02:00
std::unique_ptr<cmGlobalGenerator> CreateGlobalGenerator(
const std::string& name, cmake* cm) const override
2016-07-09 11:21:54 +02:00
{
2016-10-30 18:24:19 +01:00
if (name != T::GetActualName()) {
2020-08-30 11:54:41 +02:00
return std::unique_ptr<cmGlobalGenerator>();
2016-10-30 18:24:19 +01:00
}
2020-08-30 11:54:41 +02:00
return std::unique_ptr<cmGlobalGenerator>(cm::make_unique<T>(cm));
2016-07-09 11:21:54 +02:00
}
2013-03-16 19:13:01 +02:00
/** Get the documentation entry for this factory */
2018-01-26 17:06:56 +01:00
void GetDocumentation(cmDocumentationEntry& entry) const override
2016-07-09 11:21:54 +02:00
{
T::GetDocumentation(entry);
}
2013-03-16 19:13:01 +02:00
/** Get the names of the current registered generators */
2019-11-11 23:01:05 +01:00
std::vector<std::string> GetGeneratorNames() const override
2016-07-09 11:21:54 +02:00
{
2019-11-11 23:01:05 +01:00
std::vector<std::string> names;
2016-07-09 11:21:54 +02:00
names.push_back(T::GetActualName());
2019-11-11 23:01:05 +01:00
return names;
}
std::vector<std::string> GetGeneratorNamesWithPlatform() const override
{
return std::vector<std::string>();
2016-07-09 11:21:54 +02:00
}
2016-03-13 13:35:51 +01:00
/** Determine whether or not this generator supports toolsets */
2018-01-26 17:06:56 +01:00
bool SupportsToolset() const override { return T::SupportsToolset(); }
2016-10-30 18:24:19 +01:00
/** Determine whether or not this generator supports platforms */
2018-01-26 17:06:56 +01:00
bool SupportsPlatform() const override { return T::SupportsPlatform(); }
2019-11-11 23:01:05 +01:00
/** Get the list of supported platforms name for this generator */
std::vector<std::string> GetKnownPlatforms() const override
{
// default is no platform supported
return std::vector<std::string>();
}
std::string GetDefaultPlatformName() const override { return std::string(); }
2013-03-16 19:13:01 +02:00
};
#endif