Coverage Report

Created: 2026-02-09 06:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmExportInstallPackageInfoGenerator.h
Line
Count
Source
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
5
#include "cmConfigure.h" // IWYU pragma: keep
6
7
#include <iosfwd>
8
#include <string>
9
10
#include <cm/optional>
11
12
#include "cmExportInstallFileGenerator.h"
13
#include "cmExportPackageInfoGenerator.h"
14
15
class cmFileSet;
16
class cmGeneratorTarget;
17
class cmInstallExportGenerator;
18
class cmPackageInfoArguments;
19
class cmTargetExport;
20
21
namespace Json {
22
class Value;
23
}
24
25
/** \class cmExportInstallPackageInfoGenerator
26
 * \brief Generate files exporting targets from an install tree.
27
 *
28
 * cmExportInstallPackageInfoGenerator generates files exporting targets from
29
 * an installation tree.  The files are placed in a temporary location for
30
 * installation by cmInstallExportGenerator.  The file format is the Common
31
 * Package Specification (https://cps-org.github.io/cps/).
32
 *
33
 * One main file is generated that describes the imported targets.  Additional,
34
 * per-configuration files describe target locations and settings for each
35
 * configuration.
36
 *
37
 * This is used to implement the INSTALL(PACKAGE_INFO) command.
38
 */
39
class cmExportInstallPackageInfoGenerator
40
  : public cmExportPackageInfoGenerator
41
  , public cmExportInstallFileGenerator
42
{
43
public:
44
  /** Construct with the export installer that will install the
45
      files.  */
46
  cmExportInstallPackageInfoGenerator(cmInstallExportGenerator* iegen,
47
                                      cmPackageInfoArguments arguments);
48
49
  /** Compute the globbing expression used to load per-config import
50
      files from the main file.  */
51
  std::string GetConfigImportFileGlob() const override;
52
53
protected:
54
  bool RequiresConfigFiles = false;
55
56
  std::string const& GetExportName() const override;
57
58
  // Implement virtual methods from the superclass.
59
  bool GenerateMainFile(std::ostream& os) override;
60
  void GenerateImportTargetsConfig(std::ostream& os, std::string const& config,
61
                                   std::string const& suffix) override;
62
63
0
  char GetConfigFileNameSeparator() const override { return '@'; }
64
65
  /** Generate the cps_path, which determines the import prefix.  */
66
  std::string GenerateImportPrefix() const;
67
68
  std::string InstallNameDir(cmGeneratorTarget const* target,
69
                             std::string const& config) override;
70
71
  std::string GetCxxModulesDirectory() const override;
72
73
  cm::optional<std::string> GetFileSetDirectory(
74
    cmGeneratorTarget* gte, cmTargetExport const* te, cmFileSet* fileSet,
75
    cm::optional<std::string> const& config = {});
76
77
  bool GenerateFileSetProperties(Json::Value& component,
78
                                 cmGeneratorTarget* gte,
79
                                 cmTargetExport const* te,
80
                                 std::string const& packagePath,
81
                                 cm::optional<std::string> config = {});
82
};