KWSys Nightly Date Stamp
[cmake.git] / Source / cmRemoveCommand.cxx
blob0d5d09f6627f5e53d6adfc1d50b217154b613eaa
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmRemoveCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2008-01-23 15:27:59 $
7 Version: $Revision: 1.7 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html 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
21 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
23 if(args.size() < 1)
25 return true;
28 const char* variable = args[0].c_str(); // VAR is always first
29 // get the old value
30 const char* cacheValue
31 = this->Makefile->GetDefinition(variable);
33 // if there is no old value then return
34 if (!cacheValue)
36 return true;
39 // expand the variable
40 std::vector<std::string> varArgsExpanded;
41 cmSystemTools::ExpandListArgument(cacheValue, varArgsExpanded);
43 // expand the args
44 // check for REMOVE(VAR v1 v2 ... vn)
45 std::vector<std::string> argsExpanded;
46 std::vector<std::string> temp;
47 for(unsigned int j = 1; j < args.size(); ++j)
49 temp.push_back(args[j]);
51 cmSystemTools::ExpandList(temp, argsExpanded);
53 // now create the new value
54 std::string value;
55 for(unsigned int j = 0; j < varArgsExpanded.size(); ++j)
57 int found = 0;
58 for(unsigned int k = 0; k < argsExpanded.size(); ++k)
60 if (varArgsExpanded[j] == argsExpanded[k])
62 found = 1;
63 break;
66 if (!found)
68 if (value.size())
70 value += ";";
72 value += varArgsExpanded[j];
76 // add the definition
77 this->Makefile->AddDefinition(variable, value.c_str());
79 return true;