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
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmRemoveCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
|
cmExecutionStatus&)
|
2002-04-22 19:50:43 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (args.size() < 1) {
|
2002-08-05 17:51:50 +04:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-04-22 19:50:43 +04:00
|
|
|
|
|
|
|
const char* variable = args[0].c_str(); // VAR is always first
|
|
|
|
// get the old value
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cacheValue = 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
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cacheValue) {
|
2002-08-05 17:51:50 +04:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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;
|
2014-11-22 13:00:45 +03:00
|
|
|
temp.insert(temp.end(), args.begin() + 1, args.end());
|
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;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (unsigned int j = 0; j < varArgsExpanded.size(); ++j) {
|
2002-04-22 19:50:43 +04:00
|
|
|
int found = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (unsigned int k = 0; k < argsExpanded.size(); ++k) {
|
|
|
|
if (varArgsExpanded[j] == argsExpanded[k]) {
|
2002-04-22 19:50:43 +04:00
|
|
|
found = 1;
|
|
|
|
break;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
if (!value.empty()) {
|
2002-04-22 19:50:43 +04:00
|
|
|
value += ";";
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
value += varArgsExpanded[j];
|
2002-04-22 19:50:43 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
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;
|
|
|
|
}
|