2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2002-04-22 19:50:43 +04:00
|
|
|
|
2009-09-28 19:43:28 +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
|
|
|
|
2009-09-28 19:43:28 +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
|
2008-01-23 18:28:26 +03:00
|
|
|
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;
|
|
|
|
}
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2002-04-22 19:50:43 +04:00
|
|
|
// expand the variable
|
|
|
|
std::vector<std::string> varArgsExpanded;
|
2002-12-12 02:13:33 +03:00
|
|
|
cmSystemTools::ExpandListArgument(cacheValue, varArgsExpanded);
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2002-04-22 19:50:43 +04:00
|
|
|
// expand the args
|
2012-08-13 21:42:58 +04:00
|
|
|
// check for REMOVE(VAR v1 v2 ... vn)
|
2002-04-22 19:50:43 +04:00
|
|
|
std::vector<std::string> argsExpanded;
|
2002-12-12 02:13:33 +03:00
|
|
|
std::vector<std::string> temp;
|
2002-04-22 19:50:43 +04:00
|
|
|
for(unsigned int j = 1; j < args.size(); ++j)
|
|
|
|
{
|
2002-12-12 02:13:33 +03:00
|
|
|
temp.push_back(args[j]);
|
2002-04-22 19:50:43 +04:00
|
|
|
}
|
2002-12-12 02:13:33 +03:00
|
|
|
cmSystemTools::ExpandList(temp, argsExpanded);
|
2012-08-13 21:42:58 +04:00
|
|
|
|
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];
|
|
|
|
}
|
|
|
|
}
|
2012-08-13 21:42:58 +04:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|