summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalVisualStudioGenerator.cxx
blob: b4ab9e240ffdfc11f24472507885ffc24e9342b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*=========================================================================

  Program:   CMake - Cross-Platform Makefile Generator
  Module:    $RCSfile$
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#include "cmLocalVisualStudioGenerator.h"

#include "cmMakefile.h"
#include "cmSourceFile.h"
#include "cmSystemTools.h"

//----------------------------------------------------------------------------
cmLocalVisualStudioGenerator::cmLocalVisualStudioGenerator()
{
}

//----------------------------------------------------------------------------
cmLocalVisualStudioGenerator::~cmLocalVisualStudioGenerator()
{
}

//----------------------------------------------------------------------------
void cmLocalVisualStudioGenerator::ComputeObjectNameRequirements
(std::vector<cmSourceGroup> const& sourceGroups)
{
  // Clear the current set of requirements.
  this->NeedObjectName.clear();

  // Count the number of object files with each name.
  std::map<cmStdString, int> objectNameCounts;
  for(unsigned int i = 0; i < sourceGroups.size(); ++i)
    {
    cmSourceGroup sg = sourceGroups[i];
    std::vector<const cmSourceFile*> const& srcs = sg.GetSourceFiles();
    for(std::vector<const cmSourceFile*>::const_iterator s = srcs.begin();
        s != srcs.end(); ++s)
      {
      const cmSourceFile& sf = *(*s);
      if(!sf.GetCustomCommand() &&
         !sf.GetPropertyAsBool("HEADER_FILE_ONLY") &&
         !sf.GetPropertyAsBool("EXTERNAL_OBJECT"))
        {
        std::string objectName =
          cmSystemTools::GetFilenameWithoutLastExtension(
            sf.GetFullPath().c_str());
        objectName += ".obj";
        objectNameCounts[objectName] += 1;
        }
      }
    }

  // For all source files producing duplicate names we need unique
  // object name computation.
  for(unsigned int i = 0; i < sourceGroups.size(); ++i)
    {
    cmSourceGroup sg = sourceGroups[i];
    std::vector<const cmSourceFile*> const& srcs = sg.GetSourceFiles();
    for(std::vector<const cmSourceFile*>::const_iterator s = srcs.begin();
        s != srcs.end(); ++s)
      {
      const cmSourceFile* sf = *s;
      if(!sf->GetCustomCommand() &&
         !sf->GetPropertyAsBool("HEADER_FILE_ONLY") &&
         !sf->GetPropertyAsBool("EXTERNAL_OBJECT"))
        {
        std::string objectName =
          cmSystemTools::GetFilenameWithoutLastExtension(
            sf->GetFullPath().c_str());
        objectName += ".obj";
        if(objectNameCounts[objectName] > 1)
          {
          this->NeedObjectName.insert(sf);
          }
        }
      }
    }
}