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().
This commit is contained in:
parent
984ebc3350
commit
04ff866ca8
|
@ -29,7 +29,7 @@ public:
|
||||||
virtual ~cmGlobalGeneratorFactory() {}
|
virtual ~cmGlobalGeneratorFactory() {}
|
||||||
|
|
||||||
/** Create a GlobalGenerator */
|
/** Create a GlobalGenerator */
|
||||||
virtual cmGlobalGenerator* CreateGlobalGenerator() const = 0;
|
virtual cmGlobalGenerator* CreateGlobalGenerator(const char* n) const = 0;
|
||||||
|
|
||||||
/** Get the documentation entry for this factory */
|
/** Get the documentation entry for this factory */
|
||||||
virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0;
|
virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0;
|
||||||
|
@ -43,7 +43,8 @@ class cmGlobalGeneratorSimpleFactory : public cmGlobalGeneratorFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Create a GlobalGenerator */
|
/** Create a GlobalGenerator */
|
||||||
virtual cmGlobalGenerator* CreateGlobalGenerator() const {
|
virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const {
|
||||||
|
if (strcmp(name, T::GetActualName())) return 0;
|
||||||
return new T; }
|
return new T; }
|
||||||
|
|
||||||
/** Get the documentation entry for this factory */
|
/** Get the documentation entry for this factory */
|
||||||
|
|
|
@ -116,7 +116,7 @@ public:
|
||||||
class cmGlobalXCodeGenerator::Factory : public cmGlobalGeneratorFactory
|
class cmGlobalXCodeGenerator::Factory : public cmGlobalGeneratorFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual cmGlobalGenerator* CreateGlobalGenerator() const;
|
virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const;
|
||||||
|
|
||||||
virtual void GetDocumentation(cmDocumentationEntry& entry) const {
|
virtual void GetDocumentation(cmDocumentationEntry& entry) const {
|
||||||
cmGlobalXCodeGenerator().GetDocumentation(entry); }
|
cmGlobalXCodeGenerator().GetDocumentation(entry); }
|
||||||
|
@ -152,8 +152,10 @@ cmGlobalGeneratorFactory* cmGlobalXCodeGenerator::NewFactory()
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmGlobalGenerator* cmGlobalXCodeGenerator::Factory
|
cmGlobalGenerator* cmGlobalXCodeGenerator::Factory
|
||||||
::CreateGlobalGenerator() const
|
::CreateGlobalGenerator(const char* name) const
|
||||||
{
|
{
|
||||||
|
if (strcmp(name, GetActualName()))
|
||||||
|
return 0;
|
||||||
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
||||||
cmXcodeVersionParser parser;
|
cmXcodeVersionParser parser;
|
||||||
std::string versionFile;
|
std::string versionFile;
|
||||||
|
|
120
Source/cmake.cxx
120
Source/cmake.cxx
|
@ -222,10 +222,10 @@ cmake::~cmake()
|
||||||
{
|
{
|
||||||
delete (*j).second;
|
delete (*j).second;
|
||||||
}
|
}
|
||||||
for(RegisteredGeneratorsMap::iterator j = this->Generators.begin();
|
for(RegisteredGeneratorsVector::iterator j = this->Generators.begin();
|
||||||
j != this->Generators.end(); ++j)
|
j != this->Generators.end(); ++j)
|
||||||
{
|
{
|
||||||
delete (*j).second;
|
delete *j;
|
||||||
}
|
}
|
||||||
#ifdef CMAKE_BUILD_WITH_CMAKE
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
||||||
delete this->VariableWatch;
|
delete this->VariableWatch;
|
||||||
|
@ -1874,10 +1874,10 @@ void cmake::AddDefaultExtraGenerators()
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmake::GetRegisteredGenerators(std::vector<std::string>& names)
|
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 != this->Generators.end(); ++i)
|
||||||
{
|
{
|
||||||
i->second->GetGenerators(names);
|
(*i)->GetGenerators(names);
|
||||||
}
|
}
|
||||||
for(RegisteredExtraGeneratorsMap::const_iterator
|
for(RegisteredExtraGeneratorsMap::const_iterator
|
||||||
i = this->ExtraGenerators.begin();
|
i = this->ExtraGenerators.begin();
|
||||||
|
@ -1899,10 +1899,14 @@ cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmGlobalGenerator* generator = 0;
|
cmGlobalGenerator* generator = 0;
|
||||||
RegisteredGeneratorsMap::const_iterator genIt = this->Generators.find(name);
|
for (RegisteredGeneratorsVector::const_iterator i =
|
||||||
if(genIt != this->Generators.end())
|
this->Generators.begin(); i != this->Generators.end(); ++i)
|
||||||
{
|
{
|
||||||
generator = genIt->second->CreateGlobalGenerator();
|
generator = (*i)->CreateGlobalGenerator(name);
|
||||||
|
if (generator)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (generator)
|
if (generator)
|
||||||
|
@ -2578,55 +2582,55 @@ void cmake::AddDefaultGenerators()
|
||||||
{
|
{
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
# if !defined(CMAKE_BOOT_MINGW)
|
# if !defined(CMAKE_BOOT_MINGW)
|
||||||
this->Generators[cmGlobalVisualStudio6Generator::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalVisualStudio6Generator::NewFactory();
|
cmGlobalVisualStudio6Generator::NewFactory());
|
||||||
this->Generators[cmGlobalVisualStudio7Generator::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalVisualStudio7Generator::NewFactory();
|
cmGlobalVisualStudio7Generator::NewFactory());
|
||||||
this->Generators[cmGlobalVisualStudio10Generator::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalVisualStudio10Generator::NewFactory();
|
cmGlobalVisualStudio10Generator::NewFactory());
|
||||||
this->Generators[cmGlobalVisualStudio10IA64Generator::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalVisualStudio10IA64Generator::NewFactory();
|
cmGlobalVisualStudio10IA64Generator::NewFactory());
|
||||||
this->Generators[cmGlobalVisualStudio10Win64Generator::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalVisualStudio10Win64Generator::NewFactory();
|
cmGlobalVisualStudio10Win64Generator::NewFactory());
|
||||||
this->Generators[cmGlobalVisualStudio11Generator::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalVisualStudio11Generator::NewFactory();
|
cmGlobalVisualStudio11Generator::NewFactory());
|
||||||
this->Generators[cmGlobalVisualStudio11Win64Generator::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalVisualStudio11Win64Generator::NewFactory();
|
cmGlobalVisualStudio11Win64Generator::NewFactory());
|
||||||
this->Generators[cmGlobalVisualStudio11ARMGenerator::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalVisualStudio11ARMGenerator::NewFactory();
|
cmGlobalVisualStudio11ARMGenerator::NewFactory());
|
||||||
this->Generators[cmGlobalVisualStudio71Generator::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalVisualStudio71Generator::NewFactory();
|
cmGlobalVisualStudio71Generator::NewFactory());
|
||||||
this->Generators[cmGlobalVisualStudio8Generator::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalVisualStudio8Generator::NewFactory();
|
cmGlobalVisualStudio8Generator::NewFactory());
|
||||||
this->Generators[cmGlobalVisualStudio9Generator::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalVisualStudio9Generator::NewFactory();
|
cmGlobalVisualStudio9Generator::NewFactory());
|
||||||
this->Generators[cmGlobalVisualStudio9IA64Generator::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalVisualStudio9IA64Generator::NewFactory();
|
cmGlobalVisualStudio9IA64Generator::NewFactory());
|
||||||
this->Generators[cmGlobalVisualStudio9Win64Generator::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalVisualStudio9Win64Generator::NewFactory();
|
cmGlobalVisualStudio9Win64Generator::NewFactory());
|
||||||
this->Generators[cmGlobalVisualStudio8Win64Generator::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalVisualStudio8Win64Generator::NewFactory();
|
cmGlobalVisualStudio8Win64Generator::NewFactory());
|
||||||
this->Generators[cmGlobalBorlandMakefileGenerator::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalBorlandMakefileGenerator::NewFactory();
|
cmGlobalBorlandMakefileGenerator::NewFactory());
|
||||||
this->Generators[cmGlobalNMakeMakefileGenerator::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalNMakeMakefileGenerator::NewFactory();
|
cmGlobalNMakeMakefileGenerator::NewFactory());
|
||||||
this->Generators[cmGlobalJOMMakefileGenerator::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalJOMMakefileGenerator::NewFactory();
|
cmGlobalJOMMakefileGenerator::NewFactory());
|
||||||
this->Generators[cmGlobalWatcomWMakeGenerator::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalWatcomWMakeGenerator::NewFactory();
|
cmGlobalWatcomWMakeGenerator::NewFactory());
|
||||||
# endif
|
# endif
|
||||||
this->Generators[cmGlobalMSYSMakefileGenerator::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalMSYSMakefileGenerator::NewFactory();
|
cmGlobalMSYSMakefileGenerator::NewFactory());
|
||||||
this->Generators[cmGlobalMinGWMakefileGenerator::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalMinGWMakefileGenerator::NewFactory();
|
cmGlobalMinGWMakefileGenerator::NewFactory());
|
||||||
#endif
|
#endif
|
||||||
this->Generators[cmGlobalUnixMakefileGenerator3::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalUnixMakefileGenerator3::NewFactory();
|
cmGlobalUnixMakefileGenerator3::NewFactory());
|
||||||
this->Generators[cmGlobalNinjaGenerator::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalNinjaGenerator::NewFactory();
|
cmGlobalNinjaGenerator::NewFactory());
|
||||||
#ifdef CMAKE_USE_XCODE
|
#ifdef CMAKE_USE_XCODE
|
||||||
this->Generators[cmGlobalXCodeGenerator::GetActualName()] =
|
this->Generators.push_back(
|
||||||
cmGlobalXCodeGenerator::NewFactory();
|
cmGlobalXCodeGenerator::NewFactory());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2720,15 +2724,15 @@ void cmake::GetPropertiesDocumentation(std::map<std::string,
|
||||||
|
|
||||||
void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v)
|
void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v)
|
||||||
{
|
{
|
||||||
for(RegisteredGeneratorsMap::const_iterator i = this->Generators.begin();
|
for(RegisteredGeneratorsVector::const_iterator i =
|
||||||
i != this->Generators.end(); ++i)
|
this->Generators.begin(); i != this->Generators.end(); ++i)
|
||||||
{
|
{
|
||||||
cmDocumentationEntry e;
|
cmDocumentationEntry e;
|
||||||
i->second->GetDocumentation(e);
|
(*i)->GetDocumentation(e);
|
||||||
v.push_back(e);
|
v.push_back(e);
|
||||||
}
|
}
|
||||||
for(RegisteredExtraGeneratorsMap::const_iterator
|
for(RegisteredExtraGeneratorsMap::const_iterator i =
|
||||||
i = this->ExtraGenerators.begin(); i != this->ExtraGenerators.end(); ++i)
|
this->ExtraGenerators.begin(); i != this->ExtraGenerators.end(); ++i)
|
||||||
{
|
{
|
||||||
cmDocumentationEntry e;
|
cmDocumentationEntry e;
|
||||||
cmExternalMakefileProjectGenerator* generator = (i->second)();
|
cmExternalMakefileProjectGenerator* generator = (i->second)();
|
||||||
|
|
|
@ -397,10 +397,9 @@ protected:
|
||||||
cmExternalMakefileProjectGenerator* (*CreateExtraGeneratorFunctionType)();
|
cmExternalMakefileProjectGenerator* (*CreateExtraGeneratorFunctionType)();
|
||||||
typedef std::map<cmStdString,
|
typedef std::map<cmStdString,
|
||||||
CreateExtraGeneratorFunctionType> RegisteredExtraGeneratorsMap;
|
CreateExtraGeneratorFunctionType> RegisteredExtraGeneratorsMap;
|
||||||
typedef std::map<cmStdString,
|
typedef std::vector<cmGlobalGeneratorFactory*> RegisteredGeneratorsVector;
|
||||||
cmGlobalGeneratorFactory*> RegisteredGeneratorsMap;
|
|
||||||
RegisteredCommandsMap Commands;
|
RegisteredCommandsMap Commands;
|
||||||
RegisteredGeneratorsMap Generators;
|
RegisteredGeneratorsVector Generators;
|
||||||
RegisteredExtraGeneratorsMap ExtraGenerators;
|
RegisteredExtraGeneratorsMap ExtraGenerators;
|
||||||
void AddDefaultCommands();
|
void AddDefaultCommands();
|
||||||
void AddDefaultGenerators();
|
void AddDefaultGenerators();
|
||||||
|
|
Loading…
Reference in New Issue