Coverage Report

Created: 2026-09-14 06:43

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmGetTargetPropertyCommand.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 "cmGetTargetPropertyCommand.h"
4
5
#include "cmExecutionStatus.h"
6
#include "cmMakefile.h"
7
#include "cmMessageType.h"
8
#include "cmStringAlgorithms.h"
9
#include "cmTargetPropertyHelper.h"
10
#include "cmValue.h"
11
12
bool cmGetTargetPropertyCommand(std::vector<std::string> const& args,
13
                                cmExecutionStatus& status)
14
0
{
15
0
  if (args.size() != 3) {
16
0
    status.SetError("called with incorrect number of arguments");
17
0
    return false;
18
0
  }
19
0
  std::string const& var = args[0];
20
0
  std::string const& targetName = args[1];
21
0
  std::string const& propertyName = args[2];
22
0
  cmMakefile& mf = status.GetMakefile();
23
24
0
  cmValue propValue;
25
0
  auto result = cmGetTargetProperty(targetName, propertyName, mf, propValue);
26
0
  if (result == cmGetTargetPropertyResult::Success) {
27
0
    if (propValue) {
28
0
      mf.AddDefinition(var, *propValue);
29
0
      return true;
30
0
    }
31
0
    mf.AddDefinition(var, var + "-NOTFOUND");
32
0
    return true;
33
0
  }
34
0
  if (result == cmGetTargetPropertyResult::TargetNotFound) {
35
0
    mf.IssueMessage(
36
0
      MessageType::FATAL_ERROR,
37
0
      cmStrCat("get_target_property() called with non-existent target \"",
38
0
               targetName, "\"."));
39
0
  }
40
0
  return false;
41
0
}