VS: Add version year to generator names

Rename the Visual Studio >= 10 generators to indicate the version year:

 Visual Studio 10 => Visual Studio 10 2010
 Visual Studio 11 => Visual Studio 11 2012
 Visual Studio 12 => Visual Stduio 12 2013

Report the names with the year to the list of available generators so
that the cmake-gui drop-down shows the years.  When selecting a
generator from the "-G" option or from an existing CMAKE_GENERATOR cache
entry, recognize names without the years for compatibility and map them
to the names with years.

Update the generator names in the cmake-generators.7 manual.
This commit is contained in:
Brad King 2013-10-28 10:08:11 -04:00
parent 16df2456a4
commit 29071fed2e
15 changed files with 208 additions and 93 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -30,9 +30,9 @@ All Generators
/generator/Sublime Text 2 - NMake Makefiles /generator/Sublime Text 2 - NMake Makefiles
/generator/Sublime Text 2 - Unix Makefiles /generator/Sublime Text 2 - Unix Makefiles
/generator/Unix Makefiles /generator/Unix Makefiles
/generator/Visual Studio 10 /generator/Visual Studio 10 2010
/generator/Visual Studio 11 /generator/Visual Studio 11 2012
/generator/Visual Studio 12 /generator/Visual Studio 12 2013
/generator/Visual Studio 6 /generator/Visual Studio 6
/generator/Visual Studio 7 .NET 2003 /generator/Visual Studio 7 .NET 2003
/generator/Visual Studio 7 /generator/Visual Studio 7

View File

@ -52,6 +52,10 @@ public:
///! Get the name for this generator ///! Get the name for this generator
virtual const char *GetName() const { return "Generic"; }; 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 /** Set the generator-specific toolset name. Returns true if toolset
is supported and false otherwise. */ is supported and false otherwise. */
virtual bool SetGeneratorToolset(std::string const& ts); virtual bool SetGeneratorToolset(std::string const& ts);

View File

@ -18,26 +18,46 @@
#include "cmVisualStudioSlnParser.h" #include "cmVisualStudioSlnParser.h"
#include "cmake.h" #include "cmake.h"
static const char vs10Win32generatorName[] = "Visual Studio 10"; static const char vs10generatorName[] = "Visual Studio 10 2010";
static const char vs10Win64generatorName[] = "Visual Studio 10 Win64";
static const char vs10IA64generatorName[] = "Visual Studio 10 IA64"; // 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 class cmGlobalVisualStudio10Generator::Factory
: public cmGlobalGeneratorFactory : public cmGlobalGeneratorFactory
{ {
public: public:
virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const
if(!strcmp(name, vs10Win32generatorName)) {
std::string genName;
const char* p = cmVS10GenName(name, genName);
if(!p)
{ return 0; }
name = genName.c_str();
if(strcmp(p, "") == 0)
{ {
return new cmGlobalVisualStudio10Generator( return new cmGlobalVisualStudio10Generator(
name, NULL, NULL); name, NULL, NULL);
} }
if(!strcmp(name, vs10Win64generatorName)) if(strcmp(p, " Win64") == 0)
{ {
return new cmGlobalVisualStudio10Generator( return new cmGlobalVisualStudio10Generator(
name, "x64", "CMAKE_FORCE_WIN64"); name, "x64", "CMAKE_FORCE_WIN64");
} }
if(!strcmp(name, vs10IA64generatorName)) if(strcmp(p, " IA64") == 0)
{ {
return new cmGlobalVisualStudio10Generator( return new cmGlobalVisualStudio10Generator(
name, "Itanium", "CMAKE_FORCE_IA64"); name, "Itanium", "CMAKE_FORCE_IA64");
@ -45,15 +65,18 @@ public:
return 0; return 0;
} }
virtual void GetDocumentation(cmDocumentationEntry& entry) const { virtual void GetDocumentation(cmDocumentationEntry& entry) const
entry.Name = "Visual Studio 10"; {
entry.Brief = "Generates Visual Studio 10 (2010) project files."; entry.Name = vs10generatorName;
entry.Brief = "Generates Visual Studio 10 (VS 2010) project files.";
} }
virtual void GetGenerators(std::vector<std::string>& names) const { virtual void GetGenerators(std::vector<std::string>& names) const
names.push_back(vs10Win32generatorName); {
names.push_back(vs10Win64generatorName); names.push_back(vs10generatorName);
names.push_back(vs10IA64generatorName); } names.push_back(vs10generatorName + std::string(" IA64"));
names.push_back(vs10generatorName + std::string(" Win64"));
}
}; };
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -77,6 +100,18 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator(
this->MasmEnabled = false; this->MasmEnabled = false;
} }
//----------------------------------------------------------------------------
bool
cmGlobalVisualStudio10Generator::MatchesGeneratorName(const char* name) const
{
std::string genName;
if(cmVS10GenName(name, genName))
{
return genName == this->GetName();
}
return false;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
cmGlobalVisualStudio10Generator::SetGeneratorToolset(std::string const& ts) cmGlobalVisualStudio10Generator::SetGeneratorToolset(std::string const& ts)

View File

@ -28,6 +28,8 @@ public:
const char* platformName, const char* additionalPlatformDefinition); const char* platformName, const char* additionalPlatformDefinition);
static cmGlobalGeneratorFactory* NewFactory(); static cmGlobalGeneratorFactory* NewFactory();
virtual bool MatchesGeneratorName(const char* name) const;
virtual bool SetGeneratorToolset(std::string const& ts); virtual bool SetGeneratorToolset(std::string const& ts);
virtual std::string virtual std::string

View File

@ -13,42 +13,54 @@
#include "cmLocalVisualStudio10Generator.h" #include "cmLocalVisualStudio10Generator.h"
#include "cmMakefile.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 class cmGlobalVisualStudio11Generator::Factory
: public cmGlobalGeneratorFactory : public cmGlobalGeneratorFactory
{ {
public: public:
virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const
if(strstr(name, vs11generatorName) != name)
{ {
return 0; std::string genName;
} const char* p = cmVS11GenName(name, genName);
if(!p)
const char* p = name + sizeof(vs11generatorName) - 1; { return 0; }
if(p[0] == '\0') name = genName.c_str();
if(strcmp(p, "") == 0)
{ {
return new cmGlobalVisualStudio11Generator( return new cmGlobalVisualStudio11Generator(
name, NULL, NULL); name, NULL, NULL);
} }
if(strcmp(p, " Win64") == 0)
if(p[0] != ' ')
{ {
return 0; return new cmGlobalVisualStudio11Generator(
name, "x64", "CMAKE_FORCE_WIN64");
} }
if(strcmp(p, " ARM") == 0)
++p;
if(!strcmp(p, "ARM"))
{ {
return new cmGlobalVisualStudio11Generator( return new cmGlobalVisualStudio11Generator(
name, "ARM", NULL); name, "ARM", NULL);
} }
if(!strcmp(p, "Win64")) if(*p++ != ' ')
{ {
return new cmGlobalVisualStudio11Generator( return 0;
name, "x64", "CMAKE_FORCE_WIN64");
} }
std::set<std::string> installedSDKs = std::set<std::string> installedSDKs =
@ -65,12 +77,14 @@ public:
return ret; return ret;
} }
virtual void GetDocumentation(cmDocumentationEntry& entry) const { virtual void GetDocumentation(cmDocumentationEntry& entry) const
entry.Name = "Visual Studio 11"; {
entry.Brief = "Generates Visual Studio 11 (2012) project files."; entry.Name = vs11generatorName;
entry.Brief = "Generates Visual Studio 11 (VS 2012) project files.";
} }
virtual void GetGenerators(std::vector<std::string>& names) const { virtual void GetGenerators(std::vector<std::string>& names) const
{
names.push_back(vs11generatorName); names.push_back(vs11generatorName);
names.push_back(vs11generatorName + std::string(" ARM")); names.push_back(vs11generatorName + std::string(" ARM"));
names.push_back(vs11generatorName + std::string(" Win64")); names.push_back(vs11generatorName + std::string(" Win64"));
@ -80,7 +94,7 @@ public:
for(std::set<std::string>::const_iterator i = for(std::set<std::string>::const_iterator i =
installedSDKs.begin(); i != installedSDKs.end(); ++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"; 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) void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout)
{ {

View File

@ -24,6 +24,8 @@ public:
const char* platformName, const char* additionalPlatformDefinition); const char* platformName, const char* additionalPlatformDefinition);
static cmGlobalGeneratorFactory* NewFactory(); static cmGlobalGeneratorFactory* NewFactory();
virtual bool MatchesGeneratorName(const char* name) const;
virtual void WriteSLNHeader(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout);
///! create the correct local generator ///! create the correct local generator

View File

@ -13,26 +13,46 @@
#include "cmLocalVisualStudio10Generator.h" #include "cmLocalVisualStudio10Generator.h"
#include "cmMakefile.h" #include "cmMakefile.h"
static const char vs12Win32generatorName[] = "Visual Studio 12"; static const char vs12generatorName[] = "Visual Studio 12 2013";
static const char vs12Win64generatorName[] = "Visual Studio 12 Win64";
static const char vs12ARMgeneratorName[] = "Visual Studio 12 ARM"; // 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 class cmGlobalVisualStudio12Generator::Factory
: public cmGlobalGeneratorFactory : public cmGlobalGeneratorFactory
{ {
public: public:
virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const
if(!strcmp(name, vs12Win32generatorName)) {
std::string genName;
const char* p = cmVS12GenName(name, genName);
if(!p)
{ return 0; }
name = genName.c_str();
if(strcmp(p, "") == 0)
{ {
return new cmGlobalVisualStudio12Generator( return new cmGlobalVisualStudio12Generator(
name, NULL, NULL); name, NULL, NULL);
} }
if(!strcmp(name, vs12Win64generatorName)) if(strcmp(p, " Win64") == 0)
{ {
return new cmGlobalVisualStudio12Generator( return new cmGlobalVisualStudio12Generator(
name, "x64", "CMAKE_FORCE_WIN64"); name, "x64", "CMAKE_FORCE_WIN64");
} }
if(!strcmp(name, vs12ARMgeneratorName)) if(strcmp(p, " ARM") == 0)
{ {
return new cmGlobalVisualStudio12Generator( return new cmGlobalVisualStudio12Generator(
name, "ARM", NULL); name, "ARM", NULL);
@ -40,15 +60,18 @@ public:
return 0; return 0;
} }
virtual void GetDocumentation(cmDocumentationEntry& entry) const { virtual void GetDocumentation(cmDocumentationEntry& entry) const
entry.Name = "Visual Studio 12"; {
entry.Brief = "Generates Visual Studio 12 (2013) project files."; entry.Name = vs12generatorName;
entry.Brief = "Generates Visual Studio 12 (VS 2013) project files.";
} }
virtual void GetGenerators(std::vector<std::string>& names) const { virtual void GetGenerators(std::vector<std::string>& names) const
names.push_back(vs12Win32generatorName); {
names.push_back(vs12Win64generatorName); names.push_back(vs12generatorName);
names.push_back(vs12ARMgeneratorName); } names.push_back(vs12generatorName + std::string(" ARM"));
names.push_back(vs12generatorName + std::string(" Win64"));
}
}; };
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -72,6 +95,18 @@ cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator(
this->PlatformToolset = "v120"; 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) void cmGlobalVisualStudio12Generator::WriteSLNHeader(std::ostream& fout)
{ {

View File

@ -24,6 +24,8 @@ public:
const char* platformName, const char* additionalPlatformDefinition); const char* platformName, const char* additionalPlatformDefinition);
static cmGlobalGeneratorFactory* NewFactory(); static cmGlobalGeneratorFactory* NewFactory();
virtual bool MatchesGeneratorName(const char* name) const;
virtual void WriteSLNHeader(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout);
///! create the correct local generator ///! create the correct local generator

View File

@ -1468,9 +1468,9 @@ int cmake::ActualConfigure()
{"7.1", "Visual Studio 7 .NET 2003"}, {"7.1", "Visual Studio 7 .NET 2003"},
{"8.0", "Visual Studio 8 2005"}, {"8.0", "Visual Studio 8 2005"},
{"9.0", "Visual Studio 9 2008"}, {"9.0", "Visual Studio 9 2008"},
{"10.0", "Visual Studio 10"}, {"10.0", "Visual Studio 10 2010"},
{"11.0", "Visual Studio 11"}, {"11.0", "Visual Studio 11 2012"},
{"12.0", "Visual Studio 12"}, {"12.0", "Visual Studio 12 2013"},
{0, 0}}; {0, 0}};
for(int i=0; version[i].MSVersion != 0; i++) for(int i=0; version[i].MSVersion != 0; i++)
{ {
@ -1509,7 +1509,7 @@ int cmake::ActualConfigure()
const char* genName = this->CacheManager->GetCacheValue("CMAKE_GENERATOR"); const char* genName = this->CacheManager->GetCacheValue("CMAKE_GENERATOR");
if(genName) if(genName)
{ {
if(strcmp(this->GlobalGenerator->GetName(), genName) != 0) if(!this->GlobalGenerator->MatchesGeneratorName(genName))
{ {
std::string message = "Error: generator : "; std::string message = "Error: generator : ";
message += this->GlobalGenerator->GetName(); message += this->GlobalGenerator->GetName();