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. */
|
2021-09-14 00:13:48 +02:00
|
|
|
#pragma once
|
2013-03-16 19:13:01 +02:00
|
|
|
|
2018-01-26 17:06:56 +01:00
|
|
|
#include "cmConfigure.h" // IWYU pragma: keep
|
2016-10-30 18:24:19 +01:00
|
|
|
|
2023-05-23 16:38:00 +02:00
|
|
|
#include "cmDocumentationEntry.h" // IWYU pragma: export
|
|
|
|
|
|
|
|
// TODO The following headers are parts of the `cmGlobalGeneratorFactory`
|
|
|
|
// public API, so could be defined as export to IWYU
|
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
|
|
|
|
|
|
|
/** \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(
|
2021-09-14 00:13:48 +02:00
|
|
|
const std::string& n, bool allowArch, cmake* cm) const = 0;
|
2013-03-16 19:13:01 +02:00
|
|
|
|
|
|
|
/** Get the documentation entry for this factory */
|
2023-05-23 16:38:00 +02:00
|
|
|
virtual cmDocumentationEntry GetDocumentation() const = 0;
|
2013-03-16 19:13:01 +02:00
|
|
|
|
|
|
|
/** 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;
|
|
|
|
|
2021-09-14 00:13:48 +02:00
|
|
|
/** If the generator supports platforms, get its default. */
|
2019-11-11 23:01:05 +01:00
|
|
|
virtual std::string GetDefaultPlatformName() const = 0;
|
2013-03-16 19:13:01 +02:00
|
|
|
};
|
|
|
|
|
2023-05-23 16:38:00 +02:00
|
|
|
template <typename 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(
|
2021-09-14 00:13:48 +02:00
|
|
|
const std::string& name, bool /*allowArch*/, 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 */
|
2023-05-23 16:38:00 +02:00
|
|
|
cmDocumentationEntry GetDocumentation() const override
|
2016-07-09 11:21:54 +02:00
|
|
|
{
|
2023-05-23 16:38:00 +02:00
|
|
|
return T::GetDocumentation();
|
2016-07-09 11:21:54 +02:00
|
|
|
}
|
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
|
|
|
{
|
2023-05-23 16:38:00 +02:00
|
|
|
return { T::GetActualName() };
|
2019-11-11 23:01:05 +01:00
|
|
|
}
|
|
|
|
std::vector<std::string> GetGeneratorNamesWithPlatform() const override
|
|
|
|
{
|
2023-05-23 16:38:00 +02:00
|
|
|
return {};
|
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
|
2023-05-23 16:38:00 +02:00
|
|
|
return {};
|
2019-11-11 23:01:05 +01:00
|
|
|
}
|
|
|
|
|
2023-05-23 16:38:00 +02:00
|
|
|
std::string GetDefaultPlatformName() const override { return {}; }
|
2013-03-16 19:13:01 +02:00
|
|
|
};
|