cmLocalXCodeGenerator.cxx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmLocalXCodeGenerator.h"
  11. #include "cmGlobalXCodeGenerator.h"
  12. #include "cmSourceFile.h"
  13. #include "cmMakefile.h"
  14. //----------------------------------------------------------------------------
  15. cmLocalXCodeGenerator::cmLocalXCodeGenerator(cmGlobalGenerator* gg,
  16. cmState::Snapshot snapshot)
  17. : cmLocalGenerator(gg, snapshot)
  18. {
  19. // the global generator does this, so do not
  20. // put these flags into the language flags
  21. this->EmitUniversalBinaryFlags = false;
  22. }
  23. //----------------------------------------------------------------------------
  24. cmLocalXCodeGenerator::~cmLocalXCodeGenerator()
  25. {
  26. }
  27. //----------------------------------------------------------------------------
  28. std::string
  29. cmLocalXCodeGenerator::GetTargetDirectory(cmTarget const&) const
  30. {
  31. // No per-target directory for this generator (yet).
  32. return "";
  33. }
  34. //----------------------------------------------------------------------------
  35. void cmLocalXCodeGenerator::AppendFlagEscape(std::string& flags,
  36. const std::string& rawFlag)
  37. {
  38. cmGlobalXCodeGenerator* gg =
  39. static_cast<cmGlobalXCodeGenerator*>(this->GlobalGenerator);
  40. gg->AppendFlag(flags, rawFlag);
  41. }
  42. //----------------------------------------------------------------------------
  43. void cmLocalXCodeGenerator::Generate()
  44. {
  45. cmLocalGenerator::Generate();
  46. cmTargets& targets = this->Makefile->GetTargets();
  47. for(cmTargets::iterator iter = targets.begin();
  48. iter != targets.end(); ++iter)
  49. {
  50. cmTarget* t = &iter->second;
  51. t->HasMacOSXRpathInstallNameDir("");
  52. }
  53. }
  54. //----------------------------------------------------------------------------
  55. void cmLocalXCodeGenerator::GenerateInstallRules()
  56. {
  57. cmLocalGenerator::GenerateInstallRules();
  58. cmTargets& targets = this->Makefile->GetTargets();
  59. for(cmTargets::iterator iter = targets.begin();
  60. iter != targets.end(); ++iter)
  61. {
  62. cmTarget* t = &iter->second;
  63. t->HasMacOSXRpathInstallNameDir("");
  64. }
  65. }
  66. //----------------------------------------------------------------------------
  67. void cmLocalXCodeGenerator::ComputeObjectFilenames(
  68. std::map<cmSourceFile const*, std::string>& mapping,
  69. cmGeneratorTarget const*)
  70. {
  71. // Count the number of object files with each name. Warn about duplicate
  72. // names since Xcode names them uniquely automatically with a numeric suffix
  73. // to avoid exact duplicate file names. Note that Mac file names are not
  74. // typically case sensitive, hence the LowerCase.
  75. std::map<std::string, int> counts;
  76. for(std::map<cmSourceFile const*, std::string>::iterator
  77. si = mapping.begin(); si != mapping.end(); ++si)
  78. {
  79. cmSourceFile const* sf = si->first;
  80. std::string objectName =
  81. cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
  82. objectName += ".o";
  83. std::string objectNameLower = cmSystemTools::LowerCase(objectName);
  84. counts[objectNameLower] += 1;
  85. if (2 == counts[objectNameLower])
  86. {
  87. // TODO: emit warning about duplicate name?
  88. }
  89. si->second = objectName;
  90. }
  91. }