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
14 #include "cmExportFileGenerator.h"
15 #include "cmStateTypes.h"
18 class cmGeneratorTarget;
19 class cmGlobalGenerator;
20 class cmInstallExportGenerator;
21 class cmInstallTargetGenerator;
24 /** \class cmExportInstallFileGenerator
25 * \brief Generate a file exporting targets from an install tree.
27 * cmExportInstallFileGenerator generates files exporting targets from
28 * install an installation tree. The files are placed in a temporary
29 * location for installation by cmInstallExportGenerator. One main
30 * file is generated that creates the imported targets and loads
31 * per-configuration files. Target locations and settings for each
32 * configuration are written to these per-configuration files. After
33 * installation the main file loads the configurations that have been
36 * This is used to implement the INSTALL(EXPORT) command.
38 class cmExportInstallFileGenerator : public cmExportFileGenerator
41 /** Construct with the export installer that will install the
43 cmExportInstallFileGenerator(cmInstallExportGenerator* iegen);
45 /** Get the per-config file generated for each configuration. This
46 maps from the configuration name to the file temporary location
48 std::map<std::string, std::string> const& GetConfigImportFiles()
50 return this->ConfigImportFiles;
53 /** Get the per-config C++ module file generated for each configuration.
54 This maps from the configuration name to the file temporary location
56 std::map<std::string, std::string> const& GetConfigCxxModuleFiles()
58 return this->ConfigCxxModuleFiles;
61 /** Get the per-config C++ module file generated for each configuration.
62 This maps from the configuration name to the file temporary location
63 for installation for each target in the export set. */
64 std::map<std::string, std::vector<std::string>> const&
65 GetConfigCxxModuleTargetFiles()
67 return this->ConfigCxxModuleTargetFiles;
70 /** Compute the globbing expression used to load per-config import
71 files from the main file. */
72 std::string GetConfigImportFileGlob();
75 // Implement virtual methods from the superclass.
76 bool GenerateMainFile(std::ostream& os) override;
77 void GenerateImportTargetsConfig(std::ostream& os, const std::string& config,
78 std::string const& suffix) override;
79 cmStateEnums::TargetType GetExportTargetType(
80 cmTargetExport const* targetExport) const;
81 void HandleMissingTarget(std::string& link_libs,
82 cmGeneratorTarget const* depender,
83 cmGeneratorTarget* dependee) override;
85 void ReplaceInstallPrefix(std::string& input) override;
87 void ComplainAboutMissingTarget(cmGeneratorTarget const* depender,
88 cmGeneratorTarget const* dependee,
89 std::vector<std::string> const& exportFiles);
91 std::pair<std::vector<std::string>, std::string> FindNamespaces(
92 cmGlobalGenerator* gg, const std::string& name);
94 /** Generate the relative import prefix. */
95 virtual void GenerateImportPrefix(std::ostream&);
97 /** Generate the relative import prefix. */
98 virtual void LoadConfigFiles(std::ostream&);
100 virtual void CleanupTemporaryVariables(std::ostream&);
102 /** Generate a per-configuration file for the targets. */
103 virtual bool GenerateImportFileConfig(const std::string& config);
105 /** Fill in properties indicating installed file locations. */
106 void SetImportLocationProperty(const std::string& config,
107 std::string const& suffix,
108 cmInstallTargetGenerator* itgen,
109 ImportPropertyMap& properties,
110 std::set<std::string>& importedLocations);
112 std::string InstallNameDir(cmGeneratorTarget const* target,
113 const std::string& config) override;
115 std::string GetFileSetDirectories(cmGeneratorTarget* gte, cmFileSet* fileSet,
116 cmTargetExport* te) override;
117 std::string GetFileSetFiles(cmGeneratorTarget* gte, cmFileSet* fileSet,
118 cmTargetExport* te) override;
120 std::string GetCxxModulesDirectory() const override;
121 void GenerateCxxModuleConfigInformation(std::ostream&) const override;
122 bool GenerateImportCxxModuleConfigTargetInclusion(std::string const&);
124 cmInstallExportGenerator* IEGen;
126 // The import file generated for each configuration.
127 std::map<std::string, std::string> ConfigImportFiles;
128 // The C++ module property file generated for each configuration.
129 std::map<std::string, std::string> ConfigCxxModuleFiles;
130 // The C++ module property target files generated for each configuration.
131 std::map<std::string, std::vector<std::string>> ConfigCxxModuleTargetFiles;