cmLocalXCodeGenerator.cxx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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() = default;
  19. std::string cmLocalXCodeGenerator::GetTargetDirectory(
  20. cmGeneratorTarget const*) const
  21. {
  22. // No per-target directory for this generator (yet).
  23. return "";
  24. }
  25. void cmLocalXCodeGenerator::AppendFlagEscape(std::string& flags,
  26. const std::string& rawFlag) const
  27. {
  28. const cmGlobalXCodeGenerator* gg =
  29. static_cast<const cmGlobalXCodeGenerator*>(this->GlobalGenerator);
  30. gg->AppendFlag(flags, rawFlag);
  31. }
  32. void cmLocalXCodeGenerator::Generate()
  33. {
  34. cmLocalGenerator::Generate();
  35. for (const auto& target : this->GetGeneratorTargets()) {
  36. target->HasMacOSXRpathInstallNameDir("");
  37. }
  38. }
  39. void cmLocalXCodeGenerator::GenerateInstallRules()
  40. {
  41. cmLocalGenerator::GenerateInstallRules();
  42. for (const auto& target : this->GetGeneratorTargets()) {
  43. target->HasMacOSXRpathInstallNameDir("");
  44. }
  45. }
  46. void cmLocalXCodeGenerator::ComputeObjectFilenames(
  47. std::map<cmSourceFile const*, std::string>& mapping,
  48. cmGeneratorTarget const*)
  49. {
  50. // Count the number of object files with each name. Warn about duplicate
  51. // names since Xcode names them uniquely automatically with a numeric suffix
  52. // to avoid exact duplicate file names. Note that Mac file names are not
  53. // typically case sensitive, hence the LowerCase.
  54. std::map<std::string, int> counts;
  55. for (auto& si : mapping) {
  56. cmSourceFile const* sf = si.first;
  57. std::string objectName = cmStrCat(
  58. cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()), ".o");
  59. std::string objectNameLower = cmSystemTools::LowerCase(objectName);
  60. counts[objectNameLower] += 1;
  61. if (2 == counts[objectNameLower]) {
  62. // TODO: emit warning about duplicate name?
  63. }
  64. si.second = objectName;
  65. }
  66. }