/src/CMake/Source/cmExportCMakeConfigGenerator.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 <iosfwd> |
8 | | #include <map> |
9 | | #include <set> |
10 | | #include <string> |
11 | | |
12 | | #include <cm/string_view> |
13 | | |
14 | | #include "cmExportFileGenerator.h" |
15 | | #include "cmGeneratorExpression.h" |
16 | | #include "cmStateTypes.h" |
17 | | |
18 | | class cmGeneratorFileSet; |
19 | | class cmGeneratorTarget; |
20 | | class cmTargetExport; |
21 | | |
22 | | /** \class cmExportCMakeConfigGenerator |
23 | | * \brief Generate CMake configuration files exporting targets from a build or |
24 | | * install tree. |
25 | | * |
26 | | * cmExportCMakeConfigGenerator is the superclass for |
27 | | * cmExportBuildCMakeConfigGenerator and cmExportInstallCMakeConfigGenerator. |
28 | | * It contains common code generation routines for the two kinds of export |
29 | | * implementations. |
30 | | */ |
31 | | class cmExportCMakeConfigGenerator : virtual public cmExportFileGenerator |
32 | | { |
33 | | public: |
34 | | cmExportCMakeConfigGenerator(); |
35 | | |
36 | 0 | void SetExportOld(bool exportOld) { this->ExportOld = exportOld; } |
37 | | |
38 | | void SetExportPackageDependencies(bool exportPackageDependencies) |
39 | 0 | { |
40 | 0 | this->ExportPackageDependencies = exportPackageDependencies; |
41 | 0 | } |
42 | | |
43 | | using cmExportFileGenerator::GenerateImportFile; |
44 | | |
45 | | protected: |
46 | | using ImportPropertyMap = std::map<std::string, std::string>; |
47 | | using ImportFileSetPropertyMap = std::map<std::string, ImportPropertyMap>; |
48 | | |
49 | | // Methods to implement export file code generation. |
50 | | bool GenerateImportFile(std::ostream& os) override; |
51 | | virtual void GeneratePolicyHeaderCode(std::ostream& os); |
52 | | virtual void GeneratePolicyFooterCode(std::ostream& os); |
53 | | virtual void GenerateImportHeaderCode(std::ostream& os, |
54 | | std::string const& config = ""); |
55 | | virtual void GenerateImportFooterCode(std::ostream& os); |
56 | | void GenerateImportVersionCode(std::ostream& os); |
57 | | virtual void GenerateImportTargetCode(std::ostream& os, |
58 | | cmGeneratorTarget const* target, |
59 | | cmStateEnums::TargetType targetType); |
60 | | virtual void GenerateImportPropertyCode( |
61 | | std::ostream& os, std::string const& config, std::string const& suffix, |
62 | | cmGeneratorTarget const* target, ImportPropertyMap const& properties, |
63 | | std::string const& importedXcFrameworkLocation); |
64 | | virtual void GenerateImportedFileChecksCode( |
65 | | std::ostream& os, cmGeneratorTarget const* target, |
66 | | ImportPropertyMap const& properties, |
67 | | std::set<std::string> const& importedLocations, |
68 | | std::string const& importedXcFrameworkLocation); |
69 | | virtual void GenerateImportedFileCheckLoop(std::ostream& os); |
70 | | virtual void GenerateMissingTargetsCheckCode(std::ostream& os); |
71 | | virtual void GenerateFindDependencyCalls(std::ostream& os); |
72 | | |
73 | | virtual void GenerateExpectedTargetsCode(std::ostream& os, |
74 | | std::string const& expectedTargets); |
75 | | |
76 | | cm::string_view GetImportPrefixWithSlash() const override; |
77 | | |
78 | | virtual void GenerateInterfaceProperties( |
79 | | cmGeneratorTarget const* target, std::ostream& os, |
80 | | ImportPropertyMap const& properties); |
81 | | |
82 | | void SetImportLinkInterface( |
83 | | std::string const& config, std::string const& suffix, |
84 | | cmGeneratorExpression::PreprocessContext preprocessRule, |
85 | | cmGeneratorTarget const* target, ImportPropertyMap& properties); |
86 | | |
87 | | void GenerateTargetFileSets(cmGeneratorTarget* gte, std::ostream& os, |
88 | | ImportFileSetPropertyMap const& properties, |
89 | | cmTargetExport const* te = nullptr); |
90 | | |
91 | | std::string GetCxxModuleFile(std::string const& name) const override; |
92 | | |
93 | | void GenerateCxxModuleInformation(std::string const& name, std::ostream& os); |
94 | | |
95 | | virtual std::string GetFileSetDirectories(cmGeneratorTarget* gte, |
96 | | cmGeneratorFileSet const* fileSet, |
97 | | cmTargetExport const* te) = 0; |
98 | | virtual std::string GetFileSetFiles(cmGeneratorTarget* gte, |
99 | | cmGeneratorFileSet const* fileSet, |
100 | | cmTargetExport const* te) = 0; |
101 | | |
102 | | void SetRequiredCMakeVersion(unsigned int major, unsigned int minor, |
103 | | unsigned int patch); |
104 | | |
105 | | bool ExportOld = false; |
106 | | bool ExportPackageDependencies = false; |
107 | | |
108 | | unsigned int RequiredCMakeVersionMajor = 2; |
109 | | unsigned int RequiredCMakeVersionMinor = 8; |
110 | | unsigned int RequiredCMakeVersionPatch = 3; |
111 | | }; |