Imported Upstream version 3.24.0
[platform/upstream/cmake.git] / Source / cmExportBuildFileGenerator.h
1 /* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2    file Copyright.txt or https://cmake.org/licensing for details.  */
3 #pragma once
4
5 #include "cmConfigure.h" // IWYU pragma: keep
6
7 #include <iosfwd>
8 #include <string>
9 #include <utility>
10 #include <vector>
11
12 #include <cmext/algorithm>
13
14 #include "cmExportFileGenerator.h"
15 #include "cmStateTypes.h"
16
17 class cmExportSet;
18 class cmFileSet;
19 class cmGeneratorTarget;
20 class cmGlobalGenerator;
21 class cmLocalGenerator;
22 class cmTargetExport;
23
24 /** \class cmExportBuildFileGenerator
25  * \brief Generate a file exporting targets from a build tree.
26  *
27  * cmExportBuildFileGenerator generates a file exporting targets from
28  * a build tree.  A single file exports information for all
29  * configurations built.
30  *
31  * This is used to implement the export() command.
32  */
33 class cmExportBuildFileGenerator : public cmExportFileGenerator
34 {
35 public:
36   cmExportBuildFileGenerator();
37
38   /** Set the list of targets to export.  */
39   void SetTargets(std::vector<std::string> const& targets)
40   {
41     this->Targets = targets;
42   }
43   void GetTargets(std::vector<std::string>& targets) const;
44   void AppendTargets(std::vector<std::string> const& targets)
45   {
46     cm::append(this->Targets, targets);
47   }
48   void SetExportSet(cmExportSet*);
49
50   /** Set whether to append generated code to the output file.  */
51   void SetAppendMode(bool append) { this->AppendMode = append; }
52
53   void Compute(cmLocalGenerator* lg);
54
55 protected:
56   // Implement virtual methods from the superclass.
57   bool GenerateMainFile(std::ostream& os) override;
58   void GenerateImportTargetsConfig(std::ostream& os, const std::string& config,
59                                    std::string const& suffix) override;
60   cmStateEnums::TargetType GetExportTargetType(
61     cmGeneratorTarget const* target) const;
62   void HandleMissingTarget(std::string& link_libs,
63                            cmGeneratorTarget const* depender,
64                            cmGeneratorTarget* dependee) override;
65
66   void ComplainAboutMissingTarget(cmGeneratorTarget const* depender,
67                                   cmGeneratorTarget const* dependee,
68                                   std::vector<std::string> const& namespaces);
69
70   /** Fill in properties indicating built file locations.  */
71   void SetImportLocationProperty(const std::string& config,
72                                  std::string const& suffix,
73                                  cmGeneratorTarget* target,
74                                  ImportPropertyMap& properties);
75
76   std::string InstallNameDir(cmGeneratorTarget const* target,
77                              const std::string& config) override;
78
79   std::string GetFileSetDirectories(cmGeneratorTarget* gte, cmFileSet* fileSet,
80                                     cmTargetExport* te) override;
81   std::string GetFileSetFiles(cmGeneratorTarget* gte, cmFileSet* fileSet,
82                               cmTargetExport* te) override;
83
84   std::pair<std::vector<std::string>, std::string> FindBuildExportInfo(
85     cmGlobalGenerator* gg, const std::string& name);
86
87   std::vector<std::string> Targets;
88   cmExportSet* ExportSet;
89   std::vector<cmGeneratorTarget*> Exports;
90   cmLocalGenerator* LG;
91 };