Coverage Report

Created: 2026-07-30 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmInstallTargetsCommand.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 "cmInstallTargetsCommand.h"
4
5
#include <unordered_map>
6
#include <utility>
7
8
#include "cmDiagnostics.h"
9
#include "cmExecutionStatus.h"
10
#include "cmGlobalGenerator.h"
11
#include "cmMakefile.h"
12
#include "cmTarget.h"
13
14
bool cmInstallTargetsCommand(std::vector<std::string> const& args,
15
                             cmExecutionStatus& status)
16
0
{
17
0
  cmMakefile& mf = status.GetMakefile();
18
19
0
  mf.IssueDiagnostic(cmDiagnostics::CMD_DEPRECATED,
20
0
                     "The 'install_targets' command has been superseded. "
21
0
                     "Use 'install(TARGETS)' instead.");
22
23
0
  if (args.size() < 2) {
24
0
    status.SetError("called with incorrect number of arguments");
25
0
    return false;
26
0
  }
27
28
  // Enable the install target.
29
0
  mf.GetGlobalGenerator()->EnableInstallTarget();
30
31
0
  cmMakefile::cmTargetMap& tgts = mf.GetTargets();
32
0
  auto s = args.begin();
33
0
  ++s;
34
0
  std::string runtimeDir = "/bin";
35
0
  for (; s != args.end(); ++s) {
36
0
    if (*s == "RUNTIME_DIRECTORY") {
37
0
      ++s;
38
0
      if (s == args.end()) {
39
0
        status.SetError("called with RUNTIME_DIRECTORY but no actual "
40
0
                        "directory");
41
0
        return false;
42
0
      }
43
44
0
      runtimeDir = *s;
45
0
    } else {
46
0
      auto ti = tgts.find(*s);
47
0
      if (ti != tgts.end()) {
48
0
        ti->second.SetInstallPath(args[0]);
49
0
        ti->second.SetRuntimeInstallPath(runtimeDir);
50
0
        ti->second.SetHaveInstallRule(true);
51
0
      } else {
52
0
        std::string str = "Cannot find target: \"" + *s + "\" to install.";
53
0
        status.SetError(str);
54
0
        return false;
55
0
      }
56
0
    }
57
0
  }
58
59
0
  mf.GetGlobalGenerator()->AddInstallComponent(
60
0
    mf.GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
61
62
0
  return true;
63
0
}