1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
3 #include "cmRemoveCommand.h"
5 #include "cmExecutionStatus.h"
6 #include "cmMakefile.h"
7 #include "cmStringAlgorithms.h"
11 bool cmRemoveCommand(std::vector<std::string> const& args,
12 cmExecutionStatus& status)
18 std::string const& variable = args[0]; // VAR is always first
20 cmValue cacheValue = status.GetMakefile().GetDefinition(variable);
22 // if there is no old value then return
27 // expand the variable
28 std::vector<std::string> const varArgsExpanded = cmExpandedList(*cacheValue);
31 // check for REMOVE(VAR v1 v2 ... vn)
32 std::vector<std::string> const argsExpanded =
33 cmExpandedLists(args.begin() + 1, args.end());
35 // now create the new value
37 for (std::string const& varArgExpanded : varArgsExpanded) {
39 for (std::string const& argExpanded : argsExpanded) {
40 if (varArgExpanded == argExpanded) {
49 value += varArgExpanded;
54 status.GetMakefile().AddDefinition(variable, value);