diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 8bf6c4084..fa174bc2f 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 @@ -330,12 +331,6 @@ if (WIN32) cmGlobalVisualStudio8Generator.h cmGlobalVisualStudio9Generator.cxx cmGlobalVisualStudio9Generator.h - cmGlobalVisualStudio8Win64Generator.cxx - cmGlobalVisualStudio8Win64Generator.h - cmGlobalVisualStudio9Win64Generator.cxx - cmGlobalVisualStudio9Win64Generator.h - cmGlobalVisualStudio9IA64Generator.cxx - cmGlobalVisualStudio9IA64Generator.h cmVisualStudioGeneratorOptions.h cmVisualStudioGeneratorOptions.cxx cmVisualStudio10TargetGenerator.h @@ -344,16 +339,8 @@ if (WIN32) cmLocalVisualStudio10Generator.h cmGlobalVisualStudio10Generator.h cmGlobalVisualStudio10Generator.cxx - cmGlobalVisualStudio10Win64Generator.h - cmGlobalVisualStudio10Win64Generator.cxx - cmGlobalVisualStudio10IA64Generator.h - cmGlobalVisualStudio10IA64Generator.cxx cmGlobalVisualStudio11Generator.h cmGlobalVisualStudio11Generator.cxx - cmGlobalVisualStudio11Win64Generator.h - cmGlobalVisualStudio11Win64Generator.cxx - cmGlobalVisualStudio11ARMGenerator.h - cmGlobalVisualStudio11ARMGenerator.cxx cmGlobalVisualStudioGenerator.cxx cmGlobalVisualStudioGenerator.h cmGlobalWatcomWMakeGenerator.cxx diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx index 8c6787a2c..2a7d61d6a 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.cxx +++ b/Source/cmGlobalBorlandMakefileGenerator.cxx @@ -55,9 +55,9 @@ cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator() //---------------------------------------------------------------------------- void cmGlobalBorlandMakefileGenerator -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalBorlandMakefileGenerator::GetActualName(); entry.Brief = "Generates Borland makefiles."; entry.Full = ""; } diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h index c0cb8a6d1..bd3db3eae 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 { @@ -32,7 +33,7 @@ public: static const char* GetActualName() {return "Borland Makefiles";} /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 6c95ea805..154e6298f 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1556,14 +1556,6 @@ void cmGlobalGenerator::SetConfiguredFilesPath(cmGlobalGenerator* gen) } } -//---------------------------------------------------------------------------- -void cmGlobalGenerator::GetDocumentation(cmDocumentationEntry& entry) const -{ - entry.Name = this->GetName(); - entry.Brief = ""; - entry.Full = ""; -} - bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 0aab2d63e..bb805d9b1 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -49,9 +49,6 @@ public: ///! Get the name for this generator virtual const char *GetName() const { return "Generic"; }; - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; - /** * Create LocalGenerators and process the CMakeLists files. This does not * actually produce any makefiles, DSPs, etc. diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h new file mode 100644 index 000000000..fd1d65fb5 --- /dev/null +++ b/Source/cmGlobalGeneratorFactory.h @@ -0,0 +1,59 @@ +/*============================================================================ + 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 char* n) const = 0; + + /** Get the documentation entry for this factory */ + virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0; + + /** Get the names of the current registered generators */ + virtual void GetGenerators(std::vector& names) const = 0; +}; + +template +class cmGlobalGeneratorSimpleFactory : public cmGlobalGeneratorFactory +{ +public: + /** Create a GlobalGenerator */ + virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { + if (strcmp(name, T::GetActualName())) return 0; + return new T; } + + /** Get the documentation entry for this factory */ + virtual void GetDocumentation(cmDocumentationEntry& entry) const { + T::GetDocumentation(entry); } + + /** Get the names of the current registered generators */ + virtual void GetGenerators(std::vector& names) const { + names.push_back(T::GetActualName()); } +}; + +#endif diff --git a/Source/cmGlobalJOMMakefileGenerator.cxx b/Source/cmGlobalJOMMakefileGenerator.cxx index ef42bd4d6..4af06076f 100644 --- a/Source/cmGlobalJOMMakefileGenerator.cxx +++ b/Source/cmGlobalJOMMakefileGenerator.cxx @@ -61,9 +61,9 @@ cmLocalGenerator *cmGlobalJOMMakefileGenerator::CreateLocalGenerator() //---------------------------------------------------------------------------- void cmGlobalJOMMakefileGenerator -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalJOMMakefileGenerator::GetActualName(); entry.Brief = "Generates JOM makefiles."; entry.Full = ""; } diff --git a/Source/cmGlobalJOMMakefileGenerator.h b/Source/cmGlobalJOMMakefileGenerator.h index 691ebdb8f..28893bf27 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();} @@ -33,7 +34,7 @@ public: static const char* GetActualName() {return "NMake Makefiles JOM";} /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); diff --git a/Source/cmGlobalMSYSMakefileGenerator.cxx b/Source/cmGlobalMSYSMakefileGenerator.cxx index 80526aad8..d49639bef 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.cxx +++ b/Source/cmGlobalMSYSMakefileGenerator.cxx @@ -106,9 +106,9 @@ cmLocalGenerator *cmGlobalMSYSMakefileGenerator::CreateLocalGenerator() //---------------------------------------------------------------------------- void cmGlobalMSYSMakefileGenerator -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalMSYSMakefileGenerator::GetActualName(); entry.Brief = "Generates MSYS makefiles."; entry.Full = "The makefiles use /bin/sh as the shell. " "They require msys to be installed on the machine."; diff --git a/Source/cmGlobalMSYSMakefileGenerator.h b/Source/cmGlobalMSYSMakefileGenerator.h index b76a5bf9b..659de1186 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 { @@ -32,7 +33,7 @@ public: static const char* GetActualName() {return "MSYS Makefiles";} /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); diff --git a/Source/cmGlobalMinGWMakefileGenerator.cxx b/Source/cmGlobalMinGWMakefileGenerator.cxx index d6045c8de..e202b0230 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.cxx +++ b/Source/cmGlobalMinGWMakefileGenerator.cxx @@ -71,9 +71,9 @@ cmLocalGenerator *cmGlobalMinGWMakefileGenerator::CreateLocalGenerator() //---------------------------------------------------------------------------- void cmGlobalMinGWMakefileGenerator -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalMinGWMakefileGenerator::GetActualName(); entry.Brief = "Generates a make file for use with mingw32-make."; entry.Full = "The makefiles generated use cmd.exe as the shell. " "They do not require msys or a unix shell."; diff --git a/Source/cmGlobalMinGWMakefileGenerator.h b/Source/cmGlobalMinGWMakefileGenerator.h index 9a6a5139f..7951e9886 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.h +++ b/Source/cmGlobalMinGWMakefileGenerator.h @@ -23,15 +23,16 @@ 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();} static const char* GetActualName() {return "MinGW Makefiles";} /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx index 57a26c8ae..7af4ee3a8 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.cxx +++ b/Source/cmGlobalNMakeMakefileGenerator.cxx @@ -61,9 +61,9 @@ cmLocalGenerator *cmGlobalNMakeMakefileGenerator::CreateLocalGenerator() //---------------------------------------------------------------------------- void cmGlobalNMakeMakefileGenerator -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalNMakeMakefileGenerator::GetActualName(); entry.Brief = "Generates NMake makefiles."; entry.Full = ""; } diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h index de33b8f94..5756fbd0d 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.h +++ b/Source/cmGlobalNMakeMakefileGenerator.h @@ -23,15 +23,16 @@ 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();} static const char* GetActualName() {return "NMake Makefiles";} /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 05f5b4c86..60f5a4746 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -452,9 +452,9 @@ cmLocalGenerator* cmGlobalNinjaGenerator::CreateLocalGenerator() } void cmGlobalNinjaGenerator -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalNinjaGenerator::GetActualName(); entry.Brief = "Generates build.ninja files (experimental)."; entry.Full = "A build.ninja file is generated into the build tree. Recent " diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 24c391610..c3df7d935 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() { } @@ -177,7 +178,7 @@ public: static const char* GetActualName() { return "Ninja"; } /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation() - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); /// Overloaded methods. @see cmGlobalGenerator::Generate() virtual void Generate(); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index ebd82194c..e26cca940 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -61,9 +61,9 @@ cmLocalGenerator *cmGlobalUnixMakefileGenerator3::CreateLocalGenerator() //---------------------------------------------------------------------------- void cmGlobalUnixMakefileGenerator3 -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalUnixMakefileGenerator3::GetActualName(); entry.Brief = "Generates standard UNIX makefiles."; entry.Full = "A hierarchy of UNIX makefiles is generated into the build tree. Any " diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index e6dd09d6d..385cdc4a1 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 { @@ -63,7 +65,7 @@ public: static const char* GetActualName() {return "Unix Makefiles";} /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator3 virtual cmLocalGenerator *CreateLocalGenerator(); diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 480c577f2..c218c97ec 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -16,8 +16,61 @@ #include "cmSourceFile.h" #include "cmake.h" +static const char vs10Win32generatorName[] = "Visual Studio 10"; +static const char vs10Win64generatorName[] = "Visual Studio 10 Win64"; +static const char vs10IA64generatorName[] = "Visual Studio 10 IA64"; -cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator() +class cmGlobalVisualStudio10Generator::Factory + : public cmGlobalGeneratorFactory +{ +public: + virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { + if(!strcmp(name, vs10Win32generatorName)) + { + return new cmGlobalVisualStudio10Generator( + vs10Win32generatorName, NULL, NULL); + } + if(!strcmp(name, vs10Win64generatorName)) + { + return new cmGlobalVisualStudio10Generator( + vs10Win64generatorName, "x64", "CMAKE_FORCE_WIN64"); + } + if(!strcmp(name, vs10IA64generatorName)) + { + return new cmGlobalVisualStudio10Generator( + vs10IA64generatorName, "Itanium", "CMAKE_FORCE_IA64"); + } + return 0; + } + + virtual void GetDocumentation(cmDocumentationEntry& entry) const { + entry.Name = "Visual Studio 10"; + entry.Brief = "Generates Visual Studio 10 project files."; + entry.Full = + "It is possible to append a space followed by the platform name " + "to create project files for a specific target platform. E.g. " + "\"Visual Studio 10 Win64\" will create project files for " + "the x64 processor; \"Visual Studio 10 IA64\" for Itanium."; + } + + virtual void GetGenerators(std::vector& names) const { + names.push_back(vs10Win32generatorName); + names.push_back(vs10Win64generatorName); + names.push_back(vs10IA64generatorName); } +}; + +//---------------------------------------------------------------------------- +cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory() +{ + return new Factory; +} + +//---------------------------------------------------------------------------- +cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( + const char* name, const char* architectureId, + const char* additionalPlatformDefinition) + : cmGlobalVisualStudio8Generator(name, architectureId, + additionalPlatformDefinition) { this->FindMakeProgramFile = "CMakeVS10FindMake.cmake"; std::string vc10Express; @@ -86,20 +139,19 @@ void cmGlobalVisualStudio10Generator::Generate() } } -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio10Generator -::GetDocumentation(cmDocumentationEntry& entry) const -{ - entry.Name = this->GetName(); - entry.Brief = "Generates Visual Studio 10 project files."; - entry.Full = ""; -} - //---------------------------------------------------------------------------- void cmGlobalVisualStudio10Generator ::EnableLanguage(std::vectorconst & lang, cmMakefile *mf, bool optional) { + if(!strcmp(this->ArchitectureId, "Itanium") || + !strcmp(this->ArchitectureId, "x64")) + { + if(this->IsExpressEdition() && !this->Find64BitTools(mf)) + { + return; + } + } cmGlobalVisualStudio8Generator::EnableLanguage(lang, mf, optional); } diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 47ce790f8..b377a203d 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -24,9 +24,9 @@ class cmGlobalVisualStudio10Generator : public cmGlobalVisualStudio8Generator { public: - cmGlobalVisualStudio10Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio10Generator; } + cmGlobalVisualStudio10Generator(const char* name, + const char* architectureId, const char* additionalPlatformDefinition); + static cmGlobalGeneratorFactory* NewFactory(); virtual std::string GenerateBuildCommand(const char* makeProgram, @@ -34,15 +34,8 @@ public: const char* additionalOptions, const char *targetName, const char* config, bool ignoreErrors, bool); - ///! Get the name for the generator. - virtual const char* GetName() const { - return cmGlobalVisualStudio10Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 10";} virtual void AddPlatformDefinitions(cmMakefile* mf); - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; - ///! create the correct local generator virtual cmLocalGenerator *CreateLocalGenerator(); @@ -92,6 +85,7 @@ protected: bool UseFolderProperty(); private: + class Factory; struct LongestSourcePath { LongestSourcePath(): Length(0), Target(0), SourceFile(0) {} diff --git a/Source/cmGlobalVisualStudio10IA64Generator.cxx b/Source/cmGlobalVisualStudio10IA64Generator.cxx deleted file mode 100644 index 25dd88f2a..000000000 --- a/Source/cmGlobalVisualStudio10IA64Generator.cxx +++ /dev/null @@ -1,50 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 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. -============================================================================*/ -#include "cmGlobalVisualStudio10IA64Generator.h" -#include "cmMakefile.h" -#include "cmake.h" - -//---------------------------------------------------------------------------- -cmGlobalVisualStudio10IA64Generator::cmGlobalVisualStudio10IA64Generator() -{ - this->ArchitectureId = "x64"; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio10IA64Generator -::GetDocumentation(cmDocumentationEntry& entry) const -{ - entry.Name = this->GetName(); - entry.Brief = "Generates Visual Studio 10 Itanium project files."; - entry.Full = ""; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio10IA64Generator -::AddPlatformDefinitions(cmMakefile* mf) -{ - this->cmGlobalVisualStudio10Generator::AddPlatformDefinitions(mf); - mf->AddDefinition("CMAKE_FORCE_IA64", "TRUE"); -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio10IA64Generator -::EnableLanguage(std::vector const& languages, - cmMakefile* mf, bool optional) -{ - if(this->IsExpressEdition() && !this->Find64BitTools(mf)) - { - return; - } - this->cmGlobalVisualStudio10Generator - ::EnableLanguage(languages, mf, optional); -} diff --git a/Source/cmGlobalVisualStudio10IA64Generator.h b/Source/cmGlobalVisualStudio10IA64Generator.h deleted file mode 100644 index a088272ef..000000000 --- a/Source/cmGlobalVisualStudio10IA64Generator.h +++ /dev/null @@ -1,40 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 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 cmGlobalVisualStudio10IA64Generator_h -#define cmGlobalVisualStudio10IA64Generator_h - -#include "cmGlobalVisualStudio10Generator.h" - -class cmGlobalVisualStudio10IA64Generator : - public cmGlobalVisualStudio10Generator -{ -public: - cmGlobalVisualStudio10IA64Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio10IA64Generator; } - - ///! Get the name for the generator. - virtual const char* GetName() const { - return cmGlobalVisualStudio10IA64Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 10 IA64";} - - virtual const char* GetPlatformName() const {return "Itanium";} - - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; - - virtual void AddPlatformDefinitions(cmMakefile* mf); - - virtual void EnableLanguage(std::vectorconst& languages, - cmMakefile *, bool optional); -}; -#endif diff --git a/Source/cmGlobalVisualStudio10Win64Generator.cxx b/Source/cmGlobalVisualStudio10Win64Generator.cxx deleted file mode 100644 index d0a0c49a1..000000000 --- a/Source/cmGlobalVisualStudio10Win64Generator.cxx +++ /dev/null @@ -1,50 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 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. -============================================================================*/ -#include "cmGlobalVisualStudio10Win64Generator.h" -#include "cmMakefile.h" -#include "cmake.h" - -//---------------------------------------------------------------------------- -cmGlobalVisualStudio10Win64Generator::cmGlobalVisualStudio10Win64Generator() -{ - this->ArchitectureId = "x64"; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio10Win64Generator -::GetDocumentation(cmDocumentationEntry& entry) const -{ - entry.Name = this->GetName(); - entry.Brief = "Generates Visual Studio 10 Win64 project files."; - entry.Full = ""; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio10Win64Generator -::AddPlatformDefinitions(cmMakefile* mf) -{ - this->cmGlobalVisualStudio10Generator::AddPlatformDefinitions(mf); - mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio10Win64Generator -::EnableLanguage(std::vector const& languages, - cmMakefile* mf, bool optional) -{ - if(this->IsExpressEdition() && !this->Find64BitTools(mf)) - { - return; - } - this->cmGlobalVisualStudio10Generator - ::EnableLanguage(languages, mf, optional); -} diff --git a/Source/cmGlobalVisualStudio10Win64Generator.h b/Source/cmGlobalVisualStudio10Win64Generator.h deleted file mode 100644 index 8a2de4c0a..000000000 --- a/Source/cmGlobalVisualStudio10Win64Generator.h +++ /dev/null @@ -1,40 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 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 cmGlobalVisualStudio10Win64Generator_h -#define cmGlobalVisualStudio10Win64Generator_h - -#include "cmGlobalVisualStudio10Generator.h" - -class cmGlobalVisualStudio10Win64Generator : - public cmGlobalVisualStudio10Generator -{ -public: - cmGlobalVisualStudio10Win64Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio10Win64Generator; } - - ///! Get the name for the generator. - virtual const char* GetName() const { - return cmGlobalVisualStudio10Win64Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 10 Win64";} - - virtual const char* GetPlatformName() const {return "x64";} - - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; - - virtual void AddPlatformDefinitions(cmMakefile* mf); - - virtual void EnableLanguage(std::vectorconst& languages, - cmMakefile *, bool optional); -}; -#endif diff --git a/Source/cmGlobalVisualStudio11ARMGenerator.cxx b/Source/cmGlobalVisualStudio11ARMGenerator.cxx deleted file mode 100644 index efd71c65d..000000000 --- a/Source/cmGlobalVisualStudio11ARMGenerator.cxx +++ /dev/null @@ -1,29 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2011 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. -============================================================================*/ -#include "cmGlobalVisualStudio11ARMGenerator.h" -#include "cmMakefile.h" -#include "cmake.h" - -//---------------------------------------------------------------------------- -cmGlobalVisualStudio11ARMGenerator::cmGlobalVisualStudio11ARMGenerator() -{ - this->ArchitectureId = "ARM"; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio11ARMGenerator -::GetDocumentation(cmDocumentationEntry& entry) const -{ - entry.Name = this->GetName(); - entry.Brief = "Generates Visual Studio 11 ARM project files."; - entry.Full = ""; -} diff --git a/Source/cmGlobalVisualStudio11ARMGenerator.h b/Source/cmGlobalVisualStudio11ARMGenerator.h deleted file mode 100644 index 71dbf2e3b..000000000 --- a/Source/cmGlobalVisualStudio11ARMGenerator.h +++ /dev/null @@ -1,35 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2011 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 cmGlobalVisualStudio11ARMGenerator_h -#define cmGlobalVisualStudio11ARMGenerator_h - -#include "cmGlobalVisualStudio11Generator.h" - -class cmGlobalVisualStudio11ARMGenerator : - public cmGlobalVisualStudio11Generator -{ -public: - cmGlobalVisualStudio11ARMGenerator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio11ARMGenerator; } - - ///! Get the name for the generator. - virtual const char* GetName() const { - return cmGlobalVisualStudio11ARMGenerator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 11 ARM";} - - virtual const char* GetPlatformName() const {return "ARM";} - - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; -}; -#endif diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 23a1204bd..ba30e18cb 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -13,8 +13,61 @@ #include "cmLocalVisualStudio10Generator.h" #include "cmMakefile.h" +static const char vs11Win32generatorName[] = "Visual Studio 11"; +static const char vs11Win64generatorName[] = "Visual Studio 11 Win64"; +static const char vs11ARMgeneratorName[] = "Visual Studio 11 ARM"; + +class cmGlobalVisualStudio11Generator::Factory + : public cmGlobalGeneratorFactory +{ +public: + virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { + if(!strcmp(name, vs11Win32generatorName)) + { + return new cmGlobalVisualStudio11Generator( + vs11Win32generatorName, NULL, NULL); + } + if(!strcmp(name, vs11Win64generatorName)) + { + return new cmGlobalVisualStudio11Generator( + vs11Win64generatorName, "x64", "CMAKE_FORCE_WIN64"); + } + if(!strcmp(name, vs11ARMgeneratorName)) + { + return new cmGlobalVisualStudio11Generator( + vs11ARMgeneratorName, "ARM", NULL); + } + return 0; + } + + virtual void GetDocumentation(cmDocumentationEntry& entry) const { + entry.Name = "Visual Studio 11"; + entry.Brief = "Generates Visual Studio 11 project files."; + entry.Full = + "It is possible to append a space followed by the platform name " + "to create project files for a specific target platform. E.g. " + "\"Visual Studio 11 Win64\" will create project files for " + "the x64 processor; \"Visual Studio 11 ARM\" for ARM."; + } + + virtual void GetGenerators(std::vector& names) const { + names.push_back(vs11Win32generatorName); + names.push_back(vs11Win64generatorName); + names.push_back(vs11ARMgeneratorName); } +}; + //---------------------------------------------------------------------------- -cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator() +cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory() +{ + return new Factory; +} + +//---------------------------------------------------------------------------- +cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator( + const char* name, const char* architectureId, + const char* additionalPlatformDefinition) + : cmGlobalVisualStudio10Generator(name, architectureId, + additionalPlatformDefinition) { this->FindMakeProgramFile = "CMakeVS11FindMake.cmake"; std::string vc11Express; @@ -40,12 +93,3 @@ cmLocalGenerator *cmGlobalVisualStudio11Generator::CreateLocalGenerator() lg->SetGlobalGenerator(this); return lg; } - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio11Generator -::GetDocumentation(cmDocumentationEntry& entry) const -{ - entry.Name = this->GetName(); - entry.Brief = "Generates Visual Studio 11 project files."; - entry.Full = ""; -} diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index 56337a4db..8898c5d24 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -20,20 +20,12 @@ class cmGlobalVisualStudio11Generator: public cmGlobalVisualStudio10Generator { public: - cmGlobalVisualStudio11Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio11Generator; } - - ///! Get the name for the generator. - virtual const char* GetName() const { - return cmGlobalVisualStudio11Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 11";} + cmGlobalVisualStudio11Generator(const char* name, + const char* architectureId, const char* additionalPlatformDefinition); + static cmGlobalGeneratorFactory* NewFactory(); virtual void WriteSLNHeader(std::ostream& fout); - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; - ///! create the correct local generator virtual cmLocalGenerator *CreateLocalGenerator(); @@ -41,5 +33,7 @@ public: virtual std::string GetUserMacrosDirectory() { return ""; } protected: virtual const char* GetIDEVersion() { return "11.0"; } +private: + class Factory; }; #endif diff --git a/Source/cmGlobalVisualStudio11Win64Generator.cxx b/Source/cmGlobalVisualStudio11Win64Generator.cxx deleted file mode 100644 index 94e07bf38..000000000 --- a/Source/cmGlobalVisualStudio11Win64Generator.cxx +++ /dev/null @@ -1,37 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2011 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. -============================================================================*/ -#include "cmGlobalVisualStudio11Win64Generator.h" -#include "cmMakefile.h" -#include "cmake.h" - -//---------------------------------------------------------------------------- -cmGlobalVisualStudio11Win64Generator::cmGlobalVisualStudio11Win64Generator() -{ - this->ArchitectureId = "x64"; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio11Win64Generator -::GetDocumentation(cmDocumentationEntry& entry) const -{ - entry.Name = this->GetName(); - entry.Brief = "Generates Visual Studio 11 Win64 project files."; - entry.Full = ""; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio11Win64Generator -::AddPlatformDefinitions(cmMakefile* mf) -{ - this->cmGlobalVisualStudio11Generator::AddPlatformDefinitions(mf); - mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); -} diff --git a/Source/cmGlobalVisualStudio11Win64Generator.h b/Source/cmGlobalVisualStudio11Win64Generator.h deleted file mode 100644 index 9445d156c..000000000 --- a/Source/cmGlobalVisualStudio11Win64Generator.h +++ /dev/null @@ -1,37 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2011 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 cmGlobalVisualStudio11Win64Generator_h -#define cmGlobalVisualStudio11Win64Generator_h - -#include "cmGlobalVisualStudio11Generator.h" - -class cmGlobalVisualStudio11Win64Generator : - public cmGlobalVisualStudio11Generator -{ -public: - cmGlobalVisualStudio11Win64Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio11Win64Generator; } - - ///! Get the name for the generator. - virtual const char* GetName() const { - return cmGlobalVisualStudio11Win64Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 11 Win64";} - - virtual const char* GetPlatformName() const {return "x64";} - - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; - - virtual void AddPlatformDefinitions(cmMakefile* mf); -}; -#endif diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 0ec4850b4..cb15c30f5 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -397,9 +397,9 @@ cmGlobalVisualStudio6Generator::WriteUtilityDepend(cmTarget* target) //---------------------------------------------------------------------------- void cmGlobalVisualStudio6Generator -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalVisualStudio6Generator::GetActualName(); entry.Brief = "Generates Visual Studio 6 project files."; entry.Full = ""; } diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index 259aa8d03..40149e911 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 { @@ -34,7 +36,7 @@ public: static const char* GetActualName() {return "Visual Studio 6";} /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 9f318ece9..db584b804 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -308,9 +308,9 @@ void cmGlobalVisualStudio71Generator::WriteSLNHeader(std::ostream& fout) //---------------------------------------------------------------------------- void cmGlobalVisualStudio71Generator -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalVisualStudio71Generator::GetActualName(); entry.Brief = "Generates Visual Studio .NET 2003 project files."; entry.Full = ""; } diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index f96a7d94b..e9cab0683 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 { @@ -33,7 +34,7 @@ public: static const char* GetActualName() {return "Visual Studio 7 .NET 2003";} /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 6f9c02809..b82a4f46f 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -809,9 +809,9 @@ std::vector *cmGlobalVisualStudio7Generator::GetConfigurations() //---------------------------------------------------------------------------- void cmGlobalVisualStudio7Generator -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalVisualStudio7Generator::GetActualName(); entry.Brief = "Generates Visual Studio .NET 2002 project files."; entry.Full = ""; } diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 8ba1f4462..9eb9687d7 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 { @@ -38,7 +40,7 @@ public: virtual cmLocalGenerator *CreateLocalGenerator(); /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); /** * Try to determine system infomation such as shared library diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index c3ec3f218..855727b7b 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -16,11 +16,74 @@ #include "cmake.h" #include "cmGeneratedFileStream.h" +static const char vs8Win32generatorName[] = "Visual Studio 8 2005"; +static const char vs8Win64generatorName[] = "Visual Studio 8 2005 Win64"; + +class cmGlobalVisualStudio8Generator::Factory + : public cmGlobalGeneratorFactory +{ +public: + virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { + if(!strcmp(name, vs8Win32generatorName)) + { + return new cmGlobalVisualStudio8Generator( + vs8Win32generatorName, NULL, NULL); + } + if(!strcmp(name, vs8Win64generatorName)) + { + return new cmGlobalVisualStudio8Generator( + vs8Win64generatorName, "x64", "CMAKE_FORCE_WIN64"); + } + return 0; + } + + virtual void GetDocumentation(cmDocumentationEntry& entry) const { + entry.Name = "Visual Studio 8 2005"; + entry.Brief = "Generates Visual Studio 8 2005 project files."; + entry.Full = + "It is possible to append a space followed by the platform name " + "to create project files for a specific target platform. E.g. " + "\"Visual Studio 8 2005 Win64\" will create project files for " + "the x64 processor."; + } + + virtual void GetGenerators(std::vector& names) const { + names.push_back(vs8Win32generatorName); + names.push_back(vs8Win64generatorName); } +}; + //---------------------------------------------------------------------------- -cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator() +cmGlobalGeneratorFactory* cmGlobalVisualStudio8Generator::NewFactory() +{ + return new Factory; +} + +//---------------------------------------------------------------------------- +cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator( + const char* name, const char* architectureId, + const char* additionalPlatformDefinition) { this->FindMakeProgramFile = "CMakeVS8FindMake.cmake"; this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms"; + this->Name = name; + if (architectureId) + { + this->ArchitectureId = architectureId; + } + if (additionalPlatformDefinition) + { + this->AdditionalPlatformDefinition = additionalPlatformDefinition; + } +} + +//---------------------------------------------------------------------------- +const char* cmGlobalVisualStudio8Generator::GetPlatformName() const +{ + if (!strcmp(this->ArchitectureId, "X86")) + { + return "Win32"; + } + return this->ArchitectureId; } //---------------------------------------------------------------------------- @@ -45,9 +108,9 @@ void cmGlobalVisualStudio8Generator::WriteSLNHeader(std::ostream& fout) //---------------------------------------------------------------------------- void cmGlobalVisualStudio8Generator -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalVisualStudio8Generator::GetActualName(); entry.Brief = "Generates Visual Studio 8 2005 project files."; entry.Full = ""; } diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index 2c9424d9c..f68bb9ee1 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -23,19 +23,17 @@ class cmGlobalVisualStudio8Generator : public cmGlobalVisualStudio71Generator { public: - cmGlobalVisualStudio8Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio8Generator; } + cmGlobalVisualStudio8Generator(const char* name, + const char* architectureId, const char* additionalPlatformDefinition); + static cmGlobalGeneratorFactory* NewFactory(); ///! Get the name for the generator. - virtual const char* GetName() const { - return cmGlobalVisualStudio8Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 8 2005";} + virtual const char* GetName() const {return this->Name;} - virtual const char* GetPlatformName() const {return "Win32";} + const char* GetPlatformName() const; /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); @@ -81,5 +79,10 @@ protected: virtual bool ComputeTargetDepends(); virtual void WriteProjectDepends(std::ostream& fout, const char* name, const char* path, cmTarget &t); + + const char* Name; + +private: + class Factory; }; #endif diff --git a/Source/cmGlobalVisualStudio8Win64Generator.cxx b/Source/cmGlobalVisualStudio8Win64Generator.cxx deleted file mode 100644 index 4cbc2750d..000000000 --- a/Source/cmGlobalVisualStudio8Win64Generator.cxx +++ /dev/null @@ -1,40 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 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. -============================================================================*/ -#include "windows.h" // this must be first to define GetCurrentDirectory -#include "cmGlobalVisualStudio8Win64Generator.h" -#include "cmLocalVisualStudio7Generator.h" -#include "cmMakefile.h" -#include "cmake.h" - - - -cmGlobalVisualStudio8Win64Generator::cmGlobalVisualStudio8Win64Generator() -{ - this->ArchitectureId = "x64"; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio8Win64Generator -::GetDocumentation(cmDocumentationEntry& entry) const -{ - entry.Name = this->GetName(); - entry.Brief = "Generates Visual Studio 8 2005 Win64 project files."; - entry.Full = ""; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio8Win64Generator -::AddPlatformDefinitions(cmMakefile* mf) -{ - this->cmGlobalVisualStudio8Generator::AddPlatformDefinitions(mf); - mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); -} diff --git a/Source/cmGlobalVisualStudio8Win64Generator.h b/Source/cmGlobalVisualStudio8Win64Generator.h deleted file mode 100644 index 12f80125a..000000000 --- a/Source/cmGlobalVisualStudio8Win64Generator.h +++ /dev/null @@ -1,47 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 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 cmGlobalVisualStudio8Win64Generator_h -#define cmGlobalVisualStudio8Win64Generator_h - -#include "cmGlobalVisualStudio8Generator.h" - - -/** \class cmGlobalVisualStudio8Win64Generator - * \brief Write a Unix makefiles. - * - * cmGlobalVisualStudio8Win64Generator manages UNIX build process for a tree - */ -class cmGlobalVisualStudio8Win64Generator : - public cmGlobalVisualStudio8Generator -{ -public: - cmGlobalVisualStudio8Win64Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio8Win64Generator; } - - ///! Get the name for the generator. - virtual const char* GetName() const { - return cmGlobalVisualStudio8Win64Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 8 2005 Win64";} - - virtual const char* GetPlatformName() const {return "x64";} - - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; - - /** - * Try to determine system infomation such as shared library - * extension, pthreads, byte order etc. - */ - virtual void AddPlatformDefinitions(cmMakefile *); -}; -#endif diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index 70af50d7b..87599efd3 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -15,9 +15,61 @@ #include "cmMakefile.h" #include "cmake.h" +static const char vs9Win32generatorName[] = "Visual Studio 9 2008"; +static const char vs9Win64generatorName[] = "Visual Studio 8 2005 Win64"; +static const char vs9IA64generatorName[] = "Visual Studio 9 2008 IA64"; +class cmGlobalVisualStudio9Generator::Factory + : public cmGlobalGeneratorFactory +{ +public: + virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { + if(!strcmp(name, vs9Win32generatorName)) + { + return new cmGlobalVisualStudio9Generator( + vs9Win32generatorName, NULL, NULL); + } + if(!strcmp(name, vs9Win64generatorName)) + { + return new cmGlobalVisualStudio9Generator( + vs9Win64generatorName, "x64", "CMAKE_FORCE_WIN64"); + } + if(!strcmp(name, vs9IA64generatorName)) + { + return new cmGlobalVisualStudio9Generator( + vs9IA64generatorName, "Itanium", "CMAKE_FORCE_IA64"); + } + return 0; + } -cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator() + virtual void GetDocumentation(cmDocumentationEntry& entry) const { + entry.Name = "Visual Studio 9 2008"; + entry.Brief = "Generates Visual Studio 9 2008 project files."; + entry.Full = + "It is possible to append a space followed by the platform name " + "to create project files for a specific target platform. E.g. " + "\"Visual Studio 9 2008 Win64\" will create project files for " + "the x64 processor; \"Visual Studio 9 2008 IA64\" for Itanium."; + } + + virtual void GetGenerators(std::vector& names) const { + names.push_back(vs9Win32generatorName); + names.push_back(vs9Win64generatorName); + names.push_back(vs9IA64generatorName); } +}; + +//---------------------------------------------------------------------------- +cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory() +{ + return new Factory; +} + +//---------------------------------------------------------------------------- +cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator( + const char* name, const char* architectureId, + const char* additionalPlatformDefinition) + : cmGlobalVisualStudio8Generator(name, architectureId, + additionalPlatformDefinition) { this->FindMakeProgramFile = "CMakeVS9FindMake.cmake"; } @@ -40,15 +92,6 @@ cmLocalGenerator *cmGlobalVisualStudio9Generator::CreateLocalGenerator() return lg; } -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio9Generator -::GetDocumentation(cmDocumentationEntry& entry) const -{ - entry.Name = this->GetName(); - entry.Brief = "Generates Visual Studio 9 2008 project files."; - entry.Full = ""; -} - //---------------------------------------------------------------------------- void cmGlobalVisualStudio9Generator ::EnableLanguage(std::vectorconst & lang, diff --git a/Source/cmGlobalVisualStudio9Generator.h b/Source/cmGlobalVisualStudio9Generator.h index 0b0d1437f..f05d3773d 100644 --- a/Source/cmGlobalVisualStudio9Generator.h +++ b/Source/cmGlobalVisualStudio9Generator.h @@ -24,17 +24,9 @@ class cmGlobalVisualStudio9Generator : public cmGlobalVisualStudio8Generator { public: - cmGlobalVisualStudio9Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio9Generator; } - - ///! Get the name for the generator. - virtual const char* GetName() const { - return cmGlobalVisualStudio9Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 9 2008";} - - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + cmGlobalVisualStudio9Generator(const char* name, + const char* architectureId, const char* additionalPlatformDefinition); + static cmGlobalGeneratorFactory* NewFactory(); ///! create the correct local generator virtual cmLocalGenerator *CreateLocalGenerator(); @@ -61,5 +53,7 @@ public: virtual std::string GetUserMacrosRegKeyBase(); protected: virtual const char* GetIDEVersion() { return "9.0"; } +private: + class Factory; }; #endif diff --git a/Source/cmGlobalVisualStudio9IA64Generator.cxx b/Source/cmGlobalVisualStudio9IA64Generator.cxx deleted file mode 100644 index 38dbfacc4..000000000 --- a/Source/cmGlobalVisualStudio9IA64Generator.cxx +++ /dev/null @@ -1,37 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 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. -============================================================================*/ -#include "cmGlobalVisualStudio9IA64Generator.h" -#include "cmLocalVisualStudio7Generator.h" -#include "cmMakefile.h" - - -cmGlobalVisualStudio9IA64Generator::cmGlobalVisualStudio9IA64Generator() -{ - this->ArchitectureId = "Itanium"; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio9IA64Generator -::GetDocumentation(cmDocumentationEntry& entry) const -{ - entry.Name = this->GetName(); - entry.Brief = "Generates Visual Studio 9 2008 Itanium project files."; - entry.Full = ""; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio9IA64Generator -::AddPlatformDefinitions(cmMakefile* mf) -{ - cmGlobalVisualStudio9Generator::AddPlatformDefinitions(mf); - mf->AddDefinition("CMAKE_FORCE_IA64", "TRUE"); -} diff --git a/Source/cmGlobalVisualStudio9IA64Generator.h b/Source/cmGlobalVisualStudio9IA64Generator.h deleted file mode 100644 index 989b0d1af..000000000 --- a/Source/cmGlobalVisualStudio9IA64Generator.h +++ /dev/null @@ -1,47 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 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 cmGlobalVisualStudio9IA64Generator_h -#define cmGlobalVisualStudio9IA64Generator_h - -#include "cmGlobalVisualStudio9Generator.h" - - -/** \class cmGlobalVisualStudio8IA64Generator - * \brief Write a Unix makefiles. - * - * cmGlobalVisualStudio8IA64Generator manages UNIX build process for a tree - */ -class cmGlobalVisualStudio9IA64Generator : - public cmGlobalVisualStudio9Generator -{ -public: - cmGlobalVisualStudio9IA64Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio9IA64Generator; } - - ///! Get the name for the generator. - virtual const char* GetName() const { - return cmGlobalVisualStudio9IA64Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 9 2008 IA64";} - - virtual const char* GetPlatformName() const {return "Itanium";} - - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; - - /** - * Try to determine system infomation such as shared library - * extension, pthreads, byte order etc. - */ - virtual void AddPlatformDefinitions(cmMakefile *); -}; -#endif diff --git a/Source/cmGlobalVisualStudio9Win64Generator.cxx b/Source/cmGlobalVisualStudio9Win64Generator.cxx deleted file mode 100644 index 4d8a6463b..000000000 --- a/Source/cmGlobalVisualStudio9Win64Generator.cxx +++ /dev/null @@ -1,37 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 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. -============================================================================*/ -#include "cmGlobalVisualStudio9Win64Generator.h" -#include "cmLocalVisualStudio7Generator.h" -#include "cmMakefile.h" - - -cmGlobalVisualStudio9Win64Generator::cmGlobalVisualStudio9Win64Generator() -{ - this->ArchitectureId = "x64"; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio9Win64Generator -::GetDocumentation(cmDocumentationEntry& entry) const -{ - entry.Name = this->GetName(); - entry.Brief = "Generates Visual Studio 9 2008 Win64 project files."; - entry.Full = ""; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio9Win64Generator -::AddPlatformDefinitions(cmMakefile* mf) -{ - cmGlobalVisualStudio9Generator::AddPlatformDefinitions(mf); - mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); -} diff --git a/Source/cmGlobalVisualStudio9Win64Generator.h b/Source/cmGlobalVisualStudio9Win64Generator.h deleted file mode 100644 index 7c20cf4e2..000000000 --- a/Source/cmGlobalVisualStudio9Win64Generator.h +++ /dev/null @@ -1,47 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 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 cmGlobalVisualStudio9Win64Generator_h -#define cmGlobalVisualStudio9Win64Generator_h - -#include "cmGlobalVisualStudio9Generator.h" - - -/** \class cmGlobalVisualStudio8Win64Generator - * \brief Write a Unix makefiles. - * - * cmGlobalVisualStudio8Win64Generator manages UNIX build process for a tree - */ -class cmGlobalVisualStudio9Win64Generator : - public cmGlobalVisualStudio9Generator -{ -public: - cmGlobalVisualStudio9Win64Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio9Win64Generator; } - - ///! Get the name for the generator. - virtual const char* GetName() const { - return cmGlobalVisualStudio9Win64Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 9 2008 Win64";} - - virtual const char* GetPlatformName() const {return "x64";} - - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; - - /** - * Try to determine system infomation such as shared library - * extension, pthreads, byte order etc. - */ - virtual void AddPlatformDefinitions(cmMakefile *); -}; -#endif diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index ea6757dea..a51735154 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -22,6 +22,7 @@ cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator() { this->ArchitectureId = "X86"; + this->AdditionalPlatformDefinition = NULL; } //---------------------------------------------------------------------------- @@ -493,6 +494,11 @@ void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf) { mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", this->ArchitectureId); mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", this->ArchitectureId); + + if(this->AdditionalPlatformDefinition) + { + mf->AddDefinition(this->AdditionalPlatformDefinition, "TRUE"); + } } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index cebf7d741..7258e313e 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -99,6 +99,7 @@ protected: typedef std::map UtilityDependsMap; UtilityDependsMap UtilityDepends; const char* ArchitectureId; + const char* AdditionalPlatformDefinition; private: void ComputeTargetObjects(cmGeneratorTarget* gt) const; diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx index 45b171ff2..e3cebc4ac 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.cxx +++ b/Source/cmGlobalWatcomWMakeGenerator.cxx @@ -58,9 +58,9 @@ cmLocalGenerator *cmGlobalWatcomWMakeGenerator::CreateLocalGenerator() //---------------------------------------------------------------------------- void cmGlobalWatcomWMakeGenerator -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalWatcomWMakeGenerator::GetActualName(); entry.Brief = "Generates Watcom WMake makefiles."; entry.Full = ""; } diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h index ee16eaebc..23e60a1fc 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.h +++ b/Source/cmGlobalWatcomWMakeGenerator.h @@ -23,14 +23,16 @@ 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();} static const char* GetActualName() {return "Watcom WMake";} /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 5b2ddd8b4..4ef2f5736 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,18 @@ public: } }; +class cmGlobalXCodeGenerator::Factory : public cmGlobalGeneratorFactory +{ +public: + virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const; + + virtual void GetDocumentation(cmDocumentationEntry& entry) const { + cmGlobalXCodeGenerator::GetDocumentation(entry); } + + virtual void GetGenerators(std::vector& names) const { + names.push_back(cmGlobalXCodeGenerator::GetActualName()); } +}; + //---------------------------------------------------------------------------- cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(std::string const& version) { @@ -132,8 +145,17 @@ cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(std::string const& version) } //---------------------------------------------------------------------------- -cmGlobalGenerator* cmGlobalXCodeGenerator::New() +cmGlobalGeneratorFactory* cmGlobalXCodeGenerator::NewFactory() { + return new Factory; +} + +//---------------------------------------------------------------------------- +cmGlobalGenerator* cmGlobalXCodeGenerator::Factory +::CreateGlobalGenerator(const char* name) const +{ + if (strcmp(name, GetActualName())) + return 0; #if defined(CMAKE_BUILD_WITH_CMAKE) cmXcodeVersionParser parser; std::string versionFile; @@ -3474,9 +3496,8 @@ const char* cmGlobalXCodeGenerator::GetCMakeCFGIntDir() const //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::GetDocumentation(cmDocumentationEntry& entry) - const { - entry.Name = this->GetName(); + entry.Name = cmGlobalXCodeGenerator::GetActualName(); entry.Brief = "Generate Xcode project files."; entry.Full = ""; } diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index afa1ca22e..c98652f5d 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 { @@ -37,7 +38,7 @@ public: static const char* GetActualName() {return "Xcode";} /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); @@ -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..1ec88fb86 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -63,15 +63,8 @@ # include "cmGlobalVisualStudio71Generator.h" # include "cmGlobalVisualStudio8Generator.h" # include "cmGlobalVisualStudio9Generator.h" -# include "cmGlobalVisualStudio9IA64Generator.h" -# include "cmGlobalVisualStudio9Win64Generator.h" # include "cmGlobalVisualStudio10Generator.h" -# include "cmGlobalVisualStudio10IA64Generator.h" -# include "cmGlobalVisualStudio10Win64Generator.h" # include "cmGlobalVisualStudio11Generator.h" -# include "cmGlobalVisualStudio11Win64Generator.h" -# include "cmGlobalVisualStudio11ARMGenerator.h" -# include "cmGlobalVisualStudio8Win64Generator.h" # include "cmGlobalBorlandMakefileGenerator.h" # include "cmGlobalNMakeMakefileGenerator.h" # include "cmGlobalJOMMakefileGenerator.h" @@ -222,6 +215,11 @@ cmake::~cmake() { delete (*j).second; } + for(RegisteredGeneratorsVector::iterator j = this->Generators.begin(); + j != this->Generators.end(); ++j) + { + delete *j; + } #ifdef CMAKE_BUILD_WITH_CMAKE delete this->VariableWatch; #endif @@ -1869,10 +1867,10 @@ void cmake::AddDefaultExtraGenerators() //---------------------------------------------------------------------------- void cmake::GetRegisteredGenerators(std::vector& names) { - for(RegisteredGeneratorsMap::const_iterator i = this->Generators.begin(); + for(RegisteredGeneratorsVector::const_iterator i = this->Generators.begin(); i != this->Generators.end(); ++i) { - names.push_back(i->first); + (*i)->GetGenerators(names); } for(RegisteredExtraGeneratorsMap::const_iterator i = this->ExtraGenerators.begin(); @@ -1884,29 +1882,36 @@ void cmake::GetRegisteredGenerators(std::vector& names) cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name) { - cmGlobalGenerator* generator = 0; cmExternalMakefileProjectGenerator* extraGenerator = 0; - RegisteredGeneratorsMap::const_iterator genIt = this->Generators.find(name); - if(genIt == this->Generators.end()) + RegisteredExtraGeneratorsMap::const_iterator extraGenIt = + this->ExtraGenerators.find(name); + if (extraGenIt != this->ExtraGenerators.end()) { - RegisteredExtraGeneratorsMap::const_iterator extraGenIt = - this->ExtraGenerators.find(name); - if (extraGenIt == this->ExtraGenerators.end()) - { - return 0; - } extraGenerator = (extraGenIt->second)(); - genIt=this->Generators.find(extraGenerator->GetGlobalGeneratorName(name)); - if(genIt == this->Generators.end()) - { - delete extraGenerator; - return 0; - } - } + name = extraGenerator->GetGlobalGeneratorName(name); + } + + cmGlobalGenerator* generator = 0; + for (RegisteredGeneratorsVector::const_iterator i = + this->Generators.begin(); i != this->Generators.end(); ++i) + { + generator = (*i)->CreateGlobalGenerator(name); + if (generator) + { + break; + } + } + + if (generator) + { + generator->SetCMakeInstance(this); + generator->SetExternalMakefileProjectGenerator(extraGenerator); + } + else + { + delete extraGenerator; + } - generator = (genIt->second)(); - generator->SetCMakeInstance(this); - generator->SetExternalMakefileProjectGenerator(extraGenerator); return generator; } @@ -2570,55 +2575,41 @@ void cmake::AddDefaultGenerators() { #if defined(_WIN32) && !defined(__CYGWIN__) # if !defined(CMAKE_BOOT_MINGW) - this->Generators[cmGlobalVisualStudio6Generator::GetActualName()] = - &cmGlobalVisualStudio6Generator::New; - this->Generators[cmGlobalVisualStudio7Generator::GetActualName()] = - &cmGlobalVisualStudio7Generator::New; - this->Generators[cmGlobalVisualStudio10Generator::GetActualName()] = - &cmGlobalVisualStudio10Generator::New; - this->Generators[cmGlobalVisualStudio10IA64Generator::GetActualName()] = - &cmGlobalVisualStudio10IA64Generator::New; - this->Generators[cmGlobalVisualStudio10Win64Generator::GetActualName()] = - &cmGlobalVisualStudio10Win64Generator::New; - this->Generators[cmGlobalVisualStudio11Generator::GetActualName()] = - &cmGlobalVisualStudio11Generator::New; - this->Generators[cmGlobalVisualStudio11Win64Generator::GetActualName()] = - &cmGlobalVisualStudio11Win64Generator::New; - this->Generators[cmGlobalVisualStudio11ARMGenerator::GetActualName()] = - &cmGlobalVisualStudio11ARMGenerator::New; - this->Generators[cmGlobalVisualStudio71Generator::GetActualName()] = - &cmGlobalVisualStudio71Generator::New; - this->Generators[cmGlobalVisualStudio8Generator::GetActualName()] = - &cmGlobalVisualStudio8Generator::New; - this->Generators[cmGlobalVisualStudio9Generator::GetActualName()] = - &cmGlobalVisualStudio9Generator::New; - this->Generators[cmGlobalVisualStudio9IA64Generator::GetActualName()] = - &cmGlobalVisualStudio9IA64Generator::New; - this->Generators[cmGlobalVisualStudio9Win64Generator::GetActualName()] = - &cmGlobalVisualStudio9Win64Generator::New; - this->Generators[cmGlobalVisualStudio8Win64Generator::GetActualName()] = - &cmGlobalVisualStudio8Win64Generator::New; - this->Generators[cmGlobalBorlandMakefileGenerator::GetActualName()] = - &cmGlobalBorlandMakefileGenerator::New; - this->Generators[cmGlobalNMakeMakefileGenerator::GetActualName()] = - &cmGlobalNMakeMakefileGenerator::New; - this->Generators[cmGlobalJOMMakefileGenerator::GetActualName()] = - &cmGlobalJOMMakefileGenerator::New; - this->Generators[cmGlobalWatcomWMakeGenerator::GetActualName()] = - &cmGlobalWatcomWMakeGenerator::New; + this->Generators.push_back( + cmGlobalVisualStudio6Generator::NewFactory()); + this->Generators.push_back( + cmGlobalVisualStudio7Generator::NewFactory()); + this->Generators.push_back( + cmGlobalVisualStudio10Generator::NewFactory()); + this->Generators.push_back( + cmGlobalVisualStudio11Generator::NewFactory()); + this->Generators.push_back( + cmGlobalVisualStudio71Generator::NewFactory()); + this->Generators.push_back( + cmGlobalVisualStudio8Generator::NewFactory()); + this->Generators.push_back( + cmGlobalVisualStudio9Generator::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::New; - this->Generators[cmGlobalMinGWMakefileGenerator::GetActualName()] = - &cmGlobalMinGWMakefileGenerator::New; + this->Generators.push_back( + cmGlobalMSYSMakefileGenerator::NewFactory()); + this->Generators.push_back( + cmGlobalMinGWMakefileGenerator::NewFactory()); #endif - this->Generators[cmGlobalUnixMakefileGenerator3::GetActualName()] = - &cmGlobalUnixMakefileGenerator3::New; - this->Generators[cmGlobalNinjaGenerator::GetActualName()] = - &cmGlobalNinjaGenerator::New; + this->Generators.push_back( + cmGlobalUnixMakefileGenerator3::NewFactory()); + this->Generators.push_back( + cmGlobalNinjaGenerator::NewFactory()); #ifdef CMAKE_USE_XCODE - this->Generators[cmGlobalXCodeGenerator::GetActualName()] = - &cmGlobalXCodeGenerator::New; + this->Generators.push_back( + cmGlobalXCodeGenerator::NewFactory()); #endif } @@ -2712,17 +2703,15 @@ void cmake::GetPropertiesDocumentation(std::map& 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; - cmGlobalGenerator* generator = (i->second)(); - generator->GetDocumentation(e); - delete generator; + (*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 94c6f128f..79e05ca0c 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,12 +397,9 @@ protected: cmExternalMakefileProjectGenerator* (*CreateExtraGeneratorFunctionType)(); typedef std::map RegisteredExtraGeneratorsMap; - - typedef cmGlobalGenerator* (*CreateGeneratorFunctionType)(); - typedef std::map RegisteredGeneratorsMap; + typedef std::vector RegisteredGeneratorsVector; RegisteredCommandsMap Commands; - RegisteredGeneratorsMap Generators; + RegisteredGeneratorsVector Generators; RegisteredExtraGeneratorsMap ExtraGenerators; void AddDefaultCommands(); void AddDefaultGenerators();