cmMarkAsAdvancedCommand.cxx 1.28 KB
Newer Older
1 2
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing for details.  */
3 4 5
#include "cmMarkAsAdvancedCommand.h"

// cmMarkAsAdvancedCommand
6 7
bool cmMarkAsAdvancedCommand::InitialPass(std::vector<std::string> const& args,
                                          cmExecutionStatus&)
8
{
9
  if (args.empty()) {
10 11
    this->SetError("called with incorrect number of arguments");
    return false;
12
  }
13

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