CMake/Source/cmRemoveCommand.cxx

77 lines
1.9 KiB
C++
Raw Normal View History

/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
2002-04-22 19:50:43 +04:00
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
2002-04-22 19:50:43 +04:00
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
2002-04-22 19:50:43 +04:00
#include "cmRemoveCommand.h"
// cmRemoveCommand
bool cmRemoveCommand
::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
2002-04-22 19:50:43 +04:00
{
2002-08-05 17:51:50 +04:00
if(args.size() < 1)
2002-04-22 19:50:43 +04:00
{
2002-08-05 17:51:50 +04:00
return true;
2002-04-22 19:50:43 +04:00
}
const char* variable = args[0].c_str(); // VAR is always first
// get the old value
const char* cacheValue
2006-03-15 19:02:08 +03:00
= this->Makefile->GetDefinition(variable);
2002-04-22 19:50:43 +04:00
2002-08-05 17:51:50 +04:00
// if there is no old value then return
if (!cacheValue)
{
return true;
}
2002-04-22 19:50:43 +04:00
// expand the variable
std::vector<std::string> varArgsExpanded;
cmSystemTools::ExpandListArgument(cacheValue, varArgsExpanded);
2002-04-22 19:50:43 +04:00
// expand the args
// check for REMOVE(VAR v1 v2 ... vn)
2002-04-22 19:50:43 +04:00
std::vector<std::string> argsExpanded;
std::vector<std::string> temp;
2002-04-22 19:50:43 +04:00
for(unsigned int j = 1; j < args.size(); ++j)
{
temp.push_back(args[j]);
2002-04-22 19:50:43 +04:00
}
cmSystemTools::ExpandList(temp, argsExpanded);
2002-04-22 19:50:43 +04:00
// now create the new value
std::string value;
2003-03-21 19:24:09 +03:00
for(unsigned int j = 0; j < varArgsExpanded.size(); ++j)
2002-04-22 19:50:43 +04:00
{
int found = 0;
2003-03-21 19:24:09 +03:00
for(unsigned int k = 0; k < argsExpanded.size(); ++k)
2002-04-22 19:50:43 +04:00
{
if (varArgsExpanded[j] == argsExpanded[k])
{
found = 1;
break;
}
}
if (!found)
{
if (value.size())
{
value += ";";
}
value += varArgsExpanded[j];
}
}
2002-04-22 19:50:43 +04:00
// add the definition
2006-03-15 19:02:08 +03:00
this->Makefile->AddDefinition(variable, value.c_str());
2002-04-22 19:50:43 +04:00
return true;
}