1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmGlobalVisualStudio10Generator.cxx,v $
6 Date: $Date: 2009-07-10 13:12:25 $
7 Version: $Revision: 1.2 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "windows.h" // this must be first to define GetCurrentDirectory
18 #include "cmGlobalVisualStudio10Generator.h"
19 #include "cmLocalVisualStudio10Generator.h"
20 #include "cmMakefile.h"
24 cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator()
26 this->FindMakeProgramFile
= "CMakeVS10FindMake.cmake";
29 //----------------------------------------------------------------------------
30 void cmGlobalVisualStudio10Generator::AddPlatformDefinitions(cmMakefile
* mf
)
32 mf
->AddDefinition("MSVC10", "1");
35 //----------------------------------------------------------------------------
36 void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream
& fout
)
38 fout
<< "Microsoft Visual Studio Solution File, Format Version 11.00\n";
39 fout
<< "# Visual Studio 10\n";
42 ///! Create a local generator appropriate to this Global Generator
43 cmLocalGenerator
*cmGlobalVisualStudio10Generator::CreateLocalGenerator()
45 cmLocalGenerator
*lg
= new cmLocalVisualStudio10Generator
;
46 lg
->SetGlobalGenerator(this);
50 //----------------------------------------------------------------------------
51 void cmGlobalVisualStudio10Generator
52 ::GetDocumentation(cmDocumentationEntry
& entry
) const
54 entry
.Name
= this->GetName();
55 entry
.Brief
= "Generates Visual Studio 10 project files.";
59 //----------------------------------------------------------------------------
60 void cmGlobalVisualStudio10Generator
61 ::EnableLanguage(std::vector
<std::string
>const & lang
,
62 cmMakefile
*mf
, bool optional
)
64 cmGlobalVisualStudio8Generator::EnableLanguage(lang
, mf
, optional
);
67 //----------------------------------------------------------------------------
68 std::string
cmGlobalVisualStudio10Generator::GetUserMacrosDirectory()
73 // base begins with the VisualStudioProjectsLocation reg value...
74 if (cmSystemTools::ReadRegistryValue(
75 "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\10.0;"
76 "VisualStudioProjectsLocation",
79 cmSystemTools::ConvertToUnixSlashes(base
);
82 path
= base
+ "/VSMacros80";
83 // *NOT* a typo; right now in Visual Studio 2008 beta the macros
84 // folder is VSMacros80... They may change it to 90 before final
85 // release of 2008 or they may not... we'll have to keep our eyes
89 // path is (correctly) still empty if we did not read the base value from
94 //----------------------------------------------------------------------------
95 std::string
cmGlobalVisualStudio10Generator::GetUserMacrosRegKeyBase()
97 return "Software\\Microsoft\\VisualStudio\\10.0\\vsmacros";
101 std::string cmGlobalVisualStudio10Generator
102 ::GenerateBuildCommand(const char* makeProgram
,
103 const char *projectName
,
104 const char* additionalOptions
, const char *targetName
,
105 const char* config
, bool ignoreErrors
, bool)
107 // Ingoring errors is not implemented in visual studio 6
111 // now build the test
112 std::string makeCommand
113 = cmSystemTools::ConvertToOutputPath(makeProgram
);
114 std::string lowerCaseCommand
= makeCommand
;
115 cmSystemTools::LowerCase(lowerCaseCommand
);
117 // if there are spaces in the makeCommand, assume a full path
118 // and convert it to a path with no spaces in it as the
119 // RunSingleCommand does not like spaces
120 if(makeCommand
.find(' ') != std::string::npos
)
122 cmSystemTools::GetShortPath(makeCommand
.c_str(), makeCommand
);
124 // msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD
125 if(!targetName
|| strlen(targetName
) == 0)
127 targetName
= "ALL_BUILD";
130 if ( targetName
&& strcmp(targetName
, "clean") == 0 )
134 makeCommand
+= projectName
;
135 makeCommand
+= ".sln ";
136 makeCommand
+= "/t:Clean ";
141 makeCommand
+= targetName
;
142 makeCommand
+= ".vcxproj ";
144 makeCommand
+= "/p:Configuration=";
145 if(config
&& strlen(config
))
147 makeCommand
+= config
;
151 makeCommand
+= "Debug";
153 if ( additionalOptions
)
156 makeCommand
+= additionalOptions
;