ENH: change the search path order (if several Tcl/Tk are installed, the "current...
[cmake.git] / Source / cmSourceFilesRemoveCommand.cxx
blobbad5fa6be4e4e67ed6afe6a87b26970cc0a634e5
1 /*=========================================================================
3 Program: Insight Segmentation & Registration Toolkit
4 Module: $RCSfile: cmSourceFilesRemoveCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2002-06-27 19:57:09 $
7 Version: $Revision: 1.9 $
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 "cmSourceFilesRemoveCommand.h"
19 // cmSourceFilesRemoveCommand
20 bool cmSourceFilesRemoveCommand::InitialPass(std::vector<std::string> const& args)
22 const char* versionValue
23 = m_Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
24 if (versionValue && atof(versionValue) > 1.2)
26 this->SetError("The SOURCE_FILES_REMOVE command has been deprecated in CMake version 1.4. You should use the REMOVE command instead.\n");
27 return false;
30 if(args.size() < 2 )
32 this->SetError("called with incorrect number of arguments");
33 return false;
36 const char* variable = args[0].c_str(); // VAR is always first
37 // get the old value
38 const char* cacheValue
39 = m_Makefile->GetDefinition(variable);
41 // expand the variable
42 std::vector<std::string> varArgsExpanded;
43 std::vector<std::string> temp;
44 temp.push_back(std::string(cacheValue));
45 cmSystemTools::ExpandListArguments(temp, varArgsExpanded);
47 // expand the args
48 // check for REMOVE(VAR v1 v2 ... vn)
49 std::vector<std::string> argsExpanded;
50 std::vector<std::string> temp2;
51 for(unsigned int j = 1; j < args.size(); ++j)
53 temp2.push_back(args[j]);
55 cmSystemTools::ExpandListArguments(temp2, argsExpanded);
57 // now create the new value
58 std::string value;
59 for(unsigned int j = 0; j < varArgsExpanded.size(); ++j)
61 int found = 0;
62 for(unsigned int k = 0; k < argsExpanded.size(); ++k)
64 if (varArgsExpanded[j] == argsExpanded[k])
66 found = 1;
67 break;
70 if (!found)
72 if (value.size())
74 value += ";";
76 value += varArgsExpanded[j];
80 // add the definition
81 m_Makefile->AddDefinition(variable, value.c_str());
83 return true;