cmLocalVisualStudioGenerator.cxx 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmLocalVisualStudioGenerator.h"
  14. #include "cmMakefile.h"
  15. #include "cmSourceFile.h"
  16. #include "cmSystemTools.h"
  17. //----------------------------------------------------------------------------
  18. cmLocalVisualStudioGenerator::cmLocalVisualStudioGenerator()
  19. {
  20. }
  21. //----------------------------------------------------------------------------
  22. cmLocalVisualStudioGenerator::~cmLocalVisualStudioGenerator()
  23. {
  24. }
  25. //----------------------------------------------------------------------------
  26. void cmLocalVisualStudioGenerator::ComputeObjectNameRequirements
  27. (std::vector<cmSourceGroup> const& sourceGroups)
  28. {
  29. // Clear the current set of requirements.
  30. this->NeedObjectName.clear();
  31. // Count the number of object files with each name.
  32. std::map<cmStdString, int> objectNameCounts;
  33. for(unsigned int i = 0; i < sourceGroups.size(); ++i)
  34. {
  35. cmSourceGroup sg = sourceGroups[i];
  36. std::vector<const cmSourceFile*> const& srcs = sg.GetSourceFiles();
  37. for(std::vector<const cmSourceFile*>::const_iterator s = srcs.begin();
  38. s != srcs.end(); ++s)
  39. {
  40. const cmSourceFile& sf = *(*s);
  41. if(!sf.GetCustomCommand() &&
  42. !sf.GetPropertyAsBool("HEADER_FILE_ONLY") &&
  43. !sf.GetPropertyAsBool("EXTERNAL_OBJECT"))
  44. {
  45. std::string objectName =
  46. cmSystemTools::GetFilenameWithoutLastExtension(
  47. sf.GetFullPath().c_str());
  48. objectName += ".obj";
  49. objectNameCounts[objectName] += 1;
  50. }
  51. }
  52. }
  53. // For all source files producing duplicate names we need unique
  54. // object name computation.
  55. for(unsigned int i = 0; i < sourceGroups.size(); ++i)
  56. {
  57. cmSourceGroup sg = sourceGroups[i];
  58. std::vector<const cmSourceFile*> const& srcs = sg.GetSourceFiles();
  59. for(std::vector<const cmSourceFile*>::const_iterator s = srcs.begin();
  60. s != srcs.end(); ++s)
  61. {
  62. const cmSourceFile* sf = *s;
  63. if(!sf->GetCustomCommand() &&
  64. !sf->GetPropertyAsBool("HEADER_FILE_ONLY") &&
  65. !sf->GetPropertyAsBool("EXTERNAL_OBJECT"))
  66. {
  67. std::string objectName =
  68. cmSystemTools::GetFilenameWithoutLastExtension(
  69. sf->GetFullPath().c_str());
  70. objectName += ".obj";
  71. if(objectNameCounts[objectName] > 1)
  72. {
  73. this->NeedObjectName.insert(sf);
  74. }
  75. }
  76. }
  77. }
  78. }