1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
3 #include "cmGlobalVisualStudio9Generator.h"
9 #include "cmDocumentationEntry.h"
10 #include "cmGlobalGenerator.h"
11 #include "cmGlobalGeneratorFactory.h"
12 #include "cmGlobalVisualStudioGenerator.h"
13 #include "cmSystemTools.h"
14 #include "cmVisualStudioWCEPlatformParser.h"
18 static const char vs9generatorName[] = "Visual Studio 9 2008";
20 class cmGlobalVisualStudio9Generator::Factory : public cmGlobalGeneratorFactory
23 std::unique_ptr<cmGlobalGenerator> CreateGlobalGenerator(
24 const std::string& name, bool allowArch, cmake* cm) const override
26 if (strncmp(name.c_str(), vs9generatorName,
27 sizeof(vs9generatorName) - 1) != 0) {
28 return std::unique_ptr<cmGlobalGenerator>();
31 const char* p = name.c_str() + sizeof(vs9generatorName) - 1;
33 return std::unique_ptr<cmGlobalGenerator>(
34 new cmGlobalVisualStudio9Generator(cm, name, ""));
37 if (!allowArch || p[0] != ' ') {
38 return std::unique_ptr<cmGlobalGenerator>();
43 if (!strcmp(p, "IA64")) {
44 return std::unique_ptr<cmGlobalGenerator>(
45 new cmGlobalVisualStudio9Generator(cm, name, "Itanium"));
48 if (!strcmp(p, "Win64")) {
49 return std::unique_ptr<cmGlobalGenerator>(
50 new cmGlobalVisualStudio9Generator(cm, name, "x64"));
53 cmVisualStudioWCEPlatformParser parser(p);
54 parser.ParseVersion("9.0");
55 if (!parser.Found()) {
56 return std::unique_ptr<cmGlobalGenerator>();
59 auto ret = std::unique_ptr<cmGlobalVisualStudio9Generator>(
60 new cmGlobalVisualStudio9Generator(cm, name, p));
61 ret->WindowsCEVersion = parser.GetOSVersion();
62 return std::unique_ptr<cmGlobalGenerator>(std::move(ret));
65 void GetDocumentation(cmDocumentationEntry& entry) const override
67 entry.Name = std::string(vs9generatorName) + " [arch]";
68 entry.Brief = "Generates Visual Studio 2008 project files. "
69 "Optional [arch] can be \"Win64\" or \"IA64\".";
72 std::vector<std::string> GetGeneratorNames() const override
74 std::vector<std::string> names;
75 names.push_back(vs9generatorName);
79 std::vector<std::string> GetGeneratorNamesWithPlatform() const override
81 std::vector<std::string> names;
82 names.push_back(vs9generatorName + std::string(" Win64"));
83 names.push_back(vs9generatorName + std::string(" IA64"));
84 cmVisualStudioWCEPlatformParser parser;
85 parser.ParseVersion("9.0");
86 const std::vector<std::string>& availablePlatforms =
87 parser.GetAvailablePlatforms();
88 for (std::string const& i : availablePlatforms) {
89 names.push_back("Visual Studio 9 2008 " + i);
94 bool SupportsToolset() const override { return false; }
95 bool SupportsPlatform() const override { return true; }
97 std::vector<std::string> GetKnownPlatforms() const override
99 std::vector<std::string> platforms;
100 platforms.emplace_back("x64");
101 platforms.emplace_back("Win32");
102 platforms.emplace_back("Itanium");
103 cmVisualStudioWCEPlatformParser parser;
104 parser.ParseVersion("9.0");
105 const std::vector<std::string>& availablePlatforms =
106 parser.GetAvailablePlatforms();
107 for (std::string const& i : availablePlatforms) {
108 platforms.emplace_back(i);
113 std::string GetDefaultPlatformName() const override { return "Win32"; }
116 std::unique_ptr<cmGlobalGeneratorFactory>
117 cmGlobalVisualStudio9Generator::NewFactory()
119 return std::unique_ptr<cmGlobalGeneratorFactory>(new Factory);
122 cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator(
123 cmake* cm, const std::string& name,
124 std::string const& platformInGeneratorName)
125 : cmGlobalVisualStudio8Generator(cm, name, platformInGeneratorName)
127 this->Version = VSVersion::VS9;
128 std::string vc9Express;
129 this->ExpressEdition = cmSystemTools::ReadRegistryValue(
130 "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\9.0\\Setup\\VC;"
132 vc9Express, cmSystemTools::KeyWOW64_32);
135 std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory()
140 // base begins with the VisualStudioProjectsLocation reg value...
141 if (cmSystemTools::ReadRegistryValue(
142 "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\9.0;"
143 "VisualStudioProjectsLocation",
145 cmSystemTools::ConvertToUnixSlashes(base);
147 // 9.0 macros folder:
148 path = base + "/VSMacros80";
149 // *NOT* a typo; right now in Visual Studio 2008 beta the macros
150 // folder is VSMacros80... They may change it to 90 before final
151 // release of 2008 or they may not... we'll have to keep our eyes
155 // path is (correctly) still empty if we did not read the base value from
156 // the Registry value
160 std::string cmGlobalVisualStudio9Generator::GetUserMacrosRegKeyBase()
162 return "Software\\Microsoft\\VisualStudio\\9.0\\vsmacros";