~ubuntu-branches/ubuntu/lucid/cmake/lucid

« back to all changes in this revision

Viewing changes to Source/cmGlobalVisualStudio10Generator.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Artur Rona
  • Date: 2009-12-16 11:11:54 UTC
  • mfrom: (3.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20091216111154-6accvv6yq86h2hkc
Tags: 2.8.0-5ubuntu1
* Merge from debian testing (LP: #497349). Remaining changes:
  - Keep the Replaces: on cmake-data to cover the Kubuntu version from
    Jaunty in case someone decides to do an (unsupported) Jaunty->Lucid
    upgrade.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 "cmGlobalVisualStudio10Generator.h"
 
14
#include "cmLocalVisualStudio10Generator.h"
 
15
#include "cmMakefile.h"
 
16
#include "cmake.h"
 
17
 
 
18
 
 
19
cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator()
 
20
{
 
21
  this->FindMakeProgramFile = "CMakeVS10FindMake.cmake";
 
22
}
 
23
 
 
24
//----------------------------------------------------------------------------
 
25
void cmGlobalVisualStudio10Generator::AddPlatformDefinitions(cmMakefile* mf)
 
26
{
 
27
  mf->AddDefinition("MSVC10", "1");
 
28
}
 
29
 
 
30
//----------------------------------------------------------------------------
 
31
void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout)
 
32
{
 
33
  fout << "Microsoft Visual Studio Solution File, Format Version 11.00\n";
 
34
  fout << "# Visual Studio 2010\n";
 
35
}
 
36
 
 
37
///! Create a local generator appropriate to this Global Generator
 
38
cmLocalGenerator *cmGlobalVisualStudio10Generator::CreateLocalGenerator()
 
39
{
 
40
  cmLocalVisualStudio10Generator* lg =  new cmLocalVisualStudio10Generator;
 
41
  lg->SetPlatformName(this->PlatformName.c_str());
 
42
  lg->SetGlobalGenerator(this);
 
43
  return lg;
 
44
}
 
45
 
 
46
//----------------------------------------------------------------------------
 
47
void cmGlobalVisualStudio10Generator
 
48
::GetDocumentation(cmDocumentationEntry& entry) const
 
49
{
 
50
  entry.Name = this->GetName();
 
51
  entry.Brief = "Generates Visual Studio 10 project files.";
 
52
  entry.Full = "";
 
53
}
 
54
 
 
55
//----------------------------------------------------------------------------
 
56
void cmGlobalVisualStudio10Generator
 
57
::EnableLanguage(std::vector<std::string>const &  lang, 
 
58
                 cmMakefile *mf, bool optional)
 
59
{
 
60
  cmGlobalVisualStudio8Generator::EnableLanguage(lang, mf, optional);
 
61
}
 
62
 
 
63
//----------------------------------------------------------------------------
 
64
std::string cmGlobalVisualStudio10Generator::GetUserMacrosDirectory()
 
65
{
 
66
  std::string base;
 
67
  std::string path;
 
68
 
 
69
  // base begins with the VisualStudioProjectsLocation reg value...
 
70
  if (cmSystemTools::ReadRegistryValue(
 
71
    "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\10.0;"
 
72
    "VisualStudioProjectsLocation",
 
73
    base))
 
74
    {
 
75
    cmSystemTools::ConvertToUnixSlashes(base);
 
76
 
 
77
    // 9.0 macros folder:
 
78
    path = base + "/VSMacros80";
 
79
      // *NOT* a typo; right now in Visual Studio 2008 beta the macros
 
80
      // folder is VSMacros80... They may change it to 90 before final
 
81
      // release of 2008 or they may not... we'll have to keep our eyes
 
82
      // on it
 
83
    }
 
84
 
 
85
  // path is (correctly) still empty if we did not read the base value from
 
86
  // the Registry value
 
87
  return path;
 
88
}
 
89
 
 
90
//----------------------------------------------------------------------------
 
91
std::string cmGlobalVisualStudio10Generator::GetUserMacrosRegKeyBase()
 
92
{
 
93
  return "Software\\Microsoft\\VisualStudio\\10.0\\vsmacros";
 
94
}
 
95
 
 
96
 
 
97
std::string cmGlobalVisualStudio10Generator
 
98
::GenerateBuildCommand(const char* makeProgram,
 
99
                       const char *projectName, 
 
100
                       const char* additionalOptions, const char *targetName,
 
101
                       const char* config, bool ignoreErrors, bool)
 
102
{
 
103
  // Ingoring errors is not implemented in visual studio 6
 
104
  (void) ignoreErrors;
 
105
 
 
106
  
 
107
  // now build the test
 
108
  std::string makeCommand 
 
109
    = cmSystemTools::ConvertToOutputPath(makeProgram);
 
110
  std::string lowerCaseCommand = makeCommand;
 
111
  cmSystemTools::LowerCase(lowerCaseCommand);
 
112
 
 
113
  // if there are spaces in the makeCommand, assume a full path
 
114
  // and convert it to a path with no spaces in it as the
 
115
  // RunSingleCommand does not like spaces
 
116
  if(makeCommand.find(' ') != std::string::npos)
 
117
    {
 
118
    cmSystemTools::GetShortPath(makeCommand.c_str(), makeCommand);
 
119
    }
 
120
  // msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD
 
121
  if(!targetName || strlen(targetName) == 0)
 
122
    {
 
123
    targetName = "ALL_BUILD";
 
124
    }    
 
125
  bool clean = false;
 
126
  if ( targetName && strcmp(targetName, "clean") == 0 )
 
127
    {
 
128
    clean = true;
 
129
    makeCommand += " ";
 
130
    makeCommand += projectName;
 
131
    makeCommand += ".sln ";
 
132
    makeCommand += "/t:Clean ";
 
133
    }
 
134
  else
 
135
    {
 
136
    makeCommand += " ";
 
137
    makeCommand += targetName;
 
138
    makeCommand += ".vcxproj ";
 
139
    }
 
140
  makeCommand += "/p:Configuration=";
 
141
  if(config && strlen(config))
 
142
    {
 
143
    makeCommand += config;
 
144
    }
 
145
  else
 
146
    {
 
147
    makeCommand += "Debug";
 
148
    }
 
149
  if ( additionalOptions )
 
150
    {
 
151
    makeCommand += " ";
 
152
    makeCommand += additionalOptions;
 
153
    }
 
154
  return makeCommand;
 
155
}