cmMarkAsAdvancedCommand.cxx 1.84 KB
Newer Older
1 2
/*=========================================================================

3
  Program:   CMake - Cross-Platform Makefile Generator
4 5 6 7 8
  Module:    $RCSfile$
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

9 10
  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
11

Will Schroeder's avatar
Will Schroeder committed
12 13 14
     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.
15 16 17 18 19

=========================================================================*/
#include "cmMarkAsAdvancedCommand.h"

// cmMarkAsAdvancedCommand
Ken Martin's avatar
Ken Martin committed
20
bool cmMarkAsAdvancedCommand
21
::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
22
{
23
  if(args.size() < 1 )
24 25 26 27
    {
    this->SetError("called with incorrect number of arguments");
    return false;
    }
28

29 30 31 32 33 34 35 36 37 38 39 40 41
  unsigned int i =0;
  const char* value = "1";
  bool overwrite = false;
  if(args[0] == "CLEAR" || args[0] == "FORCE")
    {
    overwrite = true;
    if(args[0] == "CLEAR")
      {
      value = "0";
      }
    i = 1;
    }
  for(; i < args.size(); ++i)
42 43
    {
    std::string variable = args[i];
Ken Martin's avatar
Ken Martin committed
44
    cmCacheManager* manager = this->Makefile->GetCacheManager();
Ken Martin's avatar
Ken Martin committed
45 46
    cmCacheManager::CacheIterator it = 
      manager->GetCacheIterator(variable.c_str());
47
    if ( it.IsAtEnd() )
48
      {
49
      this->Makefile->GetCacheManager()
Brad King's avatar
Brad King committed
50 51
        ->AddCacheEntry(variable.c_str(), 0, 0,
          cmCacheManager::UNINITIALIZED);
52
      overwrite = true;
53
      }
54 55 56 57 58 59
    it.Find(variable.c_str());
    if ( it.IsAtEnd() )
      {
      cmSystemTools::Error("This should never happen...");
      return false;
      }
60
    if ( !it.PropertyExists("ADVANCED") || overwrite )
61 62 63
      {
      it.SetProperty("ADVANCED", value);
      }
64 65 66 67
    }
  return true;
}