1
/*=========================================================================
3
Program: CMake - Cross-Platform Makefile Generator
4
Module: $RCSfile: cmGlobalVisualStudio6Generator.cxx,v $
6
Date: $Date: 2009-01-13 18:03:52 $
7
Version: $Revision: 1.75.2.1 $
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
=========================================================================*/
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
============================================================================*/
17
12
#include "cmGlobalVisualStudio6Generator.h"
18
13
#include "cmLocalVisualStudio6Generator.h"
19
14
#include "cmMakefile.h"
17
// Utility function to make a valid VS6 *.dsp filename out
18
// of a CMake target name:
20
std::string GetVS6TargetName(const std::string& targetName)
22
std::string name(targetName);
24
// Eliminate hyphens. VS6 cannot handle hyphens in *.dsp filenames...
25
// Replace them with underscores.
27
cmSystemTools::ReplaceString(name, "-", "_");
22
32
cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator()
24
34
this->FindMakeProgramFile = "CMakeVS6FindMake.cmake";
177
187
// Write out the header for a DSW file
178
188
this->WriteDSWHeader(fout);
180
// Get the home directory with the trailing slash
181
std::string homedir = root->GetMakefile()->GetStartOutputDirectory();
185
bool doneAllBuild = false;
186
bool doneRunTests = false;
187
bool doneInstall = false;
188
bool doneEditCache = false;
189
bool doneRebuildCache = false;
190
bool donePackage = false;
192
for(i = 0; i < generators.size(); ++i)
190
// Collect all targets under this root generator and the transitive
191
// closure of their dependencies.
192
TargetDependSet projectTargets;
193
TargetDependSet originalTargets;
194
this->GetTargetSets(projectTargets, originalTargets, root, generators);
195
OrderedTargetDependSet orderedProjectTargets(projectTargets);
197
std::string rootdir = root->GetMakefile()->GetStartOutputDirectory();
199
for(OrderedTargetDependSet::const_iterator
200
tt = orderedProjectTargets.begin();
201
tt != orderedProjectTargets.end(); ++tt)
194
if(this->IsExcluded(root, generators[i]))
203
cmTarget* target = *tt;
204
cmMakefile* mf = target->GetMakefile();
205
// Write the project into the DSW file
206
const char* expath = target->GetProperty("EXTERNAL_MSPROJECT");
209
std::string project = target->GetName();
210
std::string location = expath;
211
this->WriteExternalProject(fout, project.c_str(),
212
location.c_str(), target->GetUtilities());
198
cmMakefile* mf = generators[i]->GetMakefile();
200
// Get the source directory from the makefile
201
std::string dir = mf->GetStartOutputDirectory();
202
// remove the home directory and / from the source directory
203
// this gives a relative path
204
cmSystemTools::ReplaceString(dir, homedir.c_str(), "");
206
// Get the list of create dsp files names from the LocalGenerator, more
207
// than one dsp could have been created per input CMakeLists.txt file
209
std::vector<std::string> dspnames =
210
static_cast<cmLocalVisualStudio6Generator *>(generators[i])
211
->GetCreatedProjectNames();
212
cmTargets &tgts = generators[i]->GetMakefile()->GetTargets();
213
std::vector<std::string>::iterator si = dspnames.begin();
214
for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l)
216
// special handling for the current makefile
217
if(mf == generators[0]->GetMakefile())
219
dir = "."; // no subdirectory for project generated
220
// if this is the special ALL_BUILD utility, then
221
// make it depend on every other non UTILITY project.
222
// This is done by adding the names to the GetUtilities
223
// vector on the makefile
224
if(l->first == "ALL_BUILD" && !doneAllBuild)
227
for(j = 0; j < generators.size(); ++j)
229
cmTargets &atgts = generators[j]->GetMakefile()->GetTargets();
230
for(cmTargets::iterator al = atgts.begin();
231
al != atgts.end(); ++al)
233
if (!al->second.GetPropertyAsBool("EXCLUDE_FROM_ALL"))
235
if (al->second.GetType() == cmTarget::UTILITY ||
236
al->second.GetType() == cmTarget::GLOBAL_TARGET)
238
l->second.AddUtility(al->first.c_str());
242
l->second.AddLinkLibrary(al->first, cmTarget::GENERAL);
249
// Write the project into the DSW file
250
if (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0)
252
cmCustomCommand cc = l->second.GetPostBuildCommands()[0];
253
const cmCustomCommandLines& cmds = cc.GetCommandLines();
254
std::string project = cmds[0][0];
255
std::string location = cmds[0][1];
256
this->WriteExternalProject(fout, project.c_str(),
257
location.c_str(), cc.GetDepends());
262
// skip ALL_BUILD and RUN_TESTS if they have already been added
263
if(l->first == "ALL_BUILD" )
274
if(l->first == "INSTALL")
285
if(l->first == "RUN_TESTS")
296
if(l->first == "EDIT_CACHE")
304
doneEditCache = true;
307
if(l->first == "REBUILD_CACHE")
315
doneRebuildCache = true;
318
if(l->first == "PACKAGE")
331
this->WriteProject(fout, si->c_str(), dir.c_str(),l->second);
216
std::string dspname = GetVS6TargetName(target->GetName());
217
std::string dir = target->GetMakefile()->GetStartOutputDirectory();
218
dir = root->Convert(dir.c_str(), cmLocalGenerator::START_OUTPUT);
219
this->WriteProject(fout, dspname.c_str(), dir.c_str(), *target);
338
223
// Write the footer for the DSW file
339
224
this->WriteDSWFooter(fout);