Coverage Report

Created: 2026-02-09 06:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmRemoveCommand.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 "cmRemoveCommand.h"
4
5
#include "cmExecutionStatus.h"
6
#include "cmList.h"
7
#include "cmMakefile.h"
8
#include "cmValue.h"
9
10
// cmRemoveCommand
11
bool cmRemoveCommand(std::vector<std::string> const& args,
12
                     cmExecutionStatus& status)
13
0
{
14
0
  if (args.empty()) {
15
0
    return true;
16
0
  }
17
18
0
  std::string const& variable = args[0]; // VAR is always first
19
  // get the old value
20
0
  cmValue cacheValue = status.GetMakefile().GetDefinition(variable);
21
22
  // if there is no old value then return
23
0
  if (!cacheValue) {
24
0
    return true;
25
0
  }
26
27
  // expand the variable
28
0
  cmList const varArgsExpanded{ *cacheValue };
29
30
  // expand the args
31
  // check for REMOVE(VAR v1 v2 ... vn)
32
0
  cmList const argsExpanded{ args.begin() + 1, args.end() };
33
34
  // now create the new value
35
0
  std::string value;
36
0
  for (std::string const& varArgExpanded : varArgsExpanded) {
37
0
    int found = 0;
38
0
    for (std::string const& argExpanded : argsExpanded) {
39
0
      if (varArgExpanded == argExpanded) {
40
0
        found = 1;
41
0
        break;
42
0
      }
43
0
    }
44
0
    if (!found) {
45
0
      if (!value.empty()) {
46
0
        value += ";";
47
0
      }
48
0
      value += varArgExpanded;
49
0
    }
50
0
  }
51
52
  // add the definition
53
0
  status.GetMakefile().AddDefinition(variable, value);
54
55
0
  return true;
56
0
}