1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 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 "windows.h" // this must be first to define GetCurrentDirectory
13 #include "cmGlobalVisualStudio9Generator.h"
14 #include "cmLocalVisualStudio7Generator.h"
15 #include "cmMakefile.h"
16 #include "cmVisualStudioWCEPlatformParser.h"
19 static const char vs9generatorName[] = "Visual Studio 9 2008";
21 class cmGlobalVisualStudio9Generator::Factory
22 : public cmGlobalGeneratorFactory
25 virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const {
26 if(strstr(name, vs9generatorName) != name)
31 const char* p = name + sizeof(vs9generatorName) - 1;
34 return new cmGlobalVisualStudio9Generator(
45 if(!strcmp(p, "IA64"))
47 return new cmGlobalVisualStudio9Generator(
48 name, "Itanium", "CMAKE_FORCE_IA64");
51 if(!strcmp(p, "Win64"))
53 return new cmGlobalVisualStudio9Generator(
54 name, "x64", "CMAKE_FORCE_WIN64");
57 cmVisualStudioWCEPlatformParser parser(p);
58 parser.ParseVersion("9.0");
64 cmGlobalVisualStudio9Generator* ret = new cmGlobalVisualStudio9Generator(
66 ret->WindowsCEVersion = parser.GetOSVersion();
70 virtual void GetDocumentation(cmDocumentationEntry& entry) const {
71 entry.Name = vs9generatorName;
72 entry.Brief = "Generates Visual Studio 9 2008 project files.";
74 "It is possible to append a space followed by the platform name "
75 "to create project files for a specific target platform. E.g. "
76 "\"Visual Studio 9 2008 Win64\" will create project files for "
77 "the x64 processor; \"Visual Studio 9 2008 IA64\" for Itanium.";
80 virtual void GetGenerators(std::vector<std::string>& names) const {
81 names.push_back(vs9generatorName);
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::vector<std::string>::const_iterator i =
89 availablePlatforms.begin(); i != availablePlatforms.end(); ++i)
91 names.push_back("Visual Studio 9 2008 " + *i);
96 //----------------------------------------------------------------------------
97 cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory()
102 //----------------------------------------------------------------------------
103 cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator(
104 const char* name, const char* platformName,
105 const char* additionalPlatformDefinition)
106 : cmGlobalVisualStudio8Generator(name, platformName,
107 additionalPlatformDefinition)
109 this->FindMakeProgramFile = "CMakeVS9FindMake.cmake";
112 //----------------------------------------------------------------------------
113 void cmGlobalVisualStudio9Generator::WriteSLNHeader(std::ostream& fout)
115 fout << "Microsoft Visual Studio Solution File, Format Version 10.00\n";
116 fout << "# Visual Studio 2008\n";
119 ///! Create a local generator appropriate to this Global Generator
120 cmLocalGenerator *cmGlobalVisualStudio9Generator::CreateLocalGenerator()
122 cmLocalVisualStudio7Generator *lg
123 = new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9);
124 lg->SetPlatformName(this->GetPlatformName());
125 lg->SetExtraFlagTable(this->GetExtraFlagTableVS8());
126 lg->SetGlobalGenerator(this);
130 //----------------------------------------------------------------------------
131 void cmGlobalVisualStudio9Generator
132 ::EnableLanguage(std::vector<std::string>const & lang,
133 cmMakefile *mf, bool optional)
135 cmGlobalVisualStudio8Generator::EnableLanguage(lang, mf, optional);
138 //----------------------------------------------------------------------------
139 std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory()
144 // base begins with the VisualStudioProjectsLocation reg value...
145 if (cmSystemTools::ReadRegistryValue(
146 "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\9.0;"
147 "VisualStudioProjectsLocation",
150 cmSystemTools::ConvertToUnixSlashes(base);
152 // 9.0 macros folder:
153 path = base + "/VSMacros80";
154 // *NOT* a typo; right now in Visual Studio 2008 beta the macros
155 // folder is VSMacros80... They may change it to 90 before final
156 // release of 2008 or they may not... we'll have to keep our eyes
160 // path is (correctly) still empty if we did not read the base value from
161 // the Registry value
165 //----------------------------------------------------------------------------
166 std::string cmGlobalVisualStudio9Generator::GetUserMacrosRegKeyBase()
168 return "Software\\Microsoft\\VisualStudio\\9.0\\vsmacros";