Rescan dependencies also if CMakeDirectoryInformation.cmake has changed.
[cmake.git] / Source / cmGlobalVisualStudio10Generator.cxx
blobda412923a5708c900c943f15884a5e5aebcc8221
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmGlobalVisualStudio10Generator.cxx,v $
5 Language: C++
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"
21 #include "cmake.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);
47 return lg;
50 //----------------------------------------------------------------------------
51 void cmGlobalVisualStudio10Generator
52 ::GetDocumentation(cmDocumentationEntry& entry) const
54 entry.Name = this->GetName();
55 entry.Brief = "Generates Visual Studio 10 project files.";
56 entry.Full = "";
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()
70 std::string base;
71 std::string path;
73 // base begins with the VisualStudioProjectsLocation reg value...
74 if (cmSystemTools::ReadRegistryValue(
75 "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\10.0;"
76 "VisualStudioProjectsLocation",
77 base))
79 cmSystemTools::ConvertToUnixSlashes(base);
81 // 9.0 macros folder:
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
86 // on it
89 // path is (correctly) still empty if we did not read the base value from
90 // the Registry value
91 return path;
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
108 (void) ignoreErrors;
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";
129 bool clean = false;
130 if ( targetName && strcmp(targetName, "clean") == 0 )
132 clean = true;
133 makeCommand += " ";
134 makeCommand += projectName;
135 makeCommand += ".sln ";
136 makeCommand += "/t:Clean ";
138 else
140 makeCommand += " ";
141 makeCommand += targetName;
142 makeCommand += ".vcxproj ";
144 makeCommand += "/p:Configuration=";
145 if(config && strlen(config))
147 makeCommand += config;
149 else
151 makeCommand += "Debug";
153 if ( additionalOptions )
155 makeCommand += " ";
156 makeCommand += additionalOptions;
158 return makeCommand;