cmMarkAsAdvancedCommand.cxx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmMarkAsAdvancedCommand.h"
  4. #include "cmState.h"
  5. #include "cmSystemTools.h"
  6. // cmMarkAsAdvancedCommand
  7. bool cmMarkAsAdvancedCommand::InitialPass(std::vector<std::string> const& args,
  8. cmExecutionStatus&)
  9. {
  10. if (args.empty()) {
  11. this->SetError("called with incorrect number of arguments");
  12. return false;
  13. }
  14. unsigned int i = 0;
  15. const char* value = "1";
  16. bool overwrite = false;
  17. if (args[0] == "CLEAR" || args[0] == "FORCE") {
  18. overwrite = true;
  19. if (args[0] == "CLEAR") {
  20. value = "0";
  21. }
  22. i = 1;
  23. }
  24. for (; i < args.size(); ++i) {
  25. std::string variable = args[i];
  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. cmSystemTools::Error("This should never happen...");
  34. return false;
  35. }
  36. if (!state->GetCacheEntryProperty(variable, "ADVANCED") || overwrite) {
  37. state->SetCacheEntryProperty(variable, "ADVANCED", value);
  38. }
  39. }
  40. return true;
  41. }