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

« back to all changes in this revision

Viewing changes to Source/cmGlobalVisualStudio6Generator.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
 
 
3
 
  Program:   CMake - Cross-Platform Makefile Generator
4
 
  Module:    $RCSfile: cmGlobalVisualStudio6Generator.cxx,v $
5
 
  Language:  C++
6
 
  Date:      $Date: 2009-01-13 18:03:52 $
7
 
  Version:   $Revision: 1.75.2.1 $
8
 
 
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.
11
 
 
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.
15
 
 
16
 
=========================================================================*/
 
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
============================================================================*/
17
12
#include "cmGlobalVisualStudio6Generator.h"
18
13
#include "cmLocalVisualStudio6Generator.h"
19
14
#include "cmMakefile.h"
20
15
#include "cmake.h"
21
16
 
 
17
// Utility function to make a valid VS6 *.dsp filename out
 
18
// of a CMake target name:
 
19
//
 
20
std::string GetVS6TargetName(const std::string& targetName)
 
21
{
 
22
  std::string name(targetName);
 
23
 
 
24
  // Eliminate hyphens. VS6 cannot handle hyphens in *.dsp filenames...
 
25
  // Replace them with underscores.
 
26
  //
 
27
  cmSystemTools::ReplaceString(name, "-", "_");
 
28
 
 
29
  return name;
 
30
}
 
31
 
22
32
cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator()
23
33
{
24
34
  this->FindMakeProgramFile = "CMakeVS6FindMake.cmake";
176
186
{
177
187
  // Write out the header for a DSW file
178
188
  this->WriteDSWHeader(fout);
179
 
  
180
 
  // Get the home directory with the trailing slash
181
 
  std::string homedir = root->GetMakefile()->GetStartOutputDirectory();
182
 
  homedir += "/";
183
 
    
184
 
  unsigned int i;
185
 
  bool doneAllBuild = false;
186
 
  bool doneRunTests = false;
187
 
  bool doneInstall = false;
188
 
  bool doneEditCache = false;
189
 
  bool doneRebuildCache = false;
190
 
  bool donePackage = false;
191
 
 
192
 
  for(i = 0; i < generators.size(); ++i)
 
189
 
 
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);
 
196
 
 
197
  std::string rootdir = root->GetMakefile()->GetStartOutputDirectory();
 
198
  rootdir += "/";
 
199
  for(OrderedTargetDependSet::const_iterator
 
200
        tt = orderedProjectTargets.begin();
 
201
      tt != orderedProjectTargets.end(); ++tt)
193
202
    {
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");
 
207
    if(expath)
195
208
      {
196
 
      continue;
 
209
      std::string project = target->GetName();
 
210
      std::string location = expath;
 
211
      this->WriteExternalProject(fout, project.c_str(),
 
212
                                 location.c_str(), target->GetUtilities());
197
213
      }
198
 
    cmMakefile* mf = generators[i]->GetMakefile();
199
 
    
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(), "");
205
 
 
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
208
 
    // for each target
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)
 
214
    else
215
215
      {
216
 
      // special handling for the current makefile
217
 
      if(mf == generators[0]->GetMakefile())
218
 
        {
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)
225
 
          {
226
 
          unsigned int j;
227
 
          for(j = 0; j < generators.size(); ++j)
228
 
            {
229
 
            cmTargets &atgts = generators[j]->GetMakefile()->GetTargets();
230
 
            for(cmTargets::iterator al = atgts.begin();
231
 
                al != atgts.end(); ++al)
232
 
              {
233
 
              if (!al->second.GetPropertyAsBool("EXCLUDE_FROM_ALL"))
234
 
                {
235
 
                if (al->second.GetType() == cmTarget::UTILITY ||
236
 
                    al->second.GetType() == cmTarget::GLOBAL_TARGET)
237
 
                  {
238
 
                  l->second.AddUtility(al->first.c_str());
239
 
                  }
240
 
                else
241
 
                  {
242
 
                  l->second.AddLinkLibrary(al->first, cmTarget::GENERAL);
243
 
                  }
244
 
                }
245
 
              }
246
 
            }
247
 
          }
248
 
        }
249
 
      // Write the project into the DSW file
250
 
      if (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0)
251
 
        {
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());
258
 
        }
259
 
      else 
260
 
        {
261
 
          bool skip = false;
262
 
          // skip ALL_BUILD and RUN_TESTS if they have already been added
263
 
          if(l->first == "ALL_BUILD" )
264
 
            {
265
 
            if(doneAllBuild)
266
 
              {
267
 
              skip = true;
268
 
              }
269
 
            else
270
 
              {
271
 
              doneAllBuild = true;
272
 
              }
273
 
            }
274
 
          if(l->first == "INSTALL")
275
 
            {
276
 
            if(doneInstall)
277
 
              {
278
 
              skip = true;
279
 
              }
280
 
            else
281
 
              {
282
 
              doneInstall = true;
283
 
              }
284
 
            }
285
 
          if(l->first == "RUN_TESTS")
286
 
            {
287
 
            if(doneRunTests)
288
 
              {
289
 
              skip = true;
290
 
              }
291
 
            else
292
 
              {
293
 
              doneRunTests = true;
294
 
              }
295
 
            }
296
 
          if(l->first == "EDIT_CACHE")
297
 
            {
298
 
            if(doneEditCache)
299
 
              {
300
 
              skip = true;
301
 
              }
302
 
            else
303
 
              {
304
 
              doneEditCache = true;
305
 
              }
306
 
            }
307
 
          if(l->first == "REBUILD_CACHE")
308
 
            {
309
 
            if(doneRebuildCache)
310
 
              {
311
 
              skip = true;
312
 
              }
313
 
            else
314
 
              {
315
 
              doneRebuildCache = true;
316
 
              }
317
 
            }
318
 
          if(l->first == "PACKAGE")
319
 
            {
320
 
            if(donePackage)
321
 
              {
322
 
              skip = true;
323
 
              }
324
 
            else
325
 
              {
326
 
              donePackage = true;
327
 
              }
328
 
            }
329
 
          if(!skip)
330
 
            {
331
 
            this->WriteProject(fout, si->c_str(), dir.c_str(),l->second);
332
 
            }
333
 
          ++si;
334
 
        }
 
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);
335
220
      }
336
221
    }
337
 
  
 
222
 
338
223
  // Write the footer for the DSW file
339
224
  this->WriteDSWFooter(fout);
340
225
}
372
257
    }
373
258
}
374
259
 
375
 
 
376
 
// Utility function to make a valid VS6 *.dsp filename out
377
 
// of a CMake target name:
378
 
//
379
 
std::string GetVS6TargetName(const std::string& targetName)
380
 
{
381
 
  std::string name(targetName);
382
 
 
383
 
  // Eliminate hyphens. VS6 cannot handle hyphens in *.dsp filenames...
384
 
  // Replace them with underscores.
385
 
  //
386
 
  cmSystemTools::ReplaceString(name, "-", "_");
387
 
 
388
 
  return name;
389
 
}
390
 
 
391
 
 
392
260
// Write a dsp file into the DSW file,
393
261
// Note, that dependencies from executables to 
394
262
// the libraries it uses are also done here
451
319
void cmGlobalVisualStudio6Generator::WriteExternalProject(std::ostream& fout, 
452
320
                               const char* name,
453
321
                               const char* location,
454
 
                               const std::vector<std::string>& dependencies)
 
322
                               const std::set<cmStdString>& dependencies)
455
323
{
456
324
 fout << "#########################################################"
457
325
    "######################\n\n";
462
330
  fout << "{{{\n";
463
331
 
464
332
  
465
 
  std::vector<std::string>::const_iterator i, end;
 
333
  std::set<cmStdString>::const_iterator i, end;
466
334
  // write dependencies.
467
335
  i = dependencies.begin();
468
336
  end = dependencies.end();