cmake/Source/cmGlobalGhsMultiGenerator.h

159 lines
5.2 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2021-09-14 00:13:48 +02:00
#pragma once
2015-08-17 11:37:30 +02:00
2019-11-11 23:01:05 +01:00
#include <iosfwd>
2020-08-30 11:54:41 +02:00
#include <memory>
2019-11-11 23:01:05 +01:00
#include <set>
#include <string>
#include <utility>
#include <vector>
2022-03-29 21:10:50 +02:00
#include "cmBuildOptions.h"
2020-02-01 23:06:01 +01:00
#include "cmGlobalGenerator.h"
#include "cmGlobalGeneratorFactory.h"
#include "cmTargetDepend.h"
2019-11-11 23:01:05 +01:00
class cmGeneratorTarget;
class cmLocalGenerator;
class cmMakefile;
class cmake;
2015-08-17 11:37:30 +02:00
class cmGlobalGhsMultiGenerator : public cmGlobalGenerator
{
public:
2019-11-11 23:01:05 +01:00
// The default filename extension of GHS MULTI's build files.
2016-07-09 11:21:54 +02:00
static const char* FILE_EXTENSION;
2015-08-17 11:37:30 +02:00
cmGlobalGhsMultiGenerator(cmake* cm);
2019-11-11 23:01:05 +01:00
~cmGlobalGhsMultiGenerator() override;
2015-08-17 11:37:30 +02:00
2020-08-30 11:54:41 +02:00
static std::unique_ptr<cmGlobalGeneratorFactory> NewFactory()
2016-07-09 11:21:54 +02:00
{
2020-08-30 11:54:41 +02:00
return std::unique_ptr<cmGlobalGeneratorFactory>(
new cmGlobalGeneratorSimpleFactory<cmGlobalGhsMultiGenerator>());
2016-07-09 11:21:54 +02:00
}
2015-08-17 11:37:30 +02:00
2019-11-11 23:01:05 +01:00
//! create the correct local generator
2020-08-30 11:54:41 +02:00
std::unique_ptr<cmLocalGenerator> CreateLocalGenerator(
cmMakefile* mf) override;
2015-08-17 11:37:30 +02:00
/// @return the name of this generator.
static std::string GetActualName() { return "Green Hills MULTI"; }
2016-03-13 13:35:51 +01:00
2019-11-11 23:01:05 +01:00
//! Get the name for this generator
std::string GetName() const override { return GetActualName(); }
2015-08-17 11:37:30 +02:00
/// Overloaded methods. @see cmGlobalGenerator::GetDocumentation()
2023-05-23 16:38:00 +02:00
static cmDocumentationEntry GetDocumentation();
2015-08-17 11:37:30 +02:00
2016-03-13 13:35:51 +01:00
/**
* Utilized by the generator factory to determine if this generator
* supports toolsets.
*/
2018-10-28 12:09:07 +01:00
static bool SupportsToolset() { return true; }
2016-03-13 13:35:51 +01:00
2016-10-30 18:24:19 +01:00
/**
* Utilized by the generator factory to determine if this generator
* supports platforms.
*/
2018-10-28 12:09:07 +01:00
static bool SupportsPlatform() { return true; }
// Toolset / Platform Support
2020-08-30 11:54:41 +02:00
bool SetGeneratorToolset(std::string const& ts, bool build,
cmMakefile* mf) override;
2019-11-11 23:01:05 +01:00
bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf) override;
2016-10-30 18:24:19 +01:00
2015-08-17 11:37:30 +02:00
/**
2018-08-09 18:06:22 +02:00
* Try to determine system information such as shared library
* extension, pthreads, byte order etc.
*/
2019-11-11 23:01:05 +01:00
void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
bool optional) override;
2015-08-17 11:37:30 +02:00
/*
2018-08-09 18:06:22 +02:00
* Determine what program to use for building the project.
*/
2018-01-26 17:06:56 +01:00
bool FindMakeProgram(cmMakefile* mf) override;
2015-08-17 11:37:30 +02:00
2019-11-11 23:01:05 +01:00
void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const override;
// Write the common disclaimer text at the top of each build file.
void WriteFileHeader(std::ostream& fout);
2015-08-17 11:37:30 +02:00
protected:
2019-11-11 23:01:05 +01:00
void Generate() override;
std::vector<GeneratedMakeCommand> GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
const std::string& projectDir, std::vector<std::string> const& targetNames,
2022-03-29 21:10:50 +02:00
const std::string& config, int jobs, bool verbose,
const cmBuildOptions& buildOptions = cmBuildOptions(),
2019-11-11 23:01:05 +01:00
std::vector<std::string> const& makeOptions =
std::vector<std::string>()) override;
2022-08-04 22:12:04 +02:00
void AddExtraIDETargets() override;
2015-08-17 11:37:30 +02:00
private:
2019-11-11 23:01:05 +01:00
void GetToolset(cmMakefile* mf, std::string& tsd, const std::string& ts);
/* top-level project */
void OutputTopLevelProject(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
void WriteTopLevelProject(std::ostream& fout, cmLocalGenerator* root);
void WriteMacros(std::ostream& fout, cmLocalGenerator* root);
2022-08-04 22:12:04 +02:00
void WriteHighLevelDirectives(std::ostream& fout, cmLocalGenerator* root);
void WriteSubProjects(std::ostream& fout, bool filterPredefined);
2019-11-11 23:01:05 +01:00
void WriteTargets(cmLocalGenerator* root);
void WriteProjectLine(std::ostream& fout, cmGeneratorTarget const* target,
2021-09-14 00:13:48 +02:00
std::string& rootBinaryDir);
2019-11-11 23:01:05 +01:00
void WriteCustomRuleBOD(std::ostream& fout);
void WriteCustomTargetBOD(std::ostream& fout);
2022-08-04 22:12:04 +02:00
bool AddCheckTarget();
void AddAllTarget();
2019-11-11 23:01:05 +01:00
2022-08-04 22:12:04 +02:00
std::string StampFile;
2020-08-30 11:54:41 +02:00
static std::string TrimQuotes(std::string str);
2019-11-11 23:01:05 +01:00
2018-10-28 12:09:07 +01:00
static const char* DEFAULT_BUILD_PROGRAM;
2022-08-04 22:12:04 +02:00
static const char* CHECK_BUILD_SYSTEM_TARGET;
2019-11-11 23:01:05 +01:00
bool ComputeTargetBuildOrder(cmGeneratorTarget const* tgt,
std::vector<cmGeneratorTarget const*>& build);
bool ComputeTargetBuildOrder(std::vector<cmGeneratorTarget const*>& tgt,
std::vector<cmGeneratorTarget const*>& build);
bool VisitTarget(std::set<cmGeneratorTarget const*>& temp,
std::set<cmGeneratorTarget const*>& perm,
std::vector<cmGeneratorTarget const*>& order,
cmGeneratorTarget const* ti);
std::vector<cmGeneratorTarget const*> ProjectTargets;
// Target sorting
class TargetSet : public std::set<cmGeneratorTarget const*>
{
};
class TargetCompare
{
std::string First;
public:
TargetCompare(std::string first)
: First(std::move(first))
{
}
bool operator()(cmGeneratorTarget const* l,
cmGeneratorTarget const* r) const;
};
class OrderedTargetDependSet;
};
class cmGlobalGhsMultiGenerator::OrderedTargetDependSet
: public std::multiset<cmTargetDepend,
cmGlobalGhsMultiGenerator::TargetCompare>
{
2020-02-01 23:06:01 +01:00
using derived =
std::multiset<cmTargetDepend, cmGlobalGhsMultiGenerator::TargetCompare>;
2019-11-11 23:01:05 +01:00
public:
2020-02-01 23:06:01 +01:00
using TargetDependSet = cmGlobalGenerator::TargetDependSet;
2019-11-11 23:01:05 +01:00
OrderedTargetDependSet(TargetDependSet const&, std::string const& first);
2015-08-17 11:37:30 +02:00
};