cmMarkAsAdvancedCommand.cxx 1.42 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
#include "cmMakefile.h"
6
#include "cmState.h"
7
#include "cmStateTypes.h"
8
#include "cmSystemTools.h"
9 10 11
#include "cmake.h"

class cmExecutionStatus;
12

13
// cmMarkAsAdvancedCommand
14 15
bool cmMarkAsAdvancedCommand::InitialPass(std::vector<std::string> const& args,
                                          cmExecutionStatus&)
16
{
17
  if (args.empty()) {
18 19
    this->SetError("called with incorrect number of arguments");
    return false;
20
  }
21

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