cmMarkAsAdvancedCommand.cxx 1.33 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
#include "cmMarkAsAdvancedCommand.h"

5 6 7
#include "cmState.h"
#include "cmSystemTools.h"

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

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