diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 8bf6c4084..7bf167818 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -201,6 +201,7 @@ set(SRCS cmGeneratorTarget.h cmGlobalGenerator.cxx cmGlobalGenerator.h + cmGlobalGeneratorFactory.h cmGlobalUnixMakefileGenerator3.cxx cmGlobalUnixMakefileGenerator3.h cmGraphAdjacencyList.h diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h index c0cb8a6d1..40bdcb03b 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.h +++ b/Source/cmGlobalBorlandMakefileGenerator.h @@ -23,8 +23,9 @@ class cmGlobalBorlandMakefileGenerator : public cmGlobalNMakeMakefileGenerator { public: cmGlobalBorlandMakefileGenerator(); - static cmGlobalGenerator* New() - { return new cmGlobalBorlandMakefileGenerator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + (); } ///! Get the name for the generator. virtual const char* GetName() const { diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h new file mode 100644 index 000000000..05c84208e --- /dev/null +++ b/Source/cmGlobalGeneratorFactory.h @@ -0,0 +1,51 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2012 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmGlobalGeneratorFactory_h +#define cmGlobalGeneratorFactory_h + +#include "cmStandardIncludes.h" + +class cmGlobalGenerator; +struct cmDocumentationEntry; + +/** \class cmGlobalGeneratorFactory + * \brief Responable for creating cmGlobalGenerator instances + * + * Subclasses of this class generate instances of cmGlobalGenerator. + */ +class cmGlobalGeneratorFactory +{ +public: + virtual ~cmGlobalGeneratorFactory() {} + + /** Create a GlobalGenerator */ + virtual cmGlobalGenerator* CreateGlobalGenerator() const = 0; + + /** Get the documentation entry for this factory */ + virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0; +}; + +template +class cmGlobalGeneratorSimpleFactory : public cmGlobalGeneratorFactory +{ +public: + /** Create a GlobalGenerator */ + virtual cmGlobalGenerator* CreateGlobalGenerator() const { + return new T; } + + /** Get the documentation entry for this factory */ + virtual void GetDocumentation(cmDocumentationEntry& entry) const { + T().GetDocumentation(entry); } +}; + +#endif diff --git a/Source/cmGlobalJOMMakefileGenerator.h b/Source/cmGlobalJOMMakefileGenerator.h index 691ebdb8f..8686fbfee 100644 --- a/Source/cmGlobalJOMMakefileGenerator.h +++ b/Source/cmGlobalJOMMakefileGenerator.h @@ -23,8 +23,9 @@ class cmGlobalJOMMakefileGenerator : public cmGlobalUnixMakefileGenerator3 { public: cmGlobalJOMMakefileGenerator(); - static cmGlobalGenerator* New() { - return new cmGlobalJOMMakefileGenerator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + (); } ///! Get the name for the generator. virtual const char* GetName() const { return cmGlobalJOMMakefileGenerator::GetActualName();} diff --git a/Source/cmGlobalMSYSMakefileGenerator.h b/Source/cmGlobalMSYSMakefileGenerator.h index b76a5bf9b..17decf2c9 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.h +++ b/Source/cmGlobalMSYSMakefileGenerator.h @@ -23,8 +23,9 @@ class cmGlobalMSYSMakefileGenerator : public cmGlobalUnixMakefileGenerator3 { public: cmGlobalMSYSMakefileGenerator(); - static cmGlobalGenerator* New() { - return new cmGlobalMSYSMakefileGenerator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + (); } ///! Get the name for the generator. virtual const char* GetName() const { diff --git a/Source/cmGlobalMinGWMakefileGenerator.h b/Source/cmGlobalMinGWMakefileGenerator.h index 9a6a5139f..54a6f5b3f 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.h +++ b/Source/cmGlobalMinGWMakefileGenerator.h @@ -23,8 +23,9 @@ class cmGlobalMinGWMakefileGenerator : public cmGlobalUnixMakefileGenerator3 { public: cmGlobalMinGWMakefileGenerator(); - static cmGlobalGenerator* New() { - return new cmGlobalMinGWMakefileGenerator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + (); } ///! Get the name for the generator. virtual const char* GetName() const { return cmGlobalMinGWMakefileGenerator::GetActualName();} diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h index de33b8f94..183ea9e0b 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.h +++ b/Source/cmGlobalNMakeMakefileGenerator.h @@ -23,8 +23,9 @@ class cmGlobalNMakeMakefileGenerator : public cmGlobalUnixMakefileGenerator3 { public: cmGlobalNMakeMakefileGenerator(); - static cmGlobalGenerator* New() { - return new cmGlobalNMakeMakefileGenerator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + (); } ///! Get the name for the generator. virtual const char* GetName() const { return cmGlobalNMakeMakefileGenerator::GetActualName();} diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 24c391610..7e1f6e3b9 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -14,6 +14,7 @@ # define cmGlobalNinjaGenerator_h # include "cmGlobalGenerator.h" +# include "cmGlobalGeneratorFactory.h" # include "cmNinjaTypes.h" //#define NINJA_GEN_VERBOSE_FILES @@ -160,8 +161,8 @@ public: cmGlobalNinjaGenerator(); /// Convenience method for creating an instance of this class. - static cmGlobalGenerator* New() { - return new cmGlobalNinjaGenerator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory(); } /// Destructor. virtual ~cmGlobalNinjaGenerator() { } diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index e6dd09d6d..914820c37 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -13,6 +13,7 @@ #define cmGlobalUnixMakefileGenerator3_h #include "cmGlobalGenerator.h" +#include "cmGlobalGeneratorFactory.h" class cmGeneratedFileStream; class cmMakefileTargetGenerator; @@ -54,8 +55,9 @@ class cmGlobalUnixMakefileGenerator3 : public cmGlobalGenerator { public: cmGlobalUnixMakefileGenerator3(); - static cmGlobalGenerator* New() { - return new cmGlobalUnixMakefileGenerator3; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + (); } ///! Get the name for the generator. virtual const char* GetName() const { diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 47ce790f8..58bad5989 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -25,8 +25,9 @@ class cmGlobalVisualStudio10Generator : { public: cmGlobalVisualStudio10Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio10Generator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + (); } virtual std::string GenerateBuildCommand(const char* makeProgram, diff --git a/Source/cmGlobalVisualStudio10IA64Generator.h b/Source/cmGlobalVisualStudio10IA64Generator.h index a088272ef..a7819a31c 100644 --- a/Source/cmGlobalVisualStudio10IA64Generator.h +++ b/Source/cmGlobalVisualStudio10IA64Generator.h @@ -19,8 +19,9 @@ class cmGlobalVisualStudio10IA64Generator : { public: cmGlobalVisualStudio10IA64Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio10IA64Generator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + (); } ///! Get the name for the generator. virtual const char* GetName() const { diff --git a/Source/cmGlobalVisualStudio10Win64Generator.h b/Source/cmGlobalVisualStudio10Win64Generator.h index 8a2de4c0a..2728d1573 100644 --- a/Source/cmGlobalVisualStudio10Win64Generator.h +++ b/Source/cmGlobalVisualStudio10Win64Generator.h @@ -19,8 +19,9 @@ class cmGlobalVisualStudio10Win64Generator : { public: cmGlobalVisualStudio10Win64Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio10Win64Generator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + (); } ///! Get the name for the generator. virtual const char* GetName() const { diff --git a/Source/cmGlobalVisualStudio11ARMGenerator.h b/Source/cmGlobalVisualStudio11ARMGenerator.h index 71dbf2e3b..b1d30373b 100644 --- a/Source/cmGlobalVisualStudio11ARMGenerator.h +++ b/Source/cmGlobalVisualStudio11ARMGenerator.h @@ -19,8 +19,9 @@ class cmGlobalVisualStudio11ARMGenerator : { public: cmGlobalVisualStudio11ARMGenerator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio11ARMGenerator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + (); } ///! Get the name for the generator. virtual const char* GetName() const { diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index 56337a4db..c8f27a4a8 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -21,8 +21,9 @@ class cmGlobalVisualStudio11Generator: { public: cmGlobalVisualStudio11Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio11Generator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + (); } ///! Get the name for the generator. virtual const char* GetName() const { diff --git a/Source/cmGlobalVisualStudio11Win64Generator.h b/Source/cmGlobalVisualStudio11Win64Generator.h index 9445d156c..5ddf4a785 100644 --- a/Source/cmGlobalVisualStudio11Win64Generator.h +++ b/Source/cmGlobalVisualStudio11Win64Generator.h @@ -19,8 +19,9 @@ class cmGlobalVisualStudio11Win64Generator : { public: cmGlobalVisualStudio11Win64Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio11Win64Generator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + (); } ///! Get the name for the generator. virtual const char* GetName() const { diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index 259aa8d03..bc23cf81b 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -13,6 +13,7 @@ #define cmGlobalVisualStudio6Generator_h #include "cmGlobalVisualStudioGenerator.h" +#include "cmGlobalGeneratorFactory.h" class cmTarget; @@ -25,8 +26,9 @@ class cmGlobalVisualStudio6Generator : public cmGlobalVisualStudioGenerator { public: cmGlobalVisualStudio6Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio6Generator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + (); } ///! Get the name for the generator. virtual const char* GetName() const { diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index a8daad6a2..fa0ad92ef 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -24,8 +24,9 @@ class cmGlobalVisualStudio71Generator : public cmGlobalVisualStudio7Generator { public: cmGlobalVisualStudio71Generator(); - static cmGlobalGenerator* New() - { return new cmGlobalVisualStudio71Generator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + (); } ///! Get the name for the generator. virtual const char* GetName() const { diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 1df58f97b..0f935c78c 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -13,6 +13,7 @@ #define cmGlobalVisualStudio7Generator_h #include "cmGlobalVisualStudioGenerator.h" +#include "cmGlobalGeneratorFactory.h" class cmTarget; struct cmIDEFlagTable; @@ -26,8 +27,9 @@ class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator { public: cmGlobalVisualStudio7Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio7Generator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + (); } ///! Get the name for the generator. virtual const char* GetName() const { diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index 5009f2960..157464b9e 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -24,8 +24,9 @@ class cmGlobalVisualStudio8Generator : public cmGlobalVisualStudio71Generator { public: cmGlobalVisualStudio8Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio8Generator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + (); } ///! Get the name for the generator. virtual const char* GetName() const { diff --git a/Source/cmGlobalVisualStudio8Win64Generator.h b/Source/cmGlobalVisualStudio8Win64Generator.h index 12f80125a..612c5d787 100644 --- a/Source/cmGlobalVisualStudio8Win64Generator.h +++ b/Source/cmGlobalVisualStudio8Win64Generator.h @@ -25,8 +25,9 @@ class cmGlobalVisualStudio8Win64Generator : { public: cmGlobalVisualStudio8Win64Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio8Win64Generator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + (); } ///! Get the name for the generator. virtual const char* GetName() const { diff --git a/Source/cmGlobalVisualStudio9Generator.h b/Source/cmGlobalVisualStudio9Generator.h index 0b0d1437f..d8d5e9045 100644 --- a/Source/cmGlobalVisualStudio9Generator.h +++ b/Source/cmGlobalVisualStudio9Generator.h @@ -25,8 +25,9 @@ class cmGlobalVisualStudio9Generator : { public: cmGlobalVisualStudio9Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio9Generator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + (); } ///! Get the name for the generator. virtual const char* GetName() const { diff --git a/Source/cmGlobalVisualStudio9IA64Generator.h b/Source/cmGlobalVisualStudio9IA64Generator.h index 989b0d1af..27bf71d63 100644 --- a/Source/cmGlobalVisualStudio9IA64Generator.h +++ b/Source/cmGlobalVisualStudio9IA64Generator.h @@ -25,8 +25,9 @@ class cmGlobalVisualStudio9IA64Generator : { public: cmGlobalVisualStudio9IA64Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio9IA64Generator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + (); } ///! Get the name for the generator. virtual const char* GetName() const { diff --git a/Source/cmGlobalVisualStudio9Win64Generator.h b/Source/cmGlobalVisualStudio9Win64Generator.h index 7c20cf4e2..e0c59bafa 100644 --- a/Source/cmGlobalVisualStudio9Win64Generator.h +++ b/Source/cmGlobalVisualStudio9Win64Generator.h @@ -25,8 +25,9 @@ class cmGlobalVisualStudio9Win64Generator : { public: cmGlobalVisualStudio9Win64Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio9Win64Generator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + (); } ///! Get the name for the generator. virtual const char* GetName() const { diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h index ee16eaebc..ac29b1ccd 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.h +++ b/Source/cmGlobalWatcomWMakeGenerator.h @@ -23,7 +23,9 @@ class cmGlobalWatcomWMakeGenerator : public cmGlobalUnixMakefileGenerator3 { public: cmGlobalWatcomWMakeGenerator(); - static cmGlobalGenerator* New() { return new cmGlobalWatcomWMakeGenerator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + (); } ///! Get the name for the generator. virtual const char* GetName() const { return cmGlobalWatcomWMakeGenerator::GetActualName();} diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 5b2ddd8b4..4b07a3689 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -20,6 +20,7 @@ #include "cmSourceFile.h" #include "cmCustomCommandGenerator.h" #include "cmGeneratorTarget.h" +#include "cmGlobalGeneratorFactory.h" #include @@ -112,6 +113,15 @@ public: } }; +class cmGlobalXCodeGenerator::Factory : public cmGlobalGeneratorFactory +{ +public: + virtual cmGlobalGenerator* CreateGlobalGenerator() const; + + virtual void GetDocumentation(cmDocumentationEntry& entry) const { + cmGlobalXCodeGenerator().GetDocumentation(entry); } +}; + //---------------------------------------------------------------------------- cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(std::string const& version) { @@ -132,7 +142,14 @@ cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(std::string const& version) } //---------------------------------------------------------------------------- -cmGlobalGenerator* cmGlobalXCodeGenerator::New() +cmGlobalGeneratorFactory* cmGlobalXCodeGenerator::NewFactory() +{ + return new Factory; +} + +//---------------------------------------------------------------------------- +cmGlobalGenerator* cmGlobalXCodeGenerator::Factory +::CreateGlobalGenerator() const { #if defined(CMAKE_BUILD_WITH_CMAKE) cmXcodeVersionParser parser; diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index afa1ca22e..c79293a1e 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -15,6 +15,7 @@ #include "cmGlobalGenerator.h" #include "cmXCodeObject.h" #include "cmCustomCommand.h" +class cmGlobalGeneratorFactory; class cmTarget; class cmSourceFile; class cmSourceGroup; @@ -29,7 +30,7 @@ class cmGlobalXCodeGenerator : public cmGlobalGenerator { public: cmGlobalXCodeGenerator(std::string const& version); - static cmGlobalGenerator* New(); + static cmGlobalGeneratorFactory* NewFactory(); ///! Get the name for the generator. virtual const char* GetName() const { @@ -186,6 +187,7 @@ private: const char* varNameSuffix, const char* default_flags); + class Factory; class BuildObjectListOrString; friend class BuildObjectListOrString; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 012342715..08a322f9d 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -222,6 +222,11 @@ cmake::~cmake() { delete (*j).second; } + for(RegisteredGeneratorsMap::iterator j = this->Generators.begin(); + j != this->Generators.end(); ++j) + { + delete (*j).second; + } #ifdef CMAKE_BUILD_WITH_CMAKE delete this->VariableWatch; #endif @@ -1904,7 +1909,7 @@ cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name) } } - generator = (genIt->second)(); + generator = genIt->second->CreateGlobalGenerator(); generator->SetCMakeInstance(this); generator->SetExternalMakefileProjectGenerator(extraGenerator); return generator; @@ -2571,54 +2576,54 @@ void cmake::AddDefaultGenerators() #if defined(_WIN32) && !defined(__CYGWIN__) # if !defined(CMAKE_BOOT_MINGW) this->Generators[cmGlobalVisualStudio6Generator::GetActualName()] = - &cmGlobalVisualStudio6Generator::New; + cmGlobalVisualStudio6Generator::NewFactory(); this->Generators[cmGlobalVisualStudio7Generator::GetActualName()] = - &cmGlobalVisualStudio7Generator::New; + cmGlobalVisualStudio7Generator::NewFactory(); this->Generators[cmGlobalVisualStudio10Generator::GetActualName()] = - &cmGlobalVisualStudio10Generator::New; + cmGlobalVisualStudio10Generator::NewFactory(); this->Generators[cmGlobalVisualStudio10IA64Generator::GetActualName()] = - &cmGlobalVisualStudio10IA64Generator::New; + cmGlobalVisualStudio10IA64Generator::NewFactory(); this->Generators[cmGlobalVisualStudio10Win64Generator::GetActualName()] = - &cmGlobalVisualStudio10Win64Generator::New; + cmGlobalVisualStudio10Win64Generator::NewFactory(); this->Generators[cmGlobalVisualStudio11Generator::GetActualName()] = - &cmGlobalVisualStudio11Generator::New; + cmGlobalVisualStudio11Generator::NewFactory(); this->Generators[cmGlobalVisualStudio11Win64Generator::GetActualName()] = - &cmGlobalVisualStudio11Win64Generator::New; + cmGlobalVisualStudio11Win64Generator::NewFactory(); this->Generators[cmGlobalVisualStudio11ARMGenerator::GetActualName()] = - &cmGlobalVisualStudio11ARMGenerator::New; + cmGlobalVisualStudio11ARMGenerator::NewFactory(); this->Generators[cmGlobalVisualStudio71Generator::GetActualName()] = - &cmGlobalVisualStudio71Generator::New; + cmGlobalVisualStudio71Generator::NewFactory(); this->Generators[cmGlobalVisualStudio8Generator::GetActualName()] = - &cmGlobalVisualStudio8Generator::New; + cmGlobalVisualStudio8Generator::NewFactory(); this->Generators[cmGlobalVisualStudio9Generator::GetActualName()] = - &cmGlobalVisualStudio9Generator::New; + cmGlobalVisualStudio9Generator::NewFactory(); this->Generators[cmGlobalVisualStudio9IA64Generator::GetActualName()] = - &cmGlobalVisualStudio9IA64Generator::New; + cmGlobalVisualStudio9IA64Generator::NewFactory(); this->Generators[cmGlobalVisualStudio9Win64Generator::GetActualName()] = - &cmGlobalVisualStudio9Win64Generator::New; + cmGlobalVisualStudio9Win64Generator::NewFactory(); this->Generators[cmGlobalVisualStudio8Win64Generator::GetActualName()] = - &cmGlobalVisualStudio8Win64Generator::New; + cmGlobalVisualStudio8Win64Generator::NewFactory(); this->Generators[cmGlobalBorlandMakefileGenerator::GetActualName()] = - &cmGlobalBorlandMakefileGenerator::New; + cmGlobalBorlandMakefileGenerator::NewFactory(); this->Generators[cmGlobalNMakeMakefileGenerator::GetActualName()] = - &cmGlobalNMakeMakefileGenerator::New; + cmGlobalNMakeMakefileGenerator::NewFactory(); this->Generators[cmGlobalJOMMakefileGenerator::GetActualName()] = - &cmGlobalJOMMakefileGenerator::New; + cmGlobalJOMMakefileGenerator::NewFactory(); this->Generators[cmGlobalWatcomWMakeGenerator::GetActualName()] = - &cmGlobalWatcomWMakeGenerator::New; + cmGlobalWatcomWMakeGenerator::NewFactory(); # endif this->Generators[cmGlobalMSYSMakefileGenerator::GetActualName()] = - &cmGlobalMSYSMakefileGenerator::New; + cmGlobalMSYSMakefileGenerator::NewFactory(); this->Generators[cmGlobalMinGWMakefileGenerator::GetActualName()] = - &cmGlobalMinGWMakefileGenerator::New; + cmGlobalMinGWMakefileGenerator::NewFactory(); #endif this->Generators[cmGlobalUnixMakefileGenerator3::GetActualName()] = - &cmGlobalUnixMakefileGenerator3::New; + cmGlobalUnixMakefileGenerator3::NewFactory(); this->Generators[cmGlobalNinjaGenerator::GetActualName()] = - &cmGlobalNinjaGenerator::New; + cmGlobalNinjaGenerator::NewFactory(); #ifdef CMAKE_USE_XCODE this->Generators[cmGlobalXCodeGenerator::GetActualName()] = - &cmGlobalXCodeGenerator::New; + cmGlobalXCodeGenerator::NewFactory(); #endif } @@ -2716,9 +2721,7 @@ void cmake::GetGeneratorDocumentation(std::vector& v) i != this->Generators.end(); ++i) { cmDocumentationEntry e; - cmGlobalGenerator* generator = (i->second)(); - generator->GetDocumentation(e); - delete generator; + i->second->GetDocumentation(e); v.push_back(e); } for(RegisteredExtraGeneratorsMap::const_iterator diff --git a/Source/cmake.h b/Source/cmake.h index 94c6f128f..e6bfa44dd 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -17,6 +17,7 @@ #include "cmPropertyDefinitionMap.h" #include "cmPropertyMap.h" +class cmGlobalGeneratorFactory; class cmGlobalGenerator; class cmLocalGenerator; class cmCacheManager; @@ -396,10 +397,8 @@ protected: cmExternalMakefileProjectGenerator* (*CreateExtraGeneratorFunctionType)(); typedef std::map RegisteredExtraGeneratorsMap; - - typedef cmGlobalGenerator* (*CreateGeneratorFunctionType)(); typedef std::map RegisteredGeneratorsMap; + cmGlobalGeneratorFactory*> RegisteredGeneratorsMap; RegisteredCommandsMap Commands; RegisteredGeneratorsMap Generators; RegisteredExtraGeneratorsMap ExtraGenerators;