cmake/Source/cmExternalMakefileProjectGenerator.h

111 lines
3.5 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. */
2021-09-14 00:13:48 +02:00
#pragma once
2017-07-20 19:35:53 +02:00
#include "cmConfigure.h" // IWYU pragma: keep
2020-08-30 11:54:41 +02:00
#include <memory>
2016-10-30 18:24:19 +01:00
#include <string>
#include <vector>
class cmGlobalGenerator;
2016-10-30 18:24:19 +01:00
class cmMakefile;
/** \class cmExternalMakefileProjectGenerator
* \brief Base class for generators for "External Makefile based IDE projects".
*
* cmExternalMakefileProjectGenerator is a base class for generators
2013-03-16 19:13:01 +02:00
* for "external makefile based projects", i.e. IDE projects which work
* an already existing makefiles.
2018-04-23 21:13:27 +02:00
* See cmExtraEclipseCDT4Generator as an example.
2013-03-16 19:13:01 +02:00
* After the makefiles have been generated by one of the Makefile
* generators, the Generate() method is called and this generator
2013-03-16 19:13:01 +02:00
* can iterate over the local generators and/or projects to produce the
* project files for the IDE.
*/
class cmExternalMakefileProjectGenerator
{
public:
2019-11-11 23:01:05 +01:00
virtual ~cmExternalMakefileProjectGenerator() = default;
2014-08-03 19:52:23 +02:00
virtual void EnableLanguage(std::vector<std::string> const& languages,
2016-07-09 11:21:54 +02:00
cmMakefile*, bool optional);
2019-11-11 23:01:05 +01:00
//! set the global generator which will generate the makefiles
virtual void SetGlobalGenerator(cmGlobalGenerator* generator)
2016-07-09 11:21:54 +02:00
{
this->GlobalGenerator = generator;
}
2019-11-11 23:01:05 +01:00
//! Return the list of global generators supported by this extra generator
2013-03-16 19:13:01 +02:00
const std::vector<std::string>& GetSupportedGlobalGenerators() const
2016-07-09 11:21:54 +02:00
{
return this->SupportedGlobalGenerators;
}
/** Create a full name from the given global generator name and the
* extra generator name
*/
2015-04-27 22:25:09 +02:00
static std::string CreateFullGeneratorName(
2016-07-09 11:21:54 +02:00
const std::string& globalGenerator, const std::string& extraGenerator);
2019-11-11 23:01:05 +01:00
//! Generate the project files, the Makefiles have already been generated
virtual void Generate() = 0;
2016-07-09 11:21:54 +02:00
2021-09-14 00:13:48 +02:00
void SetName(const std::string& n) { this->Name = n; }
std::string GetName() const { return this->Name; }
2016-10-30 18:24:19 +01:00
2018-04-23 21:13:27 +02:00
virtual bool Open(const std::string& bindir, const std::string& projectName,
bool dryRun);
protected:
2019-11-11 23:01:05 +01:00
//! Contains the names of the global generators support by this generator.
std::vector<std::string> SupportedGlobalGenerators;
2019-11-11 23:01:05 +01:00
//! the global generator which creates the makefiles
2018-08-09 18:06:22 +02:00
const cmGlobalGenerator* GlobalGenerator = nullptr;
2016-10-30 18:24:19 +01:00
std::string Name;
};
class cmExternalMakefileProjectGeneratorFactory
{
public:
2019-11-11 23:01:05 +01:00
cmExternalMakefileProjectGeneratorFactory(std::string n, std::string doc);
2016-10-30 18:24:19 +01:00
virtual ~cmExternalMakefileProjectGeneratorFactory();
std::string GetName() const;
std::string GetDocumentation() const;
std::vector<std::string> GetSupportedGlobalGenerators() const;
std::vector<std::string> Aliases;
2020-08-30 11:54:41 +02:00
virtual std::unique_ptr<cmExternalMakefileProjectGenerator>
2016-10-30 18:24:19 +01:00
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)
{
}
2020-08-30 11:54:41 +02:00
std::unique_ptr<cmExternalMakefileProjectGenerator>
CreateExternalMakefileProjectGenerator() const override
2016-10-30 18:24:19 +01:00
{
2020-08-30 11:54:41 +02:00
std::unique_ptr<cmExternalMakefileProjectGenerator> p(new T);
2021-09-14 00:13:48 +02:00
p->SetName(this->GetName());
2016-10-30 18:24:19 +01:00
return p;
}
};