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 "cmInstallExportGenerator.h"
16 #include "cmStateTypes.h"
20 class cmGeneratorTarget
;
21 class cmGlobalGenerator
;
22 class cmInstallTargetGenerator
;
25 /** \class cmExportInstallFileGenerator
26 * \brief Generate a file exporting targets from an install tree.
28 * cmExportInstallFileGenerator generates files exporting targets from
29 * install an installation tree. The files are placed in a temporary
30 * location for installation by cmInstallExportGenerator. One main
31 * file is generated that creates the imported targets and loads
32 * per-configuration files. Target locations and settings for each
33 * configuration are written to these per-configuration files. After
34 * installation the main file loads the configurations that have been
37 * This is used to implement the INSTALL(EXPORT) command.
39 class cmExportInstallFileGenerator
: public cmExportFileGenerator
42 /** Construct with the export installer that will install the
44 cmExportInstallFileGenerator(cmInstallExportGenerator
* iegen
);
46 /** Get the per-config file generated for each configuration. This
47 maps from the configuration name to the file temporary location
49 std::map
<std::string
, std::string
> const& GetConfigImportFiles()
51 return this->ConfigImportFiles
;
54 /** Get the per-config C++ module file generated for each configuration.
55 This maps from the configuration name to the file temporary location
57 std::map
<std::string
, std::string
> const& GetConfigCxxModuleFiles()
59 return this->ConfigCxxModuleFiles
;
62 /** Get the per-config C++ module file generated for each configuration.
63 This maps from the configuration name to the file temporary location
64 for installation for each target in the export set. */
65 std::map
<std::string
, std::vector
<std::string
>> const&
66 GetConfigCxxModuleTargetFiles()
68 return this->ConfigCxxModuleTargetFiles
;
71 /** Compute the globbing expression used to load per-config import
72 files from the main file. */
73 std::string
GetConfigImportFileGlob();
76 // Implement virtual methods from the superclass.
77 bool GenerateMainFile(std::ostream
& os
) override
;
78 void GenerateImportTargetsConfig(std::ostream
& os
, const std::string
& config
,
79 std::string
const& suffix
) override
;
80 cmStateEnums::TargetType
GetExportTargetType(
81 cmTargetExport
const* targetExport
) const;
82 void HandleMissingTarget(std::string
& link_libs
,
83 cmGeneratorTarget
const* depender
,
84 cmGeneratorTarget
* dependee
) override
;
86 void ReplaceInstallPrefix(std::string
& input
) override
;
88 void ComplainAboutMissingTarget(cmGeneratorTarget
const* depender
,
89 cmGeneratorTarget
const* dependee
,
90 std::vector
<std::string
> const& exportFiles
);
92 std::pair
<std::vector
<std::string
>, std::string
> FindNamespaces(
93 cmGlobalGenerator
* gg
, const std::string
& name
);
95 /** Generate the relative import prefix. */
96 virtual void GenerateImportPrefix(std::ostream
&);
98 /** Generate the relative import prefix. */
99 virtual void LoadConfigFiles(std::ostream
&);
101 virtual void CleanupTemporaryVariables(std::ostream
&);
103 /** Generate a per-configuration file for the targets. */
104 virtual bool GenerateImportFileConfig(const std::string
& config
);
106 /** Fill in properties indicating installed file locations. */
107 void SetImportLocationProperty(const std::string
& config
,
108 std::string
const& suffix
,
109 cmInstallTargetGenerator
* itgen
,
110 ImportPropertyMap
& properties
,
111 std::set
<std::string
>& importedLocations
);
113 std::string
InstallNameDir(cmGeneratorTarget
const* target
,
114 const std::string
& config
) override
;
116 std::string
GetFileSetDirectories(cmGeneratorTarget
* gte
, cmFileSet
* fileSet
,
117 cmTargetExport
* te
) override
;
118 std::string
GetFileSetFiles(cmGeneratorTarget
* gte
, cmFileSet
* fileSet
,
119 cmTargetExport
* te
) override
;
121 std::string
GetCxxModulesDirectory() const override
;
122 void GenerateCxxModuleConfigInformation(std::string
const&,
123 std::ostream
&) const override
;
124 bool GenerateImportCxxModuleConfigTargetInclusion(std::string
const&,
127 cmExportSet
* GetExportSet() const override
129 return this->IEGen
->GetExportSet();
132 cmInstallExportGenerator
* IEGen
;
134 // The import file generated for each configuration.
135 std::map
<std::string
, std::string
> ConfigImportFiles
;
136 // The C++ module property file generated for each configuration.
137 std::map
<std::string
, std::string
> ConfigCxxModuleFiles
;
138 // The C++ module property target files generated for each configuration.
139 std::map
<std::string
, std::vector
<std::string
>> ConfigCxxModuleTargetFiles
;