cmGlobalGhsMultiGenerator.h 4.31 KB
Newer Older
1 2
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing for details.  */
3 4 5 6
#ifndef cmGhsMultiGenerator_h
#define cmGhsMultiGenerator_h

#include "cmGlobalGenerator.h"
7

8
#include "cmGhsMultiGpj.h"
9
#include "cmGlobalGeneratorFactory.h"
10 11 12 13 14 15

class cmGeneratedFileStream;

class cmGlobalGhsMultiGenerator : public cmGlobalGenerator
{
public:
16
  // The default filename extension of GHS MULTI's build files.
17
  static const char* FILE_EXTENSION;
18

19
  cmGlobalGhsMultiGenerator(cmake* cm);
20 21
  ~cmGlobalGhsMultiGenerator();

22 23 24 25
  static cmGlobalGeneratorFactory* NewFactory()
  {
    return new cmGlobalGeneratorSimpleFactory<cmGlobalGhsMultiGenerator>();
  }
26 27

  ///! create the correct local generator
Vitaly Stakhovsky's avatar
Vitaly Stakhovsky committed
28
  cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) override;
29 30 31

  /// @return the name of this generator.
  static std::string GetActualName() { return "Green Hills MULTI"; }
32

33
  ///! Get the name for this generator
Vitaly Stakhovsky's avatar
Vitaly Stakhovsky committed
34
  std::string GetName() const override { return this->GetActualName(); }
35 36

  /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation()
37
  static void GetDocumentation(cmDocumentationEntry& entry);
38

39 40 41 42
  /**
   * Utilized by the generator factory to determine if this generator
   * supports toolsets.
   */
43
  static bool SupportsToolset() { return true; }
44

45 46 47 48
  /**
   * Utilized by the generator factory to determine if this generator
   * supports platforms.
   */
49 50 51
  static bool SupportsPlatform() { return true; }

  // Toolset / Platform Support
Vitaly Stakhovsky's avatar
Vitaly Stakhovsky committed
52 53
  bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf) override;
  bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf) override;
54

55
  /**
56 57 58
   * Try to determine system information such as shared library
   * extension, pthreads, byte order etc.
   */
Vitaly Stakhovsky's avatar
Vitaly Stakhovsky committed
59 60
  void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
                      bool optional) override;
61
  /*
62 63
   * Determine what program to use for building the project.
   */
64
  bool FindMakeProgram(cmMakefile* mf) override;
65

66 67
  void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const override;

68 69
  // Write the common disclaimer text at the top of each build file.
  void WriteFileHeader(std::ostream& fout);
70

71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
  // Target dependency sorting
  class TargetSet : public std::set<cmGeneratorTarget const*>
  {
  };
  class TargetCompare
  {
    std::string First;

  public:
    TargetCompare(std::string const& first)
      : First(first)
    {
    }
    bool operator()(cmGeneratorTarget const* l,
                    cmGeneratorTarget const* r) const;
  };
  class OrderedTargetDependSet;

89
protected:
Vitaly Stakhovsky's avatar
Vitaly Stakhovsky committed
90
  void Generate() override;
91
  void GenerateBuildCommand(GeneratedMakeCommand& makeCommand,
Vitaly Stakhovsky's avatar
Vitaly Stakhovsky committed
92 93 94 95 96 97 98 99
                            const std::string& makeProgram,
                            const std::string& projectName,
                            const std::string& projectDir,
                            const std::string& targetName,
                            const std::string& config, bool fast, int jobs,
                            bool verbose,
                            std::vector<std::string> const& makeOptions =
                              std::vector<std::string>()) override;
100 101

private:
Fred Baksik's avatar
Fred Baksik committed
102
  void GetToolset(cmMakefile* mf, std::string& tsd, const std::string& ts);
103

104 105 106 107 108 109 110 111 112
  /* top-level project */
  void OutputTopLevelProject(cmLocalGenerator* root,
                             std::vector<cmLocalGenerator*>& generators);
  void WriteTopLevelProject(std::ostream& fout, cmLocalGenerator* root,
                            std::vector<cmLocalGenerator*>& generators);
  void WriteMacros(std::ostream& fout);
  void WriteHighLevelDirectives(std::ostream& fout);
  void WriteSubProjects(std::ostream& fout, cmLocalGenerator* root,
                        std::vector<cmLocalGenerator*>& generators);
113

114
  std::string trimQuotes(std::string const& str);
115

116 117
  static const char* DEFAULT_BUILD_PROGRAM;
  static const char* DEFAULT_TOOLSET_ROOT;
118 119
};

120 121 122 123 124 125 126 127 128 129 130 131 132
class cmGlobalGhsMultiGenerator::OrderedTargetDependSet
  : public std::multiset<cmTargetDepend,
                         cmGlobalGhsMultiGenerator::TargetCompare>
{
  typedef std::multiset<cmTargetDepend,
                        cmGlobalGhsMultiGenerator::TargetCompare>
    derived;

public:
  typedef cmGlobalGenerator::TargetDependSet TargetDependSet;
  OrderedTargetDependSet(TargetDependSet const&, std::string const& first);
};

133
#endif