cmLocalXCodeGenerator.cxx 2.5 KB

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