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