1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
12 #include "cmBuildOptions.h"
13 #include "cmGlobalGenerator.h"
14 #include "cmGlobalGeneratorFactory.h"
15 #include "cmTargetDepend.h"
17 class cmGeneratorTarget;
18 class cmLocalGenerator;
21 struct cmDocumentationEntry;
23 class cmGlobalGhsMultiGenerator : public cmGlobalGenerator
26 // The default filename extension of GHS MULTI's build files.
27 static const char* FILE_EXTENSION;
29 cmGlobalGhsMultiGenerator(cmake* cm);
30 ~cmGlobalGhsMultiGenerator() override;
32 static std::unique_ptr<cmGlobalGeneratorFactory> NewFactory()
34 return std::unique_ptr<cmGlobalGeneratorFactory>(
35 new cmGlobalGeneratorSimpleFactory<cmGlobalGhsMultiGenerator>());
38 //! create the correct local generator
39 std::unique_ptr<cmLocalGenerator> CreateLocalGenerator(
40 cmMakefile* mf) override;
42 /// @return the name of this generator.
43 static std::string GetActualName() { return "Green Hills MULTI"; }
45 //! Get the name for this generator
46 std::string GetName() const override { return GetActualName(); }
48 /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation()
49 static void GetDocumentation(cmDocumentationEntry& entry);
52 * Utilized by the generator factory to determine if this generator
55 static bool SupportsToolset() { return true; }
58 * Utilized by the generator factory to determine if this generator
61 static bool SupportsPlatform() { return true; }
63 // Toolset / Platform Support
64 bool SetGeneratorToolset(std::string const& ts, bool build,
65 cmMakefile* mf) override;
66 bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf) override;
69 * Try to determine system information such as shared library
70 * extension, pthreads, byte order etc.
72 void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
73 bool optional) override;
75 * Determine what program to use for building the project.
77 bool FindMakeProgram(cmMakefile* mf) override;
79 void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const override;
81 // Write the common disclaimer text at the top of each build file.
82 void WriteFileHeader(std::ostream& fout);
85 void Generate() override;
86 std::vector<GeneratedMakeCommand> GenerateBuildCommand(
87 const std::string& makeProgram, const std::string& projectName,
88 const std::string& projectDir, std::vector<std::string> const& targetNames,
89 const std::string& config, int jobs, bool verbose,
90 const cmBuildOptions& buildOptions = cmBuildOptions(),
91 std::vector<std::string> const& makeOptions =
92 std::vector<std::string>()) override;
93 void AddExtraIDETargets() override;
96 void GetToolset(cmMakefile* mf, std::string& tsd, const std::string& ts);
98 /* top-level project */
99 void OutputTopLevelProject(cmLocalGenerator* root,
100 std::vector<cmLocalGenerator*>& generators);
101 void WriteTopLevelProject(std::ostream& fout, cmLocalGenerator* root);
102 void WriteMacros(std::ostream& fout, cmLocalGenerator* root);
103 void WriteHighLevelDirectives(std::ostream& fout, cmLocalGenerator* root);
104 void WriteSubProjects(std::ostream& fout, bool filterPredefined);
105 void WriteTargets(cmLocalGenerator* root);
106 void WriteProjectLine(std::ostream& fout, cmGeneratorTarget const* target,
107 std::string& rootBinaryDir);
108 void WriteCustomRuleBOD(std::ostream& fout);
109 void WriteCustomTargetBOD(std::ostream& fout);
110 bool AddCheckTarget();
113 std::string StampFile;
114 static std::string TrimQuotes(std::string str);
116 static const char* DEFAULT_BUILD_PROGRAM;
117 static const char* CHECK_BUILD_SYSTEM_TARGET;
119 bool ComputeTargetBuildOrder(cmGeneratorTarget const* tgt,
120 std::vector<cmGeneratorTarget const*>& build);
121 bool ComputeTargetBuildOrder(std::vector<cmGeneratorTarget const*>& tgt,
122 std::vector<cmGeneratorTarget const*>& build);
123 bool VisitTarget(std::set<cmGeneratorTarget const*>& temp,
124 std::set<cmGeneratorTarget const*>& perm,
125 std::vector<cmGeneratorTarget const*>& order,
126 cmGeneratorTarget const* ti);
128 std::vector<cmGeneratorTarget const*> ProjectTargets;
131 class TargetSet : public std::set<cmGeneratorTarget const*>
139 TargetCompare(std::string first)
140 : First(std::move(first))
143 bool operator()(cmGeneratorTarget const* l,
144 cmGeneratorTarget const* r) const;
146 class OrderedTargetDependSet;
149 class cmGlobalGhsMultiGenerator::OrderedTargetDependSet
150 : public std::multiset<cmTargetDepend,
151 cmGlobalGhsMultiGenerator::TargetCompare>
154 std::multiset<cmTargetDepend, cmGlobalGhsMultiGenerator::TargetCompare>;
157 using TargetDependSet = cmGlobalGenerator::TargetDependSet;
158 OrderedTargetDependSet(TargetDependSet const&, std::string const& first);