cmGlobalGhsMultiGenerator.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmGhsMultiGenerator_h
  4. #define cmGhsMultiGenerator_h
  5. #include "cmGlobalGenerator.h"
  6. #include "cmGhsMultiGpj.h"
  7. #include "cmGlobalGeneratorFactory.h"
  8. class cmGeneratedFileStream;
  9. class cmGlobalGhsMultiGenerator : public cmGlobalGenerator
  10. {
  11. public:
  12. // The default filename extension of GHS MULTI's build files.
  13. static const char* FILE_EXTENSION;
  14. cmGlobalGhsMultiGenerator(cmake* cm);
  15. ~cmGlobalGhsMultiGenerator();
  16. static cmGlobalGeneratorFactory* NewFactory()
  17. {
  18. return new cmGlobalGeneratorSimpleFactory<cmGlobalGhsMultiGenerator>();
  19. }
  20. ///! create the correct local generator
  21. cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) override;
  22. /// @return the name of this generator.
  23. static std::string GetActualName() { return "Green Hills MULTI"; }
  24. ///! Get the name for this generator
  25. std::string GetName() const override { return this->GetActualName(); }
  26. /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation()
  27. static void GetDocumentation(cmDocumentationEntry& entry);
  28. /**
  29. * Utilized by the generator factory to determine if this generator
  30. * supports toolsets.
  31. */
  32. static bool SupportsToolset() { return true; }
  33. /**
  34. * Utilized by the generator factory to determine if this generator
  35. * supports platforms.
  36. */
  37. static bool SupportsPlatform() { return true; }
  38. // Toolset / Platform Support
  39. bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf) override;
  40. bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf) override;
  41. /**
  42. * Try to determine system information such as shared library
  43. * extension, pthreads, byte order etc.
  44. */
  45. void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
  46. bool optional) override;
  47. /*
  48. * Determine what program to use for building the project.
  49. */
  50. bool FindMakeProgram(cmMakefile* mf) override;
  51. void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const override;
  52. // Write the common disclaimer text at the top of each build file.
  53. void WriteFileHeader(std::ostream& fout);
  54. // Target dependency sorting
  55. class TargetSet : public std::set<cmGeneratorTarget const*>
  56. {
  57. };
  58. class TargetCompare
  59. {
  60. std::string First;
  61. public:
  62. TargetCompare(std::string const& first)
  63. : First(first)
  64. {
  65. }
  66. bool operator()(cmGeneratorTarget const* l,
  67. cmGeneratorTarget const* r) const;
  68. };
  69. class OrderedTargetDependSet;
  70. protected:
  71. void Generate() override;
  72. void GenerateBuildCommand(std::vector<std::string>& makeCommand,
  73. const std::string& makeProgram,
  74. const std::string& projectName,
  75. const std::string& projectDir,
  76. const std::string& targetName,
  77. const std::string& config, bool fast, int jobs,
  78. bool verbose,
  79. std::vector<std::string> const& makeOptions =
  80. std::vector<std::string>()) override;
  81. private:
  82. void GetToolset(cmMakefile* mf, std::string& tsd, const std::string& ts);
  83. /* top-level project */
  84. void OutputTopLevelProject(cmLocalGenerator* root,
  85. std::vector<cmLocalGenerator*>& generators);
  86. void WriteTopLevelProject(std::ostream& fout, cmLocalGenerator* root,
  87. std::vector<cmLocalGenerator*>& generators);
  88. void WriteMacros(std::ostream& fout);
  89. void WriteHighLevelDirectives(std::ostream& fout);
  90. void WriteSubProjects(std::ostream& fout, cmLocalGenerator* root,
  91. std::vector<cmLocalGenerator*>& generators);
  92. std::string trimQuotes(std::string const& str);
  93. static const char* DEFAULT_BUILD_PROGRAM;
  94. static const char* DEFAULT_TOOLSET_ROOT;
  95. };
  96. class cmGlobalGhsMultiGenerator::OrderedTargetDependSet
  97. : public std::multiset<cmTargetDepend,
  98. cmGlobalGhsMultiGenerator::TargetCompare>
  99. {
  100. typedef std::multiset<cmTargetDepend,
  101. cmGlobalGhsMultiGenerator::TargetCompare>
  102. derived;
  103. public:
  104. typedef cmGlobalGenerator::TargetDependSet TargetDependSet;
  105. OrderedTargetDependSet(TargetDependSet const&, std::string const& first);
  106. };
  107. #endif