1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmUnsetCommand.cxx,v $
6 Date: $Date: 2008-08-25 14:31:28 $
7 Version: $Revision: 1.1 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html 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 "cmUnsetCommand.h"
20 bool cmUnsetCommand::InitialPass(std::vector
<std::string
> const& args
,
23 if(args
.size() < 1 || args
.size() > 2)
25 this->SetError("called with incorrect number of arguments");
29 const char* variable
= args
[0].c_str();
32 if (!strncmp(variable
,"ENV{",4) && strlen(variable
) > 5)
34 // what is the variable name
35 char *envVarName
= new char [strlen(variable
)];
36 strncpy(envVarName
,variable
+4,strlen(variable
)-5);
37 envVarName
[strlen(variable
)-5] = '\0';
39 #ifdef CMAKE_BUILD_WITH_CMAKE
40 cmSystemTools::UnsetEnv(envVarName
);
46 else if (args
.size() == 1)
48 this->Makefile
->RemoveDefinition(variable
);
52 else if ((args
.size() == 2) && (args
[1] == "CACHE"))
54 this->Makefile
->RemoveCacheDefinition(variable
);
57 // ERROR: second argument isn't CACHE
60 this->SetError("called with an invalid second argument");