1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
12 #include "cmUnsetCommand.h"
15 bool cmUnsetCommand::InitialPass(std::vector<std::string> const& args,
18 if(args.size() < 1 || args.size() > 2)
20 this->SetError("called with incorrect number of arguments");
24 const char* variable = args[0].c_str();
27 if (!strncmp(variable,"ENV{",4) && strlen(variable) > 5)
29 // what is the variable name
30 char *envVarName = new char [strlen(variable)];
31 strncpy(envVarName,variable+4,strlen(variable)-5);
32 envVarName[strlen(variable)-5] = '\0';
34 #ifdef CMAKE_BUILD_WITH_CMAKE
35 cmSystemTools::UnsetEnv(envVarName);
41 else if (args.size() == 1)
43 this->Makefile->RemoveDefinition(variable);
47 else if ((args.size() == 2) && (args[1] == "CACHE"))
49 this->Makefile->RemoveCacheDefinition(variable);
52 // ERROR: second argument isn't CACHE
55 this->SetError("called with an invalid second argument");