diff options
author | Matthew Woehlke <matthew.woehlke@kitware.com> | 2024-07-18 16:07:26 (GMT) |
---|---|---|
committer | Matthew Woehlke <matthew.woehlke@kitware.com> | 2024-07-23 16:13:39 (GMT) |
commit | 20fa4ce8d89369441dc4f8a74d62611e8dfa36ea (patch) | |
tree | 6c23718e1cb92ad7003f2157dd233bbc7333c5e6 /Source/cmExportBuildFileGenerator.h | |
parent | 6c66340a647fc7fa59e3f63e9344c05d3e760bfb (diff) | |
download | CMake-20fa4ce8d89369441dc4f8a74d62611e8dfa36ea.zip CMake-20fa4ce8d89369441dc4f8a74d62611e8dfa36ea.tar.gz CMake-20fa4ce8d89369441dc4f8a74d62611e8dfa36ea.tar.bz2 |
export: Factor out CMake-specific export generation (2/2)
In order to support generation of Common Package Specifications, the
mechanisms CMake uses to export package information need to be made more
abstract. The prior commits began this refactoring; this continues by
(actually) restructuring the classes used to generate the actual export files.
To minimize churn, this introduces virtual base classes and
diamond inheritance in order to separate logic which is format-agnostic
but depends on the export mode (build-tree versus install-tree) from
logic which is format-specific but mode-agnostic.
This could probably be refactored further to use helper classes instead,
and a future commit may do that, however an initial attempt to do that
was proving even more invasive, such that this approach was deemed more
manageable.
While we're at it, add 'const' in more places where possible.
Diffstat (limited to 'Source/cmExportBuildFileGenerator.h')
-rw-r--r-- | Source/cmExportBuildFileGenerator.h | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index 3c3d0b2..a4f8c5f 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -4,7 +4,7 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include <iosfwd> +#include <functional> #include <string> #include <utility> #include <vector> @@ -15,22 +15,19 @@ #include "cmStateTypes.h" class cmExportSet; -class cmFileSet; class cmGeneratorTarget; class cmGlobalGenerator; class cmLocalGenerator; -class cmTargetExport; -/** \class cmExportBuildFileGenerator +/** \class cmExportBuildCMakeConfigGenerator * \brief Generate a file exporting targets from a build tree. * - * cmExportBuildFileGenerator generates a file exporting targets from - * a build tree. A single file exports information for all - * configurations built. + * cmExportBuildCMakeConfigGenerator is the interface class for generating a + * file exporting targets from a build tree. * * This is used to implement the export() command. */ -class cmExportBuildFileGenerator : public cmExportFileGenerator +class cmExportBuildFileGenerator : virtual public cmExportFileGenerator { public: struct TargetExport @@ -69,25 +66,28 @@ public: return this->CxxModulesDirectory; } - /** Set whether to append generated code to the output file. */ - void SetAppendMode(bool append) { this->AppendMode = append; } - void Compute(cmLocalGenerator* lg); protected: - // Implement virtual methods from the superclass. - bool GenerateMainFile(std::ostream& os) override; - void GenerateImportTargetsConfig(std::ostream& os, std::string const& config, - std::string const& suffix) override; cmStateEnums::TargetType GetExportTargetType( cmGeneratorTarget const* target) const; + + /** Walk the list of targets to be exported. Returns true iff no duplicates + are found. */ + bool CollectExports(std::function<void(cmGeneratorTarget const*)> visitor); + void HandleMissingTarget(std::string& link_libs, cmGeneratorTarget const* depender, cmGeneratorTarget* dependee) override; - void ComplainAboutMissingTarget(cmGeneratorTarget const* depender, - cmGeneratorTarget const* dependee, - std::vector<std::string> const& namespaces); + void ComplainAboutMissingTarget( + cmGeneratorTarget const* depender, cmGeneratorTarget const* dependee, + std::vector<std::string> const& namespaces) const; + + void ComplainAboutDuplicateTarget( + std::string const& targetName) const override; + + void ReportError(std::string const& errorMessage) const override; /** Fill in properties indicating built file locations. */ void SetImportLocationProperty(std::string const& config, @@ -98,21 +98,20 @@ protected: std::string InstallNameDir(cmGeneratorTarget const* target, std::string const& config) override; - std::string GetFileSetDirectories(cmGeneratorTarget* gte, cmFileSet* fileSet, - cmTargetExport* te) override; - std::string GetFileSetFiles(cmGeneratorTarget* gte, cmFileSet* fileSet, - cmTargetExport* te) override; cmExportSet* GetExportSet() const override { return this->ExportSet; } - std::string GetCxxModulesDirectory() const override; - void GenerateCxxModuleConfigInformation(std::string const&, - std::ostream&) const override; - bool GenerateImportCxxModuleConfigTargetInclusion(std::string const&, - std::string) const; + std::string GetCxxModulesDirectory() const override + { + return this->CxxModulesDirectory; + } std::pair<std::vector<std::string>, std::string> FindBuildExportInfo( cmGlobalGenerator* gg, std::string const& name); + using cmExportFileGenerator::PopulateInterfaceProperties; + bool PopulateInterfaceProperties(cmGeneratorTarget const* target, + ImportPropertyMap& properties); + struct TargetExportPrivate { TargetExportPrivate(cmGeneratorTarget* target, |