1 /*=========================================================================
3 Program: Insight Segmentation & Registration Toolkit
4 Module: $RCSfile: cmRemoveCommand.cxx,v $
6 Date: $Date: 2002-04-22 15:50:43 $
7 Version: $Revision: 1.1 $
9 Copyright (c) 2002 Insight Consortium. All rights reserved.
10 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmRemoveCommand.h"
20 bool cmRemoveCommand::InitialPass(std::vector
<std::string
> const& args
)
24 this->SetError("called with incorrect number of arguments");
28 const char* variable
= args
[0].c_str(); // VAR is always first
30 const char* cacheValue
31 = m_Makefile
->GetDefinition(variable
);
33 // expand the variable
34 std::vector
<std::string
> varArgsExpanded
;
35 std::vector
<std::string
> temp
;
36 temp
.push_back(std::string(cacheValue
));
37 cmSystemTools::ExpandListArguments(temp
, varArgsExpanded
);
40 // check for REMOVE(VAR v1 v2 ... vn)
41 std::vector
<std::string
> argsExpanded
;
42 std::vector
<std::string
> temp2
;
43 for(unsigned int j
= 1; j
< args
.size(); ++j
)
45 temp2
.push_back(args
[j
]);
47 cmSystemTools::ExpandListArguments(temp2
, argsExpanded
);
49 // now create the new value
51 for(unsigned int j
= 1; j
< varArgsExpanded
.size(); ++j
)
54 for(unsigned int k
= 1; k
< argsExpanded
.size(); ++k
)
56 if (varArgsExpanded
[j
] == argsExpanded
[k
])
68 value
+= varArgsExpanded
[j
];
73 m_Makefile
->AddDefinition(variable
, value
.c_str());