cmLocalXCodeGenerator.cxx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmLocalXCodeGenerator.h"
  4. #include "cmGeneratorTarget.h"
  5. #include "cmGlobalXCodeGenerator.h"
  6. #include "cmSourceFile.h"
  7. class cmGeneratorTarget;
  8. class cmGlobalGenerator;
  9. class cmMakefile;
  10. cmLocalXCodeGenerator::cmLocalXCodeGenerator(cmGlobalGenerator* gg,
  11. cmMakefile* mf)
  12. : cmLocalGenerator(gg, mf)
  13. {
  14. // the global generator does this, so do not
  15. // put these flags into the language flags
  16. this->EmitUniversalBinaryFlags = false;
  17. }
  18. cmLocalXCodeGenerator::~cmLocalXCodeGenerator()
  19. {
  20. }
  21. std::string cmLocalXCodeGenerator::GetTargetDirectory(
  22. cmGeneratorTarget const*) const
  23. {
  24. // No per-target directory for this generator (yet).
  25. return "";
  26. }
  27. void cmLocalXCodeGenerator::AppendFlagEscape(std::string& flags,
  28. const std::string& rawFlag) const
  29. {
  30. const cmGlobalXCodeGenerator* gg =
  31. static_cast<const cmGlobalXCodeGenerator*>(this->GlobalGenerator);
  32. gg->AppendFlag(flags, rawFlag);
  33. }
  34. void cmLocalXCodeGenerator::Generate()
  35. {
  36. cmLocalGenerator::Generate();
  37. for (auto target : this->GetGeneratorTargets()) {
  38. target->HasMacOSXRpathInstallNameDir("");
  39. }
  40. }
  41. void cmLocalXCodeGenerator::GenerateInstallRules()
  42. {
  43. cmLocalGenerator::GenerateInstallRules();
  44. for (auto target : this->GetGeneratorTargets()) {
  45. target->HasMacOSXRpathInstallNameDir("");
  46. }
  47. }
  48. void cmLocalXCodeGenerator::ComputeObjectFilenames(
  49. std::map<cmSourceFile const*, std::string>& mapping,
  50. cmGeneratorTarget const*)
  51. {
  52. // Count the number of object files with each name. Warn about duplicate
  53. // names since Xcode names them uniquely automatically with a numeric suffix
  54. // to avoid exact duplicate file names. Note that Mac file names are not
  55. // typically case sensitive, hence the LowerCase.
  56. std::map<std::string, int> counts;
  57. for (auto& si : mapping) {
  58. cmSourceFile const* sf = si.first;
  59. std::string objectName =
  60. cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
  61. objectName += ".o";
  62. std::string objectNameLower = cmSystemTools::LowerCase(objectName);
  63. counts[objectNameLower] += 1;
  64. if (2 == counts[objectNameLower]) {
  65. // TODO: emit warning about duplicate name?
  66. }
  67. si.second = objectName;
  68. }
  69. }