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
15 16
bool cmMarkAsAdvancedCommand::InitialPass(std::vector<std::string> const& args,
                                          cmExecutionStatus&)
17
{
18
  if (args.size() < 1) {
19 20
    this->SetError("called with incorrect number of arguments");
    return false;
21
  }
22

23
  unsigned int i = 0;
24 25
  const char* value = "1";
  bool overwrite = false;
26
  if (args[0] == "CLEAR" || args[0] == "FORCE") {
27
    overwrite = true;
28
    if (args[0] == "CLEAR") {
29 30
      value = "0";
    }
31 32 33
    i = 1;
  }
  for (; i < args.size(); ++i) {
34
    std::string variable = args[i];
Stephen Kelly's avatar
Stephen Kelly committed
35
    cmState* state = this->Makefile->GetState();
36
    if (!state->GetCacheEntryValue(variable)) {
37
      this->Makefile->GetCMakeInstance()->AddCacheEntry(
Daniel Pfeifer's avatar
Daniel Pfeifer committed
38
        variable, CM_NULLPTR, CM_NULLPTR, cmState::UNINITIALIZED);
39
      overwrite = true;
40 41
    }
    if (!state->GetCacheEntryValue(variable)) {
42 43
      cmSystemTools::Error("This should never happen...");
      return false;
44 45
    }
    if (!state->GetCacheEntryProperty(variable, "ADVANCED") || overwrite) {
Stephen Kelly's avatar
Stephen Kelly committed
46
      state->SetCacheEntryProperty(variable, "ADVANCED", value);
47
    }
48
  }
49 50
  return true;
}