1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
5 #include "cmConfigure.h" // IWYU pragma: keep
12 #include <cmext/algorithm>
14 #include "cmExportFileGenerator.h"
15 #include "cmStateTypes.h"
19 class cmGeneratorTarget;
20 class cmGlobalGenerator;
21 class cmLocalGenerator;
24 /** \class cmExportBuildFileGenerator
25 * \brief Generate a file exporting targets from a build tree.
27 * cmExportBuildFileGenerator generates a file exporting targets from
28 * a build tree. A single file exports information for all
29 * configurations built.
31 * This is used to implement the export() command.
33 class cmExportBuildFileGenerator : public cmExportFileGenerator
36 cmExportBuildFileGenerator();
38 /** Set the list of targets to export. */
39 void SetTargets(std::vector<std::string> const& targets)
41 this->Targets = targets;
43 void GetTargets(std::vector<std::string>& targets) const;
44 void AppendTargets(std::vector<std::string> const& targets)
46 cm::append(this->Targets, targets);
48 void SetExportSet(cmExportSet*);
50 /** Set whether to append generated code to the output file. */
51 void SetAppendMode(bool append) { this->AppendMode = append; }
53 void Compute(cmLocalGenerator* lg);
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;
66 void ComplainAboutMissingTarget(cmGeneratorTarget const* depender,
67 cmGeneratorTarget const* dependee,
68 std::vector<std::string> const& namespaces);
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);
76 std::string InstallNameDir(cmGeneratorTarget const* target,
77 const std::string& config) override;
79 std::string GetFileSetDirectories(cmGeneratorTarget* gte, cmFileSet* fileSet,
80 cmTargetExport* te) override;
81 std::string GetFileSetFiles(cmGeneratorTarget* gte, cmFileSet* fileSet,
82 cmTargetExport* te) override;
84 std::pair<std::vector<std::string>, std::string> FindBuildExportInfo(
85 cmGlobalGenerator* gg, const std::string& name);
87 std::vector<std::string> Targets;
88 cmExportSet* ExportSet;
89 std::vector<cmGeneratorTarget*> Exports;