Coverage Report

Created: 2026-10-28 06:38

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmInstallRuntimeDependencySet.cxx
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
#include "cmInstallRuntimeDependencySet.h"
4
5
#include <set>
6
#include <string>
7
#include <utility>
8
9
#include "cmGeneratorTarget.h"
10
#include "cmGlobalGenerator.h"
11
#include "cmInstallImportedRuntimeArtifactsGenerator.h"
12
#include "cmInstallTargetGenerator.h"
13
#include "cmTargetDepend.h"
14
#include "cmTargetTypes.h"
15
16
cmInstallRuntimeDependencySet::cmInstallRuntimeDependencySet(std::string name)
17
0
  : Name(std::move(name))
18
0
{
19
0
}
20
21
void cmInstallRuntimeDependencySet::AddExecutable(
22
  std::unique_ptr<Item> executable)
23
0
{
24
0
  this->Executables.push_back(std::move(executable));
25
0
}
26
27
void cmInstallRuntimeDependencySet::AddLibrary(std::unique_ptr<Item> library)
28
0
{
29
0
  this->Libraries.push_back(std::move(library));
30
0
}
31
32
void cmInstallRuntimeDependencySet::AddModule(std::unique_ptr<Item> module)
33
0
{
34
0
  this->Modules.push_back(std::move(module));
35
0
}
36
37
bool cmInstallRuntimeDependencySet::AddBundleExecutable(
38
  std::unique_ptr<Item> bundleExecutable)
39
0
{
40
0
  if (this->BundleExecutable) {
41
0
    return false;
42
0
  }
43
0
  this->BundleExecutable = bundleExecutable.get();
44
0
  this->AddExecutable(std::move(bundleExecutable));
45
0
  return true;
46
0
}
47
48
std::string cmInstallRuntimeDependencySet::TargetItem::GetItemPath(
49
  std::string const& config) const
50
0
{
51
0
  return this->Target->GetTarget()->GetFullPath(config);
52
0
}
53
54
cmGeneratorTarget const*
55
cmInstallRuntimeDependencySet::TargetItem::GetGeneratorTarget() const
56
0
{
57
0
  return this->Target->GetTarget();
58
0
}
59
60
void cmInstallRuntimeDependencySet::GetInstallBuildDependencies(
61
  std::vector<cmGeneratorTarget const*>& dependencies) const
62
0
{
63
0
  auto appendTargets =
64
0
    [&dependencies](std::vector<std::unique_ptr<Item>> const& items) {
65
0
      for (auto const& item : items) {
66
0
        if (cmGeneratorTarget const* target = item->GetGeneratorTarget()) {
67
0
          dependencies.push_back(target);
68
0
        }
69
0
      }
70
0
    };
71
0
  appendTargets(this->Executables);
72
0
  appendTargets(this->Libraries);
73
0
  appendTargets(this->Modules);
74
0
}
75
76
namespace {
77
std::set<cmGeneratorTarget const*> const& GetTargetDependsClosure(
78
  std::map<cmGeneratorTarget const*, std::set<cmGeneratorTarget const*>>&
79
    targetDepends,
80
  cmGeneratorTarget const* tgt)
81
0
{
82
0
  auto it = targetDepends.insert({ tgt, {} });
83
0
  auto& retval = it.first->second;
84
0
  if (it.second) {
85
0
    auto const& deps = tgt->GetGlobalGenerator()->GetTargetDirectDepends(tgt);
86
0
    for (auto const& dep : deps) {
87
0
      if (!dep.IsCross() && dep.IsLink()) {
88
0
        auto type = dep->GetType();
89
0
        if (type == cm::TargetType::EXECUTABLE ||
90
0
            type == cm::TargetType::SHARED_LIBRARY ||
91
0
            type == cm::TargetType::MODULE_LIBRARY) {
92
0
          retval.insert(dep);
93
0
        }
94
0
        auto const& depDeps = GetTargetDependsClosure(targetDepends, dep);
95
0
        retval.insert(depDeps.begin(), depDeps.end());
96
0
      }
97
0
    }
98
0
  }
99
0
  return retval;
100
0
}
101
}
102
103
void cmInstallRuntimeDependencySet::TargetItem::AddPostExcludeFiles(
104
  std::string const& config, std::set<std::string>& files,
105
  cmInstallRuntimeDependencySet* set) const
106
0
{
107
0
  for (auto const* dep : GetTargetDependsClosure(set->TargetDepends,
108
0
                                                 this->Target->GetTarget())) {
109
0
    files.insert(dep->GetFullPath(config));
110
0
  }
111
0
}
112
113
std::string cmInstallRuntimeDependencySet::ImportedTargetItem::GetItemPath(
114
  std::string const& config) const
115
0
{
116
0
  return this->Target->GetTarget()->GetFullPath(config);
117
0
}
118
119
cmGeneratorTarget const*
120
cmInstallRuntimeDependencySet::ImportedTargetItem::GetGeneratorTarget() const
121
0
{
122
0
  return this->Target->GetTarget();
123
0
}