cmLocalXCodeGenerator.cxx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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(cmLocalGenerator* parent)
  16. : cmLocalGenerator(parent)
  17. {
  18. // the global generator does this, so do not
  19. // put these flags into the language flags
  20. this->EmitUniversalBinaryFlags = false;
  21. }
  22. //----------------------------------------------------------------------------
  23. cmLocalXCodeGenerator::~cmLocalXCodeGenerator()
  24. {
  25. }
  26. //----------------------------------------------------------------------------
  27. std::string
  28. cmLocalXCodeGenerator::GetTargetDirectory(cmTarget const&) const
  29. {
  30. // No per-target directory for this generator (yet).
  31. return "";
  32. }
  33. //----------------------------------------------------------------------------
  34. void cmLocalXCodeGenerator::AppendFlagEscape(std::string& flags,
  35. const std::string& rawFlag)
  36. {
  37. cmGlobalXCodeGenerator* gg =
  38. static_cast<cmGlobalXCodeGenerator*>(this->GlobalGenerator);
  39. gg->AppendFlag(flags, rawFlag);
  40. }
  41. //----------------------------------------------------------------------------
  42. void cmLocalXCodeGenerator::Generate()
  43. {
  44. cmLocalGenerator::Generate();
  45. cmTargets& targets = this->Makefile->GetTargets();
  46. for(cmTargets::iterator iter = targets.begin();
  47. iter != targets.end(); ++iter)
  48. {
  49. cmTarget* t = &iter->second;
  50. t->HasMacOSXRpathInstallNameDir("");
  51. }
  52. }
  53. //----------------------------------------------------------------------------
  54. void cmLocalXCodeGenerator::GenerateInstallRules()
  55. {
  56. cmLocalGenerator::GenerateInstallRules();
  57. cmTargets& targets = this->Makefile->GetTargets();
  58. for(cmTargets::iterator iter = targets.begin();
  59. iter != targets.end(); ++iter)
  60. {
  61. cmTarget* t = &iter->second;
  62. t->HasMacOSXRpathInstallNameDir("");
  63. }
  64. }
  65. //----------------------------------------------------------------------------
  66. void cmLocalXCodeGenerator::ComputeObjectFilenames(
  67. std::map<cmSourceFile const*, std::string>& mapping,
  68. cmGeneratorTarget const*)
  69. {
  70. // Count the number of object files with each name. Warn about duplicate
  71. // names since Xcode names them uniquely automatically with a numeric suffix
  72. // to avoid exact duplicate file names. Note that Mac file names are not
  73. // typically case sensitive, hence the LowerCase.
  74. std::map<std::string, int> counts;
  75. for(std::map<cmSourceFile const*, std::string>::iterator
  76. si = mapping.begin(); si != mapping.end(); ++si)
  77. {
  78. cmSourceFile const* sf = si->first;
  79. std::string objectName =
  80. cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
  81. objectName += ".o";
  82. std::string objectNameLower = cmSystemTools::LowerCase(objectName);
  83. counts[objectNameLower] += 1;
  84. if (2 == counts[objectNameLower])
  85. {
  86. // TODO: emit warning about duplicate name?
  87. }
  88. si->second = objectName;
  89. }
  90. }