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 "cmGlobalVisualStudio10Generator.h"
14
#include "cmLocalVisualStudio10Generator.h"
15
#include "cmMakefile.h"
19
cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator()
21
this->FindMakeProgramFile = "CMakeVS10FindMake.cmake";
24
//----------------------------------------------------------------------------
25
void cmGlobalVisualStudio10Generator::AddPlatformDefinitions(cmMakefile* mf)
27
mf->AddDefinition("MSVC10", "1");
30
//----------------------------------------------------------------------------
31
void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout)
33
fout << "Microsoft Visual Studio Solution File, Format Version 11.00\n";
34
fout << "# Visual Studio 2010\n";
37
///! Create a local generator appropriate to this Global Generator
38
cmLocalGenerator *cmGlobalVisualStudio10Generator::CreateLocalGenerator()
40
cmLocalVisualStudio10Generator* lg = new cmLocalVisualStudio10Generator;
41
lg->SetPlatformName(this->PlatformName.c_str());
42
lg->SetGlobalGenerator(this);
46
//----------------------------------------------------------------------------
47
void cmGlobalVisualStudio10Generator
48
::GetDocumentation(cmDocumentationEntry& entry) const
50
entry.Name = this->GetName();
51
entry.Brief = "Generates Visual Studio 10 project files.";
55
//----------------------------------------------------------------------------
56
void cmGlobalVisualStudio10Generator
57
::EnableLanguage(std::vector<std::string>const & lang,
58
cmMakefile *mf, bool optional)
60
cmGlobalVisualStudio8Generator::EnableLanguage(lang, mf, optional);
63
//----------------------------------------------------------------------------
64
std::string cmGlobalVisualStudio10Generator::GetUserMacrosDirectory()
69
// base begins with the VisualStudioProjectsLocation reg value...
70
if (cmSystemTools::ReadRegistryValue(
71
"HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\10.0;"
72
"VisualStudioProjectsLocation",
75
cmSystemTools::ConvertToUnixSlashes(base);
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
85
// path is (correctly) still empty if we did not read the base value from
90
//----------------------------------------------------------------------------
91
std::string cmGlobalVisualStudio10Generator::GetUserMacrosRegKeyBase()
93
return "Software\\Microsoft\\VisualStudio\\10.0\\vsmacros";
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)
103
// Ingoring errors is not implemented in visual studio 6
107
// now build the test
108
std::string makeCommand
109
= cmSystemTools::ConvertToOutputPath(makeProgram);
110
std::string lowerCaseCommand = makeCommand;
111
cmSystemTools::LowerCase(lowerCaseCommand);
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)
118
cmSystemTools::GetShortPath(makeCommand.c_str(), makeCommand);
120
// msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD
121
if(!targetName || strlen(targetName) == 0)
123
targetName = "ALL_BUILD";
126
if ( targetName && strcmp(targetName, "clean") == 0 )
130
makeCommand += projectName;
131
makeCommand += ".sln ";
132
makeCommand += "/t:Clean ";
137
makeCommand += targetName;
138
makeCommand += ".vcxproj ";
140
makeCommand += "/p:Configuration=";
141
if(config && strlen(config))
143
makeCommand += config;
147
makeCommand += "Debug";
149
if ( additionalOptions )
152
makeCommand += additionalOptions;