Imported Upstream version 2.8.9
[platform/upstream/cmake.git] / Source / cmMarkAsAdvancedCommand.cxx
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
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 "cmMarkAsAdvancedCommand.h"
13
14 // cmMarkAsAdvancedCommand
15 bool cmMarkAsAdvancedCommand
16 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
17 {
18   if(args.size() < 1 )
19     {
20     this->SetError("called with incorrect number of arguments");
21     return false;
22     }
23
24   unsigned int i =0;
25   const char* value = "1";
26   bool overwrite = false;
27   if(args[0] == "CLEAR" || args[0] == "FORCE")
28     {
29     overwrite = true;
30     if(args[0] == "CLEAR")
31       {
32       value = "0";
33       }
34     i = 1;
35     }
36   for(; i < args.size(); ++i)
37     {
38     std::string variable = args[i];
39     cmCacheManager* manager = this->Makefile->GetCacheManager();
40     cmCacheManager::CacheIterator it = 
41       manager->GetCacheIterator(variable.c_str());
42     if ( it.IsAtEnd() )
43       {
44       this->Makefile->GetCacheManager()
45         ->AddCacheEntry(variable.c_str(), 0, 0,
46           cmCacheManager::UNINITIALIZED);
47       overwrite = true;
48       }
49     it.Find(variable.c_str());
50     if ( it.IsAtEnd() )
51       {
52       cmSystemTools::Error("This should never happen...");
53       return false;
54       }
55     if ( !it.PropertyExists("ADVANCED") || overwrite )
56       {
57       it.SetProperty("ADVANCED", value);
58       }
59     }
60   return true;
61 }
62