cmExportInstallPackageInfoGenerator.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include "cmConfigure.h" // IWYU pragma: keep
  5. #include <iosfwd>
  6. #include <string>
  7. #include <vector>
  8. #include "cmExportInstallFileGenerator.h"
  9. #include "cmExportPackageInfoGenerator.h"
  10. class cmGeneratorTarget;
  11. class cmInstallExportGenerator;
  12. /** \class cmExportInstallPackageInfoGenerator
  13. * \brief Generate files exporting targets from an install tree.
  14. *
  15. * cmExportInstallPackageInfoGenerator generates files exporting targets from
  16. * an installation tree. The files are placed in a temporary location for
  17. * installation by cmInstallExportGenerator. The file format is the Common
  18. * Package Specification (https://cps-org.github.io/cps/).
  19. *
  20. * One main file is generated that describes the imported targets. Additional,
  21. * per-configuration files describe target locations and settings for each
  22. * configuration.
  23. *
  24. * This is used to implement the INSTALL(PACKAGE_INFO) command.
  25. */
  26. class cmExportInstallPackageInfoGenerator
  27. : public cmExportPackageInfoGenerator
  28. , public cmExportInstallFileGenerator
  29. {
  30. public:
  31. /** Construct with the export installer that will install the
  32. files. */
  33. cmExportInstallPackageInfoGenerator(
  34. cmInstallExportGenerator* iegen, std::string packageName,
  35. std::string version, std::string versionCompat, std::string versionSchema,
  36. std::vector<std::string> defaultTargets,
  37. std::vector<std::string> defaultConfigurations);
  38. /** Compute the globbing expression used to load per-config import
  39. files from the main file. */
  40. std::string GetConfigImportFileGlob() const override;
  41. protected:
  42. std::string const& GetExportName() const override;
  43. // Implement virtual methods from the superclass.
  44. bool GenerateMainFile(std::ostream& os) override;
  45. void GenerateImportTargetsConfig(std::ostream& os, std::string const& config,
  46. std::string const& suffix) override;
  47. char GetConfigFileNameSeparator() const override { return '@'; }
  48. /** Generate the cps_path, which determines the import prefix. */
  49. std::string GenerateImportPrefix() const;
  50. std::string InstallNameDir(cmGeneratorTarget const* target,
  51. std::string const& config) override;
  52. std::string GetCxxModulesDirectory() const override;
  53. // TODO: Generate C++ module info in a not-CMake-specific format.
  54. };