cmLocalXCodeGenerator.cxx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. cmMakefile* mf)
  17. : cmLocalGenerator(gg, mf)
  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(cmGeneratorTarget 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. cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(t);
  52. gt->HasMacOSXRpathInstallNameDir("");
  53. }
  54. }
  55. //----------------------------------------------------------------------------
  56. void cmLocalXCodeGenerator::GenerateInstallRules()
  57. {
  58. cmLocalGenerator::GenerateInstallRules();
  59. cmTargets& targets = this->Makefile->GetTargets();
  60. for(cmTargets::iterator iter = targets.begin();
  61. iter != targets.end(); ++iter)
  62. {
  63. cmTarget* t = &iter->second;
  64. cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(t);
  65. gt->HasMacOSXRpathInstallNameDir("");
  66. }
  67. }
  68. //----------------------------------------------------------------------------
  69. void cmLocalXCodeGenerator::ComputeObjectFilenames(
  70. std::map<cmSourceFile const*, std::string>& mapping,
  71. cmGeneratorTarget const*)
  72. {
  73. // Count the number of object files with each name. Warn about duplicate
  74. // names since Xcode names them uniquely automatically with a numeric suffix
  75. // to avoid exact duplicate file names. Note that Mac file names are not
  76. // typically case sensitive, hence the LowerCase.
  77. std::map<std::string, int> counts;
  78. for(std::map<cmSourceFile const*, std::string>::iterator
  79. si = mapping.begin(); si != mapping.end(); ++si)
  80. {
  81. cmSourceFile const* sf = si->first;
  82. std::string objectName =
  83. cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
  84. objectName += ".o";
  85. std::string objectNameLower = cmSystemTools::LowerCase(objectName);
  86. counts[objectNameLower] += 1;
  87. if (2 == counts[objectNameLower])
  88. {
  89. // TODO: emit warning about duplicate name?
  90. }
  91. si->second = objectName;
  92. }
  93. }