cmExportInstallPackageInfoGenerator.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file LICENSE.rst 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 <cm/optional>
  8. #include "cmExportInstallFileGenerator.h"
  9. #include "cmExportPackageInfoGenerator.h"
  10. class cmFileSet;
  11. class cmGeneratorTarget;
  12. class cmInstallExportGenerator;
  13. class cmPackageInfoArguments;
  14. class cmTargetExport;
  15. namespace Json {
  16. class Value;
  17. }
  18. /** \class cmExportInstallPackageInfoGenerator
  19. * \brief Generate files exporting targets from an install tree.
  20. *
  21. * cmExportInstallPackageInfoGenerator generates files exporting targets from
  22. * an installation tree. The files are placed in a temporary location for
  23. * installation by cmInstallExportGenerator. The file format is the Common
  24. * Package Specification (https://cps-org.github.io/cps/).
  25. *
  26. * One main file is generated that describes the imported targets. Additional,
  27. * per-configuration files describe target locations and settings for each
  28. * configuration.
  29. *
  30. * This is used to implement the INSTALL(PACKAGE_INFO) command.
  31. */
  32. class cmExportInstallPackageInfoGenerator
  33. : public cmExportPackageInfoGenerator
  34. , public cmExportInstallFileGenerator
  35. {
  36. public:
  37. /** Construct with the export installer that will install the
  38. files. */
  39. cmExportInstallPackageInfoGenerator(cmInstallExportGenerator* iegen,
  40. cmPackageInfoArguments arguments);
  41. /** Compute the globbing expression used to load per-config import
  42. files from the main file. */
  43. std::string GetConfigImportFileGlob() const override;
  44. protected:
  45. bool RequiresConfigFiles = false;
  46. std::string const& GetExportName() const override;
  47. // Implement virtual methods from the superclass.
  48. bool GenerateMainFile(std::ostream& os) override;
  49. void GenerateImportTargetsConfig(std::ostream& os, std::string const& config,
  50. std::string const& suffix) override;
  51. char GetConfigFileNameSeparator() const override { return '@'; }
  52. /** Generate the cps_path, which determines the import prefix. */
  53. std::string GenerateImportPrefix() const;
  54. std::string InstallNameDir(cmGeneratorTarget const* target,
  55. std::string const& config) override;
  56. std::string GetCxxModulesDirectory() const override;
  57. cm::optional<std::string> GetFileSetDirectory(
  58. cmGeneratorTarget* gte, cmTargetExport const* te, cmFileSet* fileSet,
  59. cm::optional<std::string> const& config = {});
  60. bool GenerateFileSetProperties(Json::Value& component,
  61. cmGeneratorTarget* gte,
  62. cmTargetExport const* te,
  63. std::string const& packagePath,
  64. cm::optional<std::string> config = {});
  65. };