diff --git a/Help/generator/Visual Studio 10 2010.rst b/Help/generator/Visual Studio 10 2010.rst new file mode 100644 index 000000000..000677a94 --- /dev/null +++ b/Help/generator/Visual Studio 10 2010.rst @@ -0,0 +1,12 @@ +Visual Studio 10 2010 +--------------------- + +Generates Visual Studio 10 (VS 2010) project files. + +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 2010 Win64" will create project files for the +x64 processor; "Visual Studio 10 2010 IA64" for Itanium. + +For compatibility with CMake versions prior to 3.0, one may specify this +generator using the name "Visual Studio 10" without the year component. diff --git a/Help/generator/Visual Studio 10.rst b/Help/generator/Visual Studio 10.rst deleted file mode 100644 index 9ea797064..000000000 --- a/Help/generator/Visual Studio 10.rst +++ /dev/null @@ -1,9 +0,0 @@ -Visual Studio 10 ----------------- - -Generates Visual Studio 10 (2010) project files. - -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. diff --git a/Help/generator/Visual Studio 11 2012.rst b/Help/generator/Visual Studio 11 2012.rst new file mode 100644 index 000000000..42f6f9160 --- /dev/null +++ b/Help/generator/Visual Studio 11 2012.rst @@ -0,0 +1,12 @@ +Visual Studio 11 2012 +--------------------- + +Generates Visual Studio 11 (VS 2012) project files. + +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 2012 Win64" will create project files for the +x64 processor; "Visual Studio 11 2012 ARM" for ARM. + +For compatibility with CMake versions prior to 3.0, one may specify this +generator using the name "Visual Studio 11" without the year component. diff --git a/Help/generator/Visual Studio 11.rst b/Help/generator/Visual Studio 11.rst deleted file mode 100644 index 4115c8d96..000000000 --- a/Help/generator/Visual Studio 11.rst +++ /dev/null @@ -1,9 +0,0 @@ -Visual Studio 11 ----------------- - -Generates Visual Studio 11 (2012) project files. - -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. diff --git a/Help/generator/Visual Studio 12 2013.rst b/Help/generator/Visual Studio 12 2013.rst new file mode 100644 index 000000000..d2f491202 --- /dev/null +++ b/Help/generator/Visual Studio 12 2013.rst @@ -0,0 +1,12 @@ +Visual Studio 12 2013 +--------------------- + +Generates Visual Studio 12 (VS 2013) project files. + +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 12 2013 Win64" will create project files for the +x64 processor; "Visual Studio 12 2013 ARM" for ARM. + +For compatibility with CMake versions prior to 3.0, one may specify this +generator using the name "Visual Studio 12" without the year component. diff --git a/Help/generator/Visual Studio 12.rst b/Help/generator/Visual Studio 12.rst deleted file mode 100644 index 51bcab71f..000000000 --- a/Help/generator/Visual Studio 12.rst +++ /dev/null @@ -1,9 +0,0 @@ -Visual Studio 12 ----------------- - -Generates Visual Studio 12 (2013) project files. - -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 12 Win64" will create project files for the x64 processor; -"Visual Studio 12 ARM" for ARM. diff --git a/Help/manual/cmake-generators.7.rst b/Help/manual/cmake-generators.7.rst index 4f0d9c3b8..a290d1aad 100644 --- a/Help/manual/cmake-generators.7.rst +++ b/Help/manual/cmake-generators.7.rst @@ -32,9 +32,9 @@ All Generators /generator/Sublime Text 2 - NMake Makefiles /generator/Sublime Text 2 - Unix Makefiles /generator/Unix Makefiles - /generator/Visual Studio 10 - /generator/Visual Studio 11 - /generator/Visual Studio 12 + /generator/Visual Studio 10 2010 + /generator/Visual Studio 11 2012 + /generator/Visual Studio 12 2013 /generator/Visual Studio 6 /generator/Visual Studio 7 .NET 2003 /generator/Visual Studio 7 diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index df434b34c..4d6e10f0e 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -52,6 +52,10 @@ public: ///! Get the name for this generator virtual const char *GetName() const { return "Generic"; }; + /** Check whether the given name matches the current generator. */ + virtual bool MatchesGeneratorName(const char* name) const + { return strcmp(this->GetName(), name) == 0; } + /** Set the generator-specific toolset name. Returns true if toolset is supported and false otherwise. */ virtual bool SetGeneratorToolset(std::string const& ts); diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 07ccc33c0..5e29fd762 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -18,42 +18,65 @@ #include "cmVisualStudioSlnParser.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"; +static const char vs10generatorName[] = "Visual Studio 10 2010"; + +// Map generator name without year to name with year. +static const char* cmVS10GenName(const char* name, std::string& genName) +{ + if(strncmp(name, vs10generatorName, sizeof(vs10generatorName)-6) != 0) + { + return 0; + } + const char* p = name + sizeof(vs10generatorName) - 6; + if(strncmp(p, " 2010", 5) == 0) + { + p += 5; + } + genName = std::string(vs10generatorName) + p; + return p; +} class cmGlobalVisualStudio10Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { - if(!strcmp(name, vs10Win32generatorName)) + virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const + { + std::string genName; + const char* p = cmVS10GenName(name, genName); + if(!p) + { return 0; } + name = genName.c_str(); + if(strcmp(p, "") == 0) { return new cmGlobalVisualStudio10Generator( name, NULL, NULL); } - if(!strcmp(name, vs10Win64generatorName)) + if(strcmp(p, " Win64") == 0) { return new cmGlobalVisualStudio10Generator( name, "x64", "CMAKE_FORCE_WIN64"); } - if(!strcmp(name, vs10IA64generatorName)) + if(strcmp(p, " IA64") == 0) { return new cmGlobalVisualStudio10Generator( name, "Itanium", "CMAKE_FORCE_IA64"); } return 0; - } + } - virtual void GetDocumentation(cmDocumentationEntry& entry) const { - entry.Name = "Visual Studio 10"; - entry.Brief = "Generates Visual Studio 10 (2010) project files."; - } + virtual void GetDocumentation(cmDocumentationEntry& entry) const + { + entry.Name = vs10generatorName; + entry.Brief = "Generates Visual Studio 10 (VS 2010) project files."; + } - virtual void GetGenerators(std::vector& names) const { - names.push_back(vs10Win32generatorName); - names.push_back(vs10Win64generatorName); - names.push_back(vs10IA64generatorName); } + virtual void GetGenerators(std::vector& names) const + { + names.push_back(vs10generatorName); + names.push_back(vs10generatorName + std::string(" IA64")); + names.push_back(vs10generatorName + std::string(" Win64")); + } }; //---------------------------------------------------------------------------- @@ -77,6 +100,18 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( this->MasmEnabled = false; } +//---------------------------------------------------------------------------- +bool +cmGlobalVisualStudio10Generator::MatchesGeneratorName(const char* name) const +{ + std::string genName; + if(cmVS10GenName(name, genName)) + { + return genName == this->GetName(); + } + return false; +} + //---------------------------------------------------------------------------- bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(std::string const& ts) diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 31e122efe..e9e7cb11d 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -28,6 +28,8 @@ public: const char* platformName, const char* additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); + virtual bool MatchesGeneratorName(const char* name) const; + virtual bool SetGeneratorToolset(std::string const& ts); virtual std::string diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 41a349e1b..d968c6de7 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -13,42 +13,54 @@ #include "cmLocalVisualStudio10Generator.h" #include "cmMakefile.h" -static const char vs11generatorName[] = "Visual Studio 11"; +static const char vs11generatorName[] = "Visual Studio 11 2012"; + +// Map generator name without year to name with year. +static const char* cmVS11GenName(const char* name, std::string& genName) +{ + if(strncmp(name, vs11generatorName, sizeof(vs11generatorName)-6) != 0) + { + return 0; + } + const char* p = name + sizeof(vs11generatorName) - 6; + if(strncmp(p, " 2012", 5) == 0) + { + p += 5; + } + genName = std::string(vs11generatorName) + p; + return p; +} class cmGlobalVisualStudio11Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { - if(strstr(name, vs11generatorName) != name) - { - return 0; - } - - const char* p = name + sizeof(vs11generatorName) - 1; - if(p[0] == '\0') + virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const + { + std::string genName; + const char* p = cmVS11GenName(name, genName); + if(!p) + { return 0; } + name = genName.c_str(); + if(strcmp(p, "") == 0) { return new cmGlobalVisualStudio11Generator( name, NULL, NULL); } - - if(p[0] != ' ') + if(strcmp(p, " Win64") == 0) { - return 0; + return new cmGlobalVisualStudio11Generator( + name, "x64", "CMAKE_FORCE_WIN64"); } - - ++p; - - if(!strcmp(p, "ARM")) + if(strcmp(p, " ARM") == 0) { return new cmGlobalVisualStudio11Generator( name, "ARM", NULL); } - if(!strcmp(p, "Win64")) + if(*p++ != ' ') { - return new cmGlobalVisualStudio11Generator( - name, "x64", "CMAKE_FORCE_WIN64"); + return 0; } std::set installedSDKs = @@ -63,14 +75,16 @@ public: new cmGlobalVisualStudio11Generator(name, p, NULL); ret->WindowsCEVersion = "8.00"; return ret; - } + } - virtual void GetDocumentation(cmDocumentationEntry& entry) const { - entry.Name = "Visual Studio 11"; - entry.Brief = "Generates Visual Studio 11 (2012) project files."; - } + virtual void GetDocumentation(cmDocumentationEntry& entry) const + { + entry.Name = vs11generatorName; + entry.Brief = "Generates Visual Studio 11 (VS 2012) project files."; + } - virtual void GetGenerators(std::vector& names) const { + virtual void GetGenerators(std::vector& names) const + { names.push_back(vs11generatorName); names.push_back(vs11generatorName + std::string(" ARM")); names.push_back(vs11generatorName + std::string(" Win64")); @@ -80,9 +94,9 @@ public: for(std::set::const_iterator i = installedSDKs.begin(); i != installedSDKs.end(); ++i) { - names.push_back("Visual Studio 11 " + *i); + names.push_back(std::string(vs11generatorName) + " " + *i); } - } + } }; //---------------------------------------------------------------------------- @@ -106,6 +120,18 @@ cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator( this->PlatformToolset = "v110"; } +//---------------------------------------------------------------------------- +bool +cmGlobalVisualStudio11Generator::MatchesGeneratorName(const char* name) const +{ + std::string genName; + if(cmVS11GenName(name, genName)) + { + return genName == this->GetName(); + } + return false; +} + //---------------------------------------------------------------------------- void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout) { diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index 7cc7e69d9..7ef77e7cc 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -24,6 +24,8 @@ public: const char* platformName, const char* additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); + virtual bool MatchesGeneratorName(const char* name) const; + virtual void WriteSLNHeader(std::ostream& fout); ///! create the correct local generator diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index c2cdc0bdf..f3806df1b 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -13,42 +13,65 @@ #include "cmLocalVisualStudio10Generator.h" #include "cmMakefile.h" -static const char vs12Win32generatorName[] = "Visual Studio 12"; -static const char vs12Win64generatorName[] = "Visual Studio 12 Win64"; -static const char vs12ARMgeneratorName[] = "Visual Studio 12 ARM"; +static const char vs12generatorName[] = "Visual Studio 12 2013"; + +// Map generator name without year to name with year. +static const char* cmVS12GenName(const char* name, std::string& genName) +{ + if(strncmp(name, vs12generatorName, sizeof(vs12generatorName)-6) != 0) + { + return 0; + } + const char* p = name + sizeof(vs12generatorName) - 6; + if(strncmp(p, " 2013", 5) == 0) + { + p += 5; + } + genName = std::string(vs12generatorName) + p; + return p; +} class cmGlobalVisualStudio12Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { - if(!strcmp(name, vs12Win32generatorName)) + virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const + { + std::string genName; + const char* p = cmVS12GenName(name, genName); + if(!p) + { return 0; } + name = genName.c_str(); + if(strcmp(p, "") == 0) { return new cmGlobalVisualStudio12Generator( name, NULL, NULL); } - if(!strcmp(name, vs12Win64generatorName)) + if(strcmp(p, " Win64") == 0) { return new cmGlobalVisualStudio12Generator( name, "x64", "CMAKE_FORCE_WIN64"); } - if(!strcmp(name, vs12ARMgeneratorName)) + if(strcmp(p, " ARM") == 0) { return new cmGlobalVisualStudio12Generator( name, "ARM", NULL); } return 0; - } + } - virtual void GetDocumentation(cmDocumentationEntry& entry) const { - entry.Name = "Visual Studio 12"; - entry.Brief = "Generates Visual Studio 12 (2013) project files."; - } + virtual void GetDocumentation(cmDocumentationEntry& entry) const + { + entry.Name = vs12generatorName; + entry.Brief = "Generates Visual Studio 12 (VS 2013) project files."; + } - virtual void GetGenerators(std::vector& names) const { - names.push_back(vs12Win32generatorName); - names.push_back(vs12Win64generatorName); - names.push_back(vs12ARMgeneratorName); } + virtual void GetGenerators(std::vector& names) const + { + names.push_back(vs12generatorName); + names.push_back(vs12generatorName + std::string(" ARM")); + names.push_back(vs12generatorName + std::string(" Win64")); + } }; //---------------------------------------------------------------------------- @@ -72,6 +95,18 @@ cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator( this->PlatformToolset = "v120"; } +//---------------------------------------------------------------------------- +bool +cmGlobalVisualStudio12Generator::MatchesGeneratorName(const char* name) const +{ + std::string genName; + if(cmVS12GenName(name, genName)) + { + return genName == this->GetName(); + } + return false; +} + //---------------------------------------------------------------------------- void cmGlobalVisualStudio12Generator::WriteSLNHeader(std::ostream& fout) { diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h index 8c8aeb1fd..5a4a78d0b 100644 --- a/Source/cmGlobalVisualStudio12Generator.h +++ b/Source/cmGlobalVisualStudio12Generator.h @@ -24,6 +24,8 @@ public: const char* platformName, const char* additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); + virtual bool MatchesGeneratorName(const char* name) const; + virtual void WriteSLNHeader(std::ostream& fout); ///! create the correct local generator diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 186d4e6ca..f786691d9 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1468,9 +1468,9 @@ int cmake::ActualConfigure() {"7.1", "Visual Studio 7 .NET 2003"}, {"8.0", "Visual Studio 8 2005"}, {"9.0", "Visual Studio 9 2008"}, - {"10.0", "Visual Studio 10"}, - {"11.0", "Visual Studio 11"}, - {"12.0", "Visual Studio 12"}, + {"10.0", "Visual Studio 10 2010"}, + {"11.0", "Visual Studio 11 2012"}, + {"12.0", "Visual Studio 12 2013"}, {0, 0}}; for(int i=0; version[i].MSVersion != 0; i++) { @@ -1509,7 +1509,7 @@ int cmake::ActualConfigure() const char* genName = this->CacheManager->GetCacheValue("CMAKE_GENERATOR"); if(genName) { - if(strcmp(this->GlobalGenerator->GetName(), genName) != 0) + if(!this->GlobalGenerator->MatchesGeneratorName(genName)) { std::string message = "Error: generator : "; message += this->GlobalGenerator->GetName();