mirror of
https://github.com/Kitware/CMake.git
synced 2025-05-10 07:10:32 +08:00

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.
53 lines
1.9 KiB
C++
53 lines
1.9 KiB
C++
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
|
#pragma once
|
|
|
|
#include "cmConfigure.h" // IWYU pragma: keep
|
|
|
|
#include <iosfwd>
|
|
#include <string>
|
|
|
|
#include "cmExportBuildFileGenerator.h"
|
|
#include "cmExportCMakeConfigGenerator.h"
|
|
|
|
class cmFileSet;
|
|
class cmGeneratorTarget;
|
|
class cmTargetExport;
|
|
|
|
/** \class cmExportBuildCMakeConfigGenerator
|
|
* \brief Generate a file exporting targets from a build tree.
|
|
*
|
|
* cmExportBuildCMakeConfigGenerator generates a file exporting targets from
|
|
* a build tree. This exports the targets to CMake's native package
|
|
* configuration format. A single file exports information for all
|
|
* configurations built.
|
|
*
|
|
* This is used to implement the export() command.
|
|
*/
|
|
class cmExportBuildCMakeConfigGenerator
|
|
: public cmExportCMakeConfigGenerator
|
|
, public cmExportBuildFileGenerator
|
|
{
|
|
public:
|
|
cmExportBuildCMakeConfigGenerator();
|
|
|
|
/** Set whether to append generated code to the output file. */
|
|
void SetAppendMode(bool append) { this->AppendMode = append; }
|
|
|
|
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;
|
|
|
|
std::string GetFileSetDirectories(cmGeneratorTarget* gte, cmFileSet* fileSet,
|
|
cmTargetExport const* te) override;
|
|
std::string GetFileSetFiles(cmGeneratorTarget* gte, cmFileSet* fileSet,
|
|
cmTargetExport const* te) override;
|
|
|
|
void GenerateCxxModuleConfigInformation(std::string const&,
|
|
std::ostream&) const override;
|
|
bool GenerateImportCxxModuleConfigTargetInclusion(std::string const&,
|
|
std::string) const;
|
|
};
|