/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 cmFileSet; |
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 | | |
48 | | // Methods to implement export file code generation. |
49 | | bool GenerateImportFile(std::ostream& os) override; |
50 | | virtual void GeneratePolicyHeaderCode(std::ostream& os); |
51 | | virtual void GeneratePolicyFooterCode(std::ostream& os); |
52 | | virtual void GenerateImportHeaderCode(std::ostream& os, |
53 | | std::string const& config = ""); |
54 | | virtual void GenerateImportFooterCode(std::ostream& os); |
55 | | void GenerateImportVersionCode(std::ostream& os); |
56 | | virtual void GenerateImportTargetCode(std::ostream& os, |
57 | | cmGeneratorTarget const* target, |
58 | | cmStateEnums::TargetType targetType); |
59 | | virtual void GenerateImportPropertyCode( |
60 | | std::ostream& os, std::string const& config, std::string const& suffix, |
61 | | cmGeneratorTarget const* target, ImportPropertyMap const& properties, |
62 | | std::string const& importedXcFrameworkLocation); |
63 | | virtual void GenerateImportedFileChecksCode( |
64 | | std::ostream& os, cmGeneratorTarget const* target, |
65 | | ImportPropertyMap const& properties, |
66 | | std::set<std::string> const& importedLocations, |
67 | | std::string const& importedXcFrameworkLocation); |
68 | | virtual void GenerateImportedFileCheckLoop(std::ostream& os); |
69 | | virtual void GenerateMissingTargetsCheckCode(std::ostream& os); |
70 | | virtual void GenerateFindDependencyCalls(std::ostream& os); |
71 | | |
72 | | virtual void GenerateExpectedTargetsCode(std::ostream& os, |
73 | | std::string const& expectedTargets); |
74 | | |
75 | | cm::string_view GetImportPrefixWithSlash() const override; |
76 | | |
77 | | virtual void GenerateInterfaceProperties( |
78 | | cmGeneratorTarget const* target, std::ostream& os, |
79 | | ImportPropertyMap const& properties); |
80 | | |
81 | | void SetImportLinkInterface( |
82 | | std::string const& config, std::string const& suffix, |
83 | | cmGeneratorExpression::PreprocessContext preprocessRule, |
84 | | cmGeneratorTarget const* target, ImportPropertyMap& properties); |
85 | | |
86 | | void GenerateTargetFileSets(cmGeneratorTarget* gte, std::ostream& os, |
87 | | cmTargetExport const* te = nullptr); |
88 | | |
89 | | std::string GetCxxModuleFile(std::string const& name) const override; |
90 | | |
91 | | void GenerateCxxModuleInformation(std::string const& name, std::ostream& os); |
92 | | |
93 | | virtual std::string GetFileSetDirectories(cmGeneratorTarget* gte, |
94 | | cmFileSet* fileSet, |
95 | | cmTargetExport const* te) = 0; |
96 | | virtual std::string GetFileSetFiles(cmGeneratorTarget* gte, |
97 | | cmFileSet* fileSet, |
98 | | cmTargetExport const* te) = 0; |
99 | | |
100 | | void SetRequiredCMakeVersion(unsigned int major, unsigned int minor, |
101 | | unsigned int patch); |
102 | | |
103 | | bool ExportOld = false; |
104 | | bool ExportPackageDependencies = false; |
105 | | |
106 | | unsigned int RequiredCMakeVersionMajor = 2; |
107 | | unsigned int RequiredCMakeVersionMinor = 8; |
108 | | unsigned int RequiredCMakeVersionPatch = 3; |
109 | | }; |