Coverage Report

Created: 2026-07-14 07:09

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmAddDependenciesCommand.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 "cmAddDependenciesCommand.h"
4
5
#include "cmExecutionStatus.h"
6
#include "cmMakefile.h"
7
#include "cmMessageType.h"
8
#include "cmRange.h"
9
#include "cmStringAlgorithms.h"
10
#include "cmTarget.h"
11
12
bool cmAddDependenciesCommand(std::vector<std::string> const& args,
13
                              cmExecutionStatus& status)
14
0
{
15
0
  if (args.empty()) {
16
0
    status.SetError("called with incorrect number of arguments");
17
0
    return false;
18
0
  }
19
20
0
  cmMakefile& mf = status.GetMakefile();
21
0
  std::string const& target_name = args[0];
22
0
  if (cmTarget* target = mf.FindTargetToUse(target_name)) {
23
24
    // skip over target_name
25
0
    for (std::string const& arg : cmMakeRange(args).advance(1)) {
26
0
      target->AddUtility(arg, false, &mf);
27
0
      target->AddCodegenDependency(arg);
28
0
    }
29
0
  } else {
30
0
    mf.IssueMessage(
31
0
      MessageType::FATAL_ERROR,
32
0
      cmStrCat(
33
0
        "Cannot add target-level dependencies to non-existent "
34
0
        "target \"",
35
0
        target_name,
36
0
        "\".\nThe add_dependencies works for "
37
0
        "top-level logical targets created by the add_executable, "
38
0
        "add_library, or add_custom_target commands.  If you want to add "
39
0
        "file-level dependencies see the DEPENDS option of the "
40
0
        "add_custom_target and add_custom_command commands."));
41
0
  }
42
43
0
  return true;
44
0
}