Imported Upstream version 2.8.9
[platform/upstream/cmake.git] / Source / cmGlobalVisualStudio9Generator.cxx
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
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 "cmake.h"
17
18
19
20 cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator()
21 {
22   this->FindMakeProgramFile = "CMakeVS9FindMake.cmake";
23 }
24
25 //----------------------------------------------------------------------------
26 void cmGlobalVisualStudio9Generator::AddPlatformDefinitions(cmMakefile* mf)
27 {
28   mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", this->ArchitectureId);
29   mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", this->ArchitectureId);
30   mf->AddDefinition("MSVC90", "1");
31 }
32
33 //----------------------------------------------------------------------------
34 void cmGlobalVisualStudio9Generator::WriteSLNHeader(std::ostream& fout)
35 {
36   fout << "Microsoft Visual Studio Solution File, Format Version 10.00\n";
37   fout << "# Visual Studio 2008\n";
38 }
39
40 ///! Create a local generator appropriate to this Global Generator
41 cmLocalGenerator *cmGlobalVisualStudio9Generator::CreateLocalGenerator()
42 {
43   cmLocalVisualStudio7Generator *lg
44     = new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9);
45   lg->SetPlatformName(this->GetPlatformName());
46   lg->SetExtraFlagTable(this->GetExtraFlagTableVS8());
47   lg->SetGlobalGenerator(this);
48   return lg;
49 }
50
51 //----------------------------------------------------------------------------
52 void cmGlobalVisualStudio9Generator
53 ::GetDocumentation(cmDocumentationEntry& entry) const
54 {
55   entry.Name = this->GetName();
56   entry.Brief = "Generates Visual Studio 9 2008 project files.";
57   entry.Full = "";
58 }
59
60 //----------------------------------------------------------------------------
61 void cmGlobalVisualStudio9Generator
62 ::EnableLanguage(std::vector<std::string>const &  lang, 
63                  cmMakefile *mf, bool optional)
64 {
65   cmGlobalVisualStudio8Generator::EnableLanguage(lang, mf, optional);
66 }
67
68 //----------------------------------------------------------------------------
69 std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory()
70 {
71   std::string base;
72   std::string path;
73
74   // base begins with the VisualStudioProjectsLocation reg value...
75   if (cmSystemTools::ReadRegistryValue(
76     "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\9.0;"
77     "VisualStudioProjectsLocation",
78     base))
79     {
80     cmSystemTools::ConvertToUnixSlashes(base);
81
82     // 9.0 macros folder:
83     path = base + "/VSMacros80";
84       // *NOT* a typo; right now in Visual Studio 2008 beta the macros
85       // folder is VSMacros80... They may change it to 90 before final
86       // release of 2008 or they may not... we'll have to keep our eyes
87       // on it
88     }
89
90   // path is (correctly) still empty if we did not read the base value from
91   // the Registry value
92   return path;
93 }
94
95 //----------------------------------------------------------------------------
96 std::string cmGlobalVisualStudio9Generator::GetUserMacrosRegKeyBase()
97 {
98   return "Software\\Microsoft\\VisualStudio\\9.0\\vsmacros";
99 }