cmLocalVisualStudioGenerator.cxx 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. bool cmLocalVisualStudioGenerator::SourceFileCompiles(const cmSourceFile* sf)
  27. {
  28. return (!sf->GetCustomCommand() &&
  29. !sf->GetPropertyAsBool("HEADER_FILE_ONLY") &&
  30. !sf->GetPropertyAsBool("EXTERNAL_OBJECT"));
  31. }
  32. //----------------------------------------------------------------------------
  33. void cmLocalVisualStudioGenerator::ComputeObjectNameRequirements
  34. (std::vector<cmSourceGroup> const& sourceGroups)
  35. {
  36. // Clear the current set of requirements.
  37. this->NeedObjectName.clear();
  38. // Count the number of object files with each name.
  39. std::map<cmStdString, int> objectNameCounts;
  40. for(unsigned int i = 0; i < sourceGroups.size(); ++i)
  41. {
  42. cmSourceGroup sg = sourceGroups[i];
  43. std::vector<const cmSourceFile*> const& srcs = sg.GetSourceFiles();
  44. for(std::vector<const cmSourceFile*>::const_iterator s = srcs.begin();
  45. s != srcs.end(); ++s)
  46. {
  47. const cmSourceFile* sf = *s;
  48. if(this->SourceFileCompiles(sf))
  49. {
  50. std::string objectName =
  51. cmSystemTools::GetFilenameWithoutLastExtension(
  52. sf->GetFullPath().c_str());
  53. objectName += ".obj";
  54. objectNameCounts[objectName] += 1;
  55. }
  56. }
  57. }
  58. // For all source files producing duplicate names we need unique
  59. // object name computation.
  60. for(unsigned int i = 0; i < sourceGroups.size(); ++i)
  61. {
  62. cmSourceGroup sg = sourceGroups[i];
  63. std::vector<const cmSourceFile*> const& srcs = sg.GetSourceFiles();
  64. for(std::vector<const cmSourceFile*>::const_iterator s = srcs.begin();
  65. s != srcs.end(); ++s)
  66. {
  67. const cmSourceFile* sf = *s;
  68. if(this->SourceFileCompiles(sf))
  69. {
  70. std::string objectName =
  71. cmSystemTools::GetFilenameWithoutLastExtension(
  72. sf->GetFullPath().c_str());
  73. objectName += ".obj";
  74. if(objectNameCounts[objectName] > 1)
  75. {
  76. this->NeedObjectName.insert(sf);
  77. }
  78. }
  79. }
  80. }
  81. }