/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 "cmStateTypes.h" |
14 | | #include "cmTargetDepend.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 | | namespace { |
55 | | std::set<cmGeneratorTarget const*> const& GetTargetDependsClosure( |
56 | | std::map<cmGeneratorTarget const*, std::set<cmGeneratorTarget const*>>& |
57 | | targetDepends, |
58 | | cmGeneratorTarget const* tgt) |
59 | 0 | { |
60 | 0 | auto it = targetDepends.insert({ tgt, {} }); |
61 | 0 | auto& retval = it.first->second; |
62 | 0 | if (it.second) { |
63 | 0 | auto const& deps = tgt->GetGlobalGenerator()->GetTargetDirectDepends(tgt); |
64 | 0 | for (auto const& dep : deps) { |
65 | 0 | if (!dep.IsCross() && dep.IsLink()) { |
66 | 0 | auto type = dep->GetType(); |
67 | 0 | if (type == cmStateEnums::EXECUTABLE || |
68 | 0 | type == cmStateEnums::SHARED_LIBRARY || |
69 | 0 | type == cmStateEnums::MODULE_LIBRARY) { |
70 | 0 | retval.insert(dep); |
71 | 0 | } |
72 | 0 | auto const& depDeps = GetTargetDependsClosure(targetDepends, dep); |
73 | 0 | retval.insert(depDeps.begin(), depDeps.end()); |
74 | 0 | } |
75 | 0 | } |
76 | 0 | } |
77 | 0 | return retval; |
78 | 0 | } |
79 | | } |
80 | | |
81 | | void cmInstallRuntimeDependencySet::TargetItem::AddPostExcludeFiles( |
82 | | std::string const& config, std::set<std::string>& files, |
83 | | cmInstallRuntimeDependencySet* set) const |
84 | 0 | { |
85 | 0 | for (auto const* dep : GetTargetDependsClosure(set->TargetDepends, |
86 | 0 | this->Target->GetTarget())) { |
87 | 0 | files.insert(dep->GetFullPath(config)); |
88 | 0 | } |
89 | 0 | } |
90 | | |
91 | | std::string cmInstallRuntimeDependencySet::ImportedTargetItem::GetItemPath( |
92 | | std::string const& config) const |
93 | 0 | { |
94 | 0 | return this->Target->GetTarget()->GetFullPath(config); |
95 | 0 | } |