cmake/Source/cmMarkAsAdvancedCommand.cxx

50 lines
1.4 KiB
C++
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMarkAsAdvancedCommand.h"
2017-04-14 19:02:05 +02:00
#include "cmMakefile.h"
#include "cmState.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
#include "cmake.h"
class cmExecutionStatus;
// cmMarkAsAdvancedCommand
2016-07-09 11:21:54 +02:00
bool cmMarkAsAdvancedCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus&)
{
2016-10-30 18:24:19 +01:00
if (args.empty()) {
this->SetError("called with incorrect number of arguments");
return false;
2016-07-09 11:21:54 +02:00
}
2016-07-09 11:21:54 +02:00
unsigned int i = 0;
const char* value = "1";
bool overwrite = false;
2016-07-09 11:21:54 +02:00
if (args[0] == "CLEAR" || args[0] == "FORCE") {
overwrite = true;
2016-07-09 11:21:54 +02:00
if (args[0] == "CLEAR") {
value = "0";
}
2016-07-09 11:21:54 +02:00
i = 1;
}
for (; i < args.size(); ++i) {
2017-07-20 19:35:53 +02:00
std::string const& variable = args[i];
2015-08-17 11:37:30 +02:00
cmState* state = this->Makefile->GetState();
2016-07-09 11:21:54 +02:00
if (!state->GetCacheEntryValue(variable)) {
2016-03-13 13:35:51 +01:00
this->Makefile->GetCMakeInstance()->AddCacheEntry(
2017-04-14 19:02:05 +02:00
variable, CM_NULLPTR, CM_NULLPTR, cmStateEnums::UNINITIALIZED);
overwrite = true;
2016-07-09 11:21:54 +02:00
}
if (!state->GetCacheEntryValue(variable)) {
cmSystemTools::Error("This should never happen...");
return false;
2016-07-09 11:21:54 +02:00
}
if (!state->GetCacheEntryProperty(variable, "ADVANCED") || overwrite) {
2015-08-17 11:37:30 +02:00
state->SetCacheEntryProperty(variable, "ADVANCED", value);
}
2016-07-09 11:21:54 +02:00
}
return true;
}