summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorPatrick Gansterer <paroga@paroga.com>2012-11-19 15:13:54 (GMT)
committerBrad King <brad.king@kitware.com>2012-11-19 17:54:35 (GMT)
commit04ff866ca8a0c5f4f8712d6cfafcd192ed4cbe58 (patch)
tree690d285ba132f07a4189cf68564f962aae7cd158 /Source
parent984ebc3350f72cb005999f7b796803f83be15304 (diff)
downloadCMake-04ff866ca8a0c5f4f8712d6cfafcd192ed4cbe58.zip
CMake-04ff866ca8a0c5f4f8712d6cfafcd192ed4cbe58.tar.gz
CMake-04ff866ca8a0c5f4f8712d6cfafcd192ed4cbe58.tar.bz2
Allow a GeneratorFactory handling of more than one generator
Pass the name of the requested generator to the generator factory, which is now responsible to check if it can create a matching generator for the name. This allows us to add more logic to the factory in a next step, so that not every possible generator needs to get registered explicit in cmake::AddDefaultGenerators().
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalGeneratorFactory.h5
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx6
-rw-r--r--Source/cmake.cxx120
-rw-r--r--Source/cmake.h5
4 files changed, 71 insertions, 65 deletions
diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h
index 9d8f7a0..0dfb362 100644
--- a/Source/cmGlobalGeneratorFactory.h
+++ b/Source/cmGlobalGeneratorFactory.h
@@ -29,7 +29,7 @@ public:
virtual ~cmGlobalGeneratorFactory() {}
/** Create a GlobalGenerator */
- virtual cmGlobalGenerator* CreateGlobalGenerator() const = 0;
+ virtual cmGlobalGenerator* CreateGlobalGenerator(const char* n) const = 0;
/** Get the documentation entry for this factory */
virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0;
@@ -43,7 +43,8 @@ class cmGlobalGeneratorSimpleFactory : public cmGlobalGeneratorFactory
{
public:
/** Create a GlobalGenerator */
- virtual cmGlobalGenerator* CreateGlobalGenerator() const {
+ virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const {
+ if (strcmp(name, T::GetActualName())) return 0;
return new T; }
/** Get the documentation entry for this factory */
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 59ca652..e6f3422 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -116,7 +116,7 @@ public:
class cmGlobalXCodeGenerator::Factory : public cmGlobalGeneratorFactory
{
public:
- virtual cmGlobalGenerator* CreateGlobalGenerator() const;
+ virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const;
virtual void GetDocumentation(cmDocumentationEntry& entry) const {
cmGlobalXCodeGenerator().GetDocumentation(entry); }
@@ -152,8 +152,10 @@ cmGlobalGeneratorFactory* cmGlobalXCodeGenerator::NewFactory()
//----------------------------------------------------------------------------
cmGlobalGenerator* cmGlobalXCodeGenerator::Factory
-::CreateGlobalGenerator() const
+::CreateGlobalGenerator(const char* name) const
{
+ if (strcmp(name, GetActualName()))
+ return 0;
#if defined(CMAKE_BUILD_WITH_CMAKE)
cmXcodeVersionParser parser;
std::string versionFile;
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index cd71507..3eda86d 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -222,10 +222,10 @@ cmake::~cmake()
{
delete (*j).second;
}
- for(RegisteredGeneratorsMap::iterator j = this->Generators.begin();
+ for(RegisteredGeneratorsVector::iterator j = this->Generators.begin();
j != this->Generators.end(); ++j)
{
- delete (*j).second;
+ delete *j;
}
#ifdef CMAKE_BUILD_WITH_CMAKE
delete this->VariableWatch;
@@ -1874,10 +1874,10 @@ void cmake::AddDefaultExtraGenerators()
//----------------------------------------------------------------------------
void cmake::GetRegisteredGenerators(std::vector<std::string>& names)
{
- for(RegisteredGeneratorsMap::const_iterator i = this->Generators.begin();
+ for(RegisteredGeneratorsVector::const_iterator i = this->Generators.begin();
i != this->Generators.end(); ++i)
{
- i->second->GetGenerators(names);
+ (*i)->GetGenerators(names);
}
for(RegisteredExtraGeneratorsMap::const_iterator
i = this->ExtraGenerators.begin();
@@ -1899,10 +1899,14 @@ cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name)
}
cmGlobalGenerator* generator = 0;
- RegisteredGeneratorsMap::const_iterator genIt = this->Generators.find(name);
- if(genIt != this->Generators.end())
+ for (RegisteredGeneratorsVector::const_iterator i =
+ this->Generators.begin(); i != this->Generators.end(); ++i)
{
- generator = genIt->second->CreateGlobalGenerator();
+ generator = (*i)->CreateGlobalGenerator(name);
+ if (generator)
+ {
+ break;
+ }
}
if (generator)
@@ -2578,55 +2582,55 @@ void cmake::AddDefaultGenerators()
{
#if defined(_WIN32) && !defined(__CYGWIN__)
# if !defined(CMAKE_BOOT_MINGW)
- this->Generators[cmGlobalVisualStudio6Generator::GetActualName()] =
- cmGlobalVisualStudio6Generator::NewFactory();
- this->Generators[cmGlobalVisualStudio7Generator::GetActualName()] =
- cmGlobalVisualStudio7Generator::NewFactory();
- this->Generators[cmGlobalVisualStudio10Generator::GetActualName()] =
- cmGlobalVisualStudio10Generator::NewFactory();
- this->Generators[cmGlobalVisualStudio10IA64Generator::GetActualName()] =
- cmGlobalVisualStudio10IA64Generator::NewFactory();
- this->Generators[cmGlobalVisualStudio10Win64Generator::GetActualName()] =
- cmGlobalVisualStudio10Win64Generator::NewFactory();
- this->Generators[cmGlobalVisualStudio11Generator::GetActualName()] =
- cmGlobalVisualStudio11Generator::NewFactory();
- this->Generators[cmGlobalVisualStudio11Win64Generator::GetActualName()] =
- cmGlobalVisualStudio11Win64Generator::NewFactory();
- this->Generators[cmGlobalVisualStudio11ARMGenerator::GetActualName()] =
- cmGlobalVisualStudio11ARMGenerator::NewFactory();
- this->Generators[cmGlobalVisualStudio71Generator::GetActualName()] =
- cmGlobalVisualStudio71Generator::NewFactory();
- this->Generators[cmGlobalVisualStudio8Generator::GetActualName()] =
- cmGlobalVisualStudio8Generator::NewFactory();
- this->Generators[cmGlobalVisualStudio9Generator::GetActualName()] =
- cmGlobalVisualStudio9Generator::NewFactory();
- this->Generators[cmGlobalVisualStudio9IA64Generator::GetActualName()] =
- cmGlobalVisualStudio9IA64Generator::NewFactory();
- this->Generators[cmGlobalVisualStudio9Win64Generator::GetActualName()] =
- cmGlobalVisualStudio9Win64Generator::NewFactory();
- this->Generators[cmGlobalVisualStudio8Win64Generator::GetActualName()] =
- cmGlobalVisualStudio8Win64Generator::NewFactory();
- this->Generators[cmGlobalBorlandMakefileGenerator::GetActualName()] =
- cmGlobalBorlandMakefileGenerator::NewFactory();
- this->Generators[cmGlobalNMakeMakefileGenerator::GetActualName()] =
- cmGlobalNMakeMakefileGenerator::NewFactory();
- this->Generators[cmGlobalJOMMakefileGenerator::GetActualName()] =
- cmGlobalJOMMakefileGenerator::NewFactory();
- this->Generators[cmGlobalWatcomWMakeGenerator::GetActualName()] =
- cmGlobalWatcomWMakeGenerator::NewFactory();
+ this->Generators.push_back(
+ cmGlobalVisualStudio6Generator::NewFactory());
+ this->Generators.push_back(
+ cmGlobalVisualStudio7Generator::NewFactory());
+ this->Generators.push_back(
+ cmGlobalVisualStudio10Generator::NewFactory());
+ this->Generators.push_back(
+ cmGlobalVisualStudio10IA64Generator::NewFactory());
+ this->Generators.push_back(
+ cmGlobalVisualStudio10Win64Generator::NewFactory());
+ this->Generators.push_back(
+ cmGlobalVisualStudio11Generator::NewFactory());
+ this->Generators.push_back(
+ cmGlobalVisualStudio11Win64Generator::NewFactory());
+ this->Generators.push_back(
+ cmGlobalVisualStudio11ARMGenerator::NewFactory());
+ this->Generators.push_back(
+ cmGlobalVisualStudio71Generator::NewFactory());
+ this->Generators.push_back(
+ cmGlobalVisualStudio8Generator::NewFactory());
+ this->Generators.push_back(
+ cmGlobalVisualStudio9Generator::NewFactory());
+ this->Generators.push_back(
+ cmGlobalVisualStudio9IA64Generator::NewFactory());
+ this->Generators.push_back(
+ cmGlobalVisualStudio9Win64Generator::NewFactory());
+ this->Generators.push_back(
+ cmGlobalVisualStudio8Win64Generator::NewFactory());
+ this->Generators.push_back(
+ cmGlobalBorlandMakefileGenerator::NewFactory());
+ this->Generators.push_back(
+ cmGlobalNMakeMakefileGenerator::NewFactory());
+ this->Generators.push_back(
+ cmGlobalJOMMakefileGenerator::NewFactory());
+ this->Generators.push_back(
+ cmGlobalWatcomWMakeGenerator::NewFactory());
# endif
- this->Generators[cmGlobalMSYSMakefileGenerator::GetActualName()] =
- cmGlobalMSYSMakefileGenerator::NewFactory();
- this->Generators[cmGlobalMinGWMakefileGenerator::GetActualName()] =
- cmGlobalMinGWMakefileGenerator::NewFactory();
+ this->Generators.push_back(
+ cmGlobalMSYSMakefileGenerator::NewFactory());
+ this->Generators.push_back(
+ cmGlobalMinGWMakefileGenerator::NewFactory());
#endif
- this->Generators[cmGlobalUnixMakefileGenerator3::GetActualName()] =
- cmGlobalUnixMakefileGenerator3::NewFactory();
- this->Generators[cmGlobalNinjaGenerator::GetActualName()] =
- cmGlobalNinjaGenerator::NewFactory();
+ this->Generators.push_back(
+ cmGlobalUnixMakefileGenerator3::NewFactory());
+ this->Generators.push_back(
+ cmGlobalNinjaGenerator::NewFactory());
#ifdef CMAKE_USE_XCODE
- this->Generators[cmGlobalXCodeGenerator::GetActualName()] =
- cmGlobalXCodeGenerator::NewFactory();
+ this->Generators.push_back(
+ cmGlobalXCodeGenerator::NewFactory());
#endif
}
@@ -2720,15 +2724,15 @@ void cmake::GetPropertiesDocumentation(std::map<std::string,
void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v)
{
- for(RegisteredGeneratorsMap::const_iterator i = this->Generators.begin();
- i != this->Generators.end(); ++i)
+ for(RegisteredGeneratorsVector::const_iterator i =
+ this->Generators.begin(); i != this->Generators.end(); ++i)
{
cmDocumentationEntry e;
- i->second->GetDocumentation(e);
+ (*i)->GetDocumentation(e);
v.push_back(e);
}
- for(RegisteredExtraGeneratorsMap::const_iterator
- i = this->ExtraGenerators.begin(); i != this->ExtraGenerators.end(); ++i)
+ for(RegisteredExtraGeneratorsMap::const_iterator i =
+ this->ExtraGenerators.begin(); i != this->ExtraGenerators.end(); ++i)
{
cmDocumentationEntry e;
cmExternalMakefileProjectGenerator* generator = (i->second)();
diff --git a/Source/cmake.h b/Source/cmake.h
index e6bfa44..79e05ca 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -397,10 +397,9 @@ protected:
cmExternalMakefileProjectGenerator* (*CreateExtraGeneratorFunctionType)();
typedef std::map<cmStdString,
CreateExtraGeneratorFunctionType> RegisteredExtraGeneratorsMap;
- typedef std::map<cmStdString,
- cmGlobalGeneratorFactory*> RegisteredGeneratorsMap;
+ typedef std::vector<cmGlobalGeneratorFactory*> RegisteredGeneratorsVector;
RegisteredCommandsMap Commands;
- RegisteredGeneratorsMap Generators;
+ RegisteredGeneratorsVector Generators;
RegisteredExtraGeneratorsMap ExtraGenerators;
void AddDefaultCommands();
void AddDefaultGenerators();