/src/CMake/Source/cmExportBuildFileGenerator.h
Line | Count | Source |
1 | | /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
2 | | file LICENSE.rst or https://cmake.org/licensing for details. */ |
3 | | #pragma once |
4 | | |
5 | | #include "cmConfigure.h" // IWYU pragma: keep |
6 | | |
7 | | #include <functional> |
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 cmGeneratorTarget; |
19 | | class cmLocalGenerator; |
20 | | |
21 | | /** \class cmExportBuildCMakeConfigGenerator |
22 | | * \brief Generate a file exporting targets from a build tree. |
23 | | * |
24 | | * cmExportBuildCMakeConfigGenerator is the interface class for generating a |
25 | | * file exporting targets from a build tree. |
26 | | * |
27 | | * This is used to implement the export() command. |
28 | | */ |
29 | | class cmExportBuildFileGenerator : virtual public cmExportFileGenerator |
30 | | { |
31 | | public: |
32 | | struct TargetExport |
33 | | { |
34 | | TargetExport(std::string name, std::string xcFrameworkLocation) |
35 | 0 | : Name(std::move(name)) |
36 | 0 | , XcFrameworkLocation(std::move(xcFrameworkLocation)) |
37 | 0 | { |
38 | 0 | } |
39 | | |
40 | | std::string Name; |
41 | | std::string XcFrameworkLocation; |
42 | | }; |
43 | | |
44 | | cmExportBuildFileGenerator(); |
45 | | |
46 | | /** Set the list of targets to export. */ |
47 | | void SetTargets(std::vector<TargetExport> const& targets) |
48 | 0 | { |
49 | 0 | this->Targets = targets; |
50 | 0 | } |
51 | | void GetTargets(std::vector<TargetExport>& targets) const; |
52 | | void AppendTargets(std::vector<TargetExport> const& targets) |
53 | 0 | { |
54 | 0 | cm::append(this->Targets, targets); |
55 | 0 | } |
56 | | void SetExportSet(cmExportSet*); |
57 | | |
58 | | /** Set the name of the C++ module directory. */ |
59 | | void SetCxxModuleDirectory(std::string cxx_module_dir) |
60 | 0 | { |
61 | 0 | this->CxxModulesDirectory = std::move(cxx_module_dir); |
62 | 0 | } |
63 | | std::string const& GetCxxModuleDirectory() const |
64 | 0 | { |
65 | 0 | return this->CxxModulesDirectory; |
66 | 0 | } |
67 | | |
68 | | void Compute(cmLocalGenerator* lg); |
69 | | |
70 | | protected: |
71 | | cmStateEnums::TargetType GetExportTargetType( |
72 | | cmGeneratorTarget const* target) const; |
73 | | |
74 | | /** Walk the list of targets to be exported. Returns true iff no duplicates |
75 | | are found. */ |
76 | | bool CollectExports(std::function<void(cmGeneratorTarget const*)> visitor); |
77 | | |
78 | | void HandleMissingTarget(std::string& link_libs, |
79 | | cmGeneratorTarget const* depender, |
80 | | cmGeneratorTarget* dependee) override; |
81 | | |
82 | | void ComplainAboutMissingTarget(cmGeneratorTarget const* depender, |
83 | | cmGeneratorTarget const* dependee, |
84 | | ExportInfo const& exportInfo) const; |
85 | | |
86 | | void ComplainAboutDuplicateTarget( |
87 | | std::string const& targetName) const override; |
88 | | |
89 | | void IssueMessage(MessageType type, |
90 | | std::string const& message) const override; |
91 | | |
92 | | /** Fill in properties indicating built file locations. */ |
93 | | void SetImportLocationProperty(std::string const& config, |
94 | | std::string const& suffix, |
95 | | cmGeneratorTarget* target, |
96 | | ImportPropertyMap& properties); |
97 | | |
98 | | std::string InstallNameDir(cmGeneratorTarget const* target, |
99 | | std::string const& config) override; |
100 | | |
101 | 0 | cmExportSet* GetExportSet() const override { return this->ExportSet; } |
102 | | |
103 | | std::string GetCxxModulesDirectory() const override |
104 | 0 | { |
105 | 0 | return this->CxxModulesDirectory; |
106 | 0 | } |
107 | | |
108 | | ExportInfo FindExportInfo(cmGeneratorTarget const* target) const override; |
109 | | |
110 | | using cmExportFileGenerator::PopulateInterfaceProperties; |
111 | | bool PopulateInterfaceProperties(cmGeneratorTarget const* target, |
112 | | ImportPropertyMap& properties); |
113 | | |
114 | | struct TargetExportPrivate |
115 | | { |
116 | | TargetExportPrivate(cmGeneratorTarget* target, |
117 | | std::string xcFrameworkLocation) |
118 | 0 | : Target(target) |
119 | 0 | , XcFrameworkLocation(std::move(xcFrameworkLocation)) |
120 | 0 | { |
121 | 0 | } |
122 | | |
123 | | cmGeneratorTarget* Target; |
124 | | std::string XcFrameworkLocation; |
125 | | }; |
126 | | |
127 | | std::vector<TargetExport> Targets; |
128 | | cmExportSet* ExportSet; |
129 | | std::vector<TargetExportPrivate> Exports; |
130 | | cmLocalGenerator* LG; |
131 | | // The directory for C++ module information. |
132 | | std::string CxxModulesDirectory; |
133 | | }; |