cmMarkAsAdvancedCommand.cxx 1.69 KB
Newer Older
1 2 3
/*============================================================================
  CMake - Cross Platform Makefile Generator
  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4

5 6
  Distributed under the OSI-approved BSD License (the "License");
  see accompanying file Copyright.txt for details.
7

8 9 10 11
  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.
============================================================================*/
12 13 14
#include "cmMarkAsAdvancedCommand.h"

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

24 25 26 27 28 29 30 31 32 33 34 35 36
  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)
37 38
    {
    std::string variable = args[i];
Stephen Kelly's avatar
Stephen Kelly committed
39 40
    cmState* state = this->Makefile->GetState();
    if (!state->GetCacheEntryValue(variable))
41
      {
42 43
      this->Makefile->GetCMakeInstance()->AddCacheEntry(
              variable, 0, 0, cmState::UNINITIALIZED);
44
      overwrite = true;
45
      }
Stephen Kelly's avatar
Stephen Kelly committed
46
    if (!state->GetCacheEntryValue(variable))
47 48 49 50
      {
      cmSystemTools::Error("This should never happen...");
      return false;
      }
Stephen Kelly's avatar
Stephen Kelly committed
51
    if (!state->GetCacheEntryProperty(variable, "ADVANCED") || overwrite)
52
      {
Stephen Kelly's avatar
Stephen Kelly committed
53
      state->SetCacheEntryProperty(variable, "ADVANCED", value);
54
      }
55 56 57 58
    }
  return true;
}