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
;
22 class cmGlobalGhsMultiGenerator
: public cmGlobalGenerator
25 // The default filename extension of GHS MULTI's build files.
26 static const char* FILE_EXTENSION
;
28 cmGlobalGhsMultiGenerator(cmake
* cm
);
29 ~cmGlobalGhsMultiGenerator() override
;
31 static std::unique_ptr
<cmGlobalGeneratorFactory
> NewFactory()
33 return std::unique_ptr
<cmGlobalGeneratorFactory
>(
34 new cmGlobalGeneratorSimpleFactory
<cmGlobalGhsMultiGenerator
>());
37 //! create the correct local generator
38 std::unique_ptr
<cmLocalGenerator
> CreateLocalGenerator(
39 cmMakefile
* mf
) override
;
41 /// @return the name of this generator.
42 static std::string
GetActualName() { return "Green Hills MULTI"; }
44 //! Get the name for this generator
45 std::string
GetName() const override
{ return GetActualName(); }
47 /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation()
48 static cmDocumentationEntry
GetDocumentation();
51 * Utilized by the generator factory to determine if this generator
54 static bool SupportsToolset() { return true; }
57 * Utilized by the generator factory to determine if this generator
60 static bool SupportsPlatform() { return true; }
62 // Toolset / Platform Support
63 bool SetGeneratorToolset(std::string
const& ts
, bool build
,
64 cmMakefile
* mf
) override
;
65 bool SetGeneratorPlatform(std::string
const& p
, cmMakefile
* mf
) override
;
68 * Try to determine system information such as shared library
69 * extension, pthreads, byte order etc.
71 void EnableLanguage(std::vector
<std::string
> const& languages
, cmMakefile
*,
72 bool optional
) override
;
74 * Determine what program to use for building the project.
76 bool FindMakeProgram(cmMakefile
* mf
) override
;
78 void ComputeTargetObjectDirectory(cmGeneratorTarget
* gt
) const override
;
80 // Write the common disclaimer text at the top of each build file.
81 void WriteFileHeader(std::ostream
& fout
);
84 void Generate() override
;
85 std::vector
<GeneratedMakeCommand
> GenerateBuildCommand(
86 const std::string
& makeProgram
, const std::string
& projectName
,
87 const std::string
& projectDir
, std::vector
<std::string
> const& targetNames
,
88 const std::string
& config
, int jobs
, bool verbose
,
89 const cmBuildOptions
& buildOptions
= cmBuildOptions(),
90 std::vector
<std::string
> const& makeOptions
=
91 std::vector
<std::string
>()) override
;
92 void AddExtraIDETargets() override
;
95 void GetToolset(cmMakefile
* mf
, std::string
& tsd
, const std::string
& ts
);
97 /* top-level project */
98 void OutputTopLevelProject(cmLocalGenerator
* root
,
99 std::vector
<cmLocalGenerator
*>& generators
);
100 void WriteTopLevelProject(std::ostream
& fout
, cmLocalGenerator
* root
);
101 void WriteMacros(std::ostream
& fout
, cmLocalGenerator
* root
);
102 void WriteHighLevelDirectives(std::ostream
& fout
, cmLocalGenerator
* root
);
103 void WriteSubProjects(std::ostream
& fout
, bool filterPredefined
);
104 void WriteTargets(cmLocalGenerator
* root
);
105 void WriteProjectLine(std::ostream
& fout
, cmGeneratorTarget
const* target
,
106 std::string
& rootBinaryDir
);
107 void WriteCustomRuleBOD(std::ostream
& fout
);
108 void WriteCustomTargetBOD(std::ostream
& fout
);
109 bool AddCheckTarget();
112 std::string StampFile
;
113 static std::string
TrimQuotes(std::string str
);
115 static const char* DEFAULT_BUILD_PROGRAM
;
116 static const char* CHECK_BUILD_SYSTEM_TARGET
;
118 bool ComputeTargetBuildOrder(cmGeneratorTarget
const* tgt
,
119 std::vector
<cmGeneratorTarget
const*>& build
);
120 bool ComputeTargetBuildOrder(std::vector
<cmGeneratorTarget
const*>& tgt
,
121 std::vector
<cmGeneratorTarget
const*>& build
);
122 bool VisitTarget(std::set
<cmGeneratorTarget
const*>& temp
,
123 std::set
<cmGeneratorTarget
const*>& perm
,
124 std::vector
<cmGeneratorTarget
const*>& order
,
125 cmGeneratorTarget
const* ti
);
127 std::vector
<cmGeneratorTarget
const*> ProjectTargets
;
130 class TargetSet
: public std::set
<cmGeneratorTarget
const*>
138 TargetCompare(std::string first
)
139 : First(std::move(first
))
142 bool operator()(cmGeneratorTarget
const* l
,
143 cmGeneratorTarget
const* r
) const;
145 class OrderedTargetDependSet
;
148 class cmGlobalGhsMultiGenerator::OrderedTargetDependSet
149 : public std::multiset
<cmTargetDepend
,
150 cmGlobalGhsMultiGenerator::TargetCompare
>
153 std::multiset
<cmTargetDepend
, cmGlobalGhsMultiGenerator::TargetCompare
>;
156 using TargetDependSet
= cmGlobalGenerator::TargetDependSet
;
157 OrderedTargetDependSet(TargetDependSet
const&, std::string
const& first
);