summaryrefslogtreecommitdiff
path: root/Source/cmExternalMakefileProjectGenerator.cxx
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2016-07-20 18:28:39 +0200
committerBrad King <brad.king@kitware.com>2016-08-03 09:43:00 -0400
commita354f60ce07cd67bd60161824a4e74bf9068fea4 (patch)
tree14c272760205567469ddd856a99e98ace6282841 /Source/cmExternalMakefileProjectGenerator.cxx
parentfd59f9ad519c1c311c54569133797d9061e90558 (diff)
downloadcmake-a354f60ce07cd67bd60161824a4e74bf9068fea4.tar.gz
Refactor extra generator registration to use factories
This will allow additional information about the availability and capabilities of extra generators to be queried without actually creating them. Instead of a static NewFactory() method like the main generator factories have, use a static GetFactory() method to get a pointer to a statically allocated extra generator factory. This simplifies memory management.
Diffstat (limited to 'Source/cmExternalMakefileProjectGenerator.cxx')
-rw-r--r--Source/cmExternalMakefileProjectGenerator.cxx49
1 files changed, 29 insertions, 20 deletions
diff --git a/Source/cmExternalMakefileProjectGenerator.cxx b/Source/cmExternalMakefileProjectGenerator.cxx
index 0e42d759e0..a527e50173 100644
--- a/Source/cmExternalMakefileProjectGenerator.cxx
+++ b/Source/cmExternalMakefileProjectGenerator.cxx
@@ -33,28 +33,37 @@ std::string cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
return fullName;
}
-std::string cmExternalMakefileProjectGenerator::GetGlobalGeneratorName(
- const std::string& fullName)
+cmExternalMakefileProjectGeneratorFactory::
+ cmExternalMakefileProjectGeneratorFactory(const std::string& n,
+ const std::string& doc)
+ : Name(n)
+ , Documentation(doc)
{
- // at least one global generator must be supported
- assert(!this->SupportedGlobalGenerators.empty());
+}
- if (fullName.empty()) {
- return "";
- }
+cmExternalMakefileProjectGeneratorFactory::
+ ~cmExternalMakefileProjectGeneratorFactory()
+{
+}
- // if we get only the short name, take the first global generator as default
- if (fullName == this->GetName()) {
- return this->SupportedGlobalGenerators[0];
- }
+std::string cmExternalMakefileProjectGeneratorFactory::GetName() const
+{
+ return this->Name;
+}
- // otherwise search for the matching global generator
- for (std::vector<std::string>::const_iterator it =
- this->SupportedGlobalGenerators.begin();
- it != this->SupportedGlobalGenerators.end(); ++it) {
- if (this->CreateFullGeneratorName(*it, this->GetName()) == fullName) {
- return *it;
- }
- }
- return "";
+std::string cmExternalMakefileProjectGeneratorFactory::GetDocumentation() const
+{
+ return this->Documentation;
+}
+
+std::vector<std::string>
+cmExternalMakefileProjectGeneratorFactory::GetSupportedGlobalGenerators() const
+{
+ return this->SupportedGlobalGenerators;
+}
+
+void cmExternalMakefileProjectGeneratorFactory::AddSupportedGlobalGenerator(
+ const std::string& base)
+{
+ this->SupportedGlobalGenerators.push_back(base);
}