1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2011 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
12 #include "cmGlobalVisualStudio11Generator.h"
13 #include "cmLocalVisualStudio10Generator.h"
14 #include "cmMakefile.h"
16 static const char vs11generatorName[] = "Visual Studio 11";
18 class cmGlobalVisualStudio11Generator::Factory
19 : public cmGlobalGeneratorFactory
22 virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const {
23 if(strstr(name, vs11generatorName) != name)
28 const char* p = name + sizeof(vs11generatorName) - 1;
31 return new cmGlobalVisualStudio11Generator(
44 return new cmGlobalVisualStudio11Generator(
48 if(!strcmp(p, "Win64"))
50 return new cmGlobalVisualStudio11Generator(
51 name, "x64", "CMAKE_FORCE_WIN64");
54 std::set<std::string> installedSDKs =
55 cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs();
57 if(installedSDKs.find(p) == installedSDKs.end())
62 cmGlobalVisualStudio11Generator* ret =
63 new cmGlobalVisualStudio11Generator(name, p, NULL);
64 ret->WindowsCEVersion = "8.00";
68 virtual void GetDocumentation(cmDocumentationEntry& entry) const {
69 entry.Name = "Visual Studio 11";
70 entry.Brief = "Generates Visual Studio 11 (2012) project files.";
72 "It is possible to append a space followed by the platform name "
73 "to create project files for a specific target platform. E.g. "
74 "\"Visual Studio 11 Win64\" will create project files for "
75 "the x64 processor; \"Visual Studio 11 ARM\" for ARM.";
78 virtual void GetGenerators(std::vector<std::string>& names) const {
79 names.push_back(vs11generatorName);
80 names.push_back(vs11generatorName + std::string(" ARM"));
81 names.push_back(vs11generatorName + std::string(" Win64"));
83 std::set<std::string> installedSDKs =
84 cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs();
85 for(std::set<std::string>::const_iterator i =
86 installedSDKs.begin(); i != installedSDKs.end(); ++i)
88 names.push_back("Visual Studio 11 " + *i);
93 //----------------------------------------------------------------------------
94 cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory()
99 //----------------------------------------------------------------------------
100 cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator(
101 const char* name, const char* platformName,
102 const char* additionalPlatformDefinition)
103 : cmGlobalVisualStudio10Generator(name, platformName,
104 additionalPlatformDefinition)
106 this->FindMakeProgramFile = "CMakeVS11FindMake.cmake";
107 std::string vc11Express;
108 this->ExpressEdition = cmSystemTools::ReadRegistryValue(
109 "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\11.0\\Setup\\VC;"
110 "ProductDir", vc11Express, cmSystemTools::KeyWOW64_32);
111 this->PlatformToolset = "v110";
114 //----------------------------------------------------------------------------
115 void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout)
117 fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n";
118 if (this->ExpressEdition)
120 fout << "# Visual Studio Express 2012 for Windows Desktop\n";
124 fout << "# Visual Studio 2012\n";
128 //----------------------------------------------------------------------------
129 cmLocalGenerator *cmGlobalVisualStudio11Generator::CreateLocalGenerator()
131 cmLocalVisualStudio10Generator* lg =
132 new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS11);
133 lg->SetPlatformName(this->GetPlatformName());
134 lg->SetGlobalGenerator(this);
138 //----------------------------------------------------------------------------
139 bool cmGlobalVisualStudio11Generator::UseFolderProperty()
141 // Intentionally skip over the parent class implementation and call the
142 // grand-parent class's implementation. Folders are not supported by the
143 // Express editions in VS10 and earlier, but they are in VS11 Express.
144 return cmGlobalVisualStudio8Generator::UseFolderProperty();
147 //----------------------------------------------------------------------------
148 std::set<std::string>
149 cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs()
151 const char sdksKey[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
152 "Windows CE Tools\\SDKs";
154 std::vector<std::string> subkeys;
155 cmSystemTools::GetRegistrySubKeys(sdksKey, subkeys,
156 cmSystemTools::KeyWOW64_32);
158 std::set<std::string> ret;
159 for(std::vector<std::string>::const_iterator i =
160 subkeys.begin(); i != subkeys.end(); ++i)
162 std::string key = sdksKey;
168 if(cmSystemTools::ReadRegistryValue(key.c_str(),
170 cmSystemTools::KeyWOW64_32) &&