FIX: stupid pb fixed (close to being medieval'ed by The Ken)
[cmake.git] / Source / cmRemoveCommand.cxx
blob8f64d95b520bee29404ddbeabd07ab8d7e28a5f2
1 /*=========================================================================
3 Program: Insight Segmentation & Registration Toolkit
4 Module: $RCSfile: cmRemoveCommand.cxx,v $
5 Language: C++
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"
19 // cmRemoveCommand
20 bool cmRemoveCommand::InitialPass(std::vector<std::string> const& args)
22 if(args.size() < 2 )
24 this->SetError("called with incorrect number of arguments");
25 return false;
28 const char* variable = args[0].c_str(); // VAR is always first
29 // get the old value
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);
39 // expand the args
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
50 std::string value;
51 for(unsigned int j = 1; j < varArgsExpanded.size(); ++j)
53 int found = 0;
54 for(unsigned int k = 1; k < argsExpanded.size(); ++k)
56 if (varArgsExpanded[j] == argsExpanded[k])
58 found = 1;
59 break;
62 if (!found)
64 if (value.size())
66 value += ";";
68 value += varArgsExpanded[j];
72 // add the definition
73 m_Makefile->AddDefinition(variable, value.c_str());
75 return true;