cmMarkAsAdvancedCommand.cxx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmMarkAsAdvancedCommand.h"
  11. // cmMarkAsAdvancedCommand
  12. bool cmMarkAsAdvancedCommand::InitialPass(std::vector<std::string> const& args,
  13. cmExecutionStatus&)
  14. {
  15. if (args.empty()) {
  16. this->SetError("called with incorrect number of arguments");
  17. return false;
  18. }
  19. unsigned int i = 0;
  20. const char* value = "1";
  21. bool overwrite = false;
  22. if (args[0] == "CLEAR" || args[0] == "FORCE") {
  23. overwrite = true;
  24. if (args[0] == "CLEAR") {
  25. value = "0";
  26. }
  27. i = 1;
  28. }
  29. for (; i < args.size(); ++i) {
  30. std::string variable = args[i];
  31. cmState* state = this->Makefile->GetState();
  32. if (!state->GetCacheEntryValue(variable)) {
  33. this->Makefile->GetCMakeInstance()->AddCacheEntry(
  34. variable, CM_NULLPTR, CM_NULLPTR, cmState::UNINITIALIZED);
  35. overwrite = true;
  36. }
  37. if (!state->GetCacheEntryValue(variable)) {
  38. cmSystemTools::Error("This should never happen...");
  39. return false;
  40. }
  41. if (!state->GetCacheEntryProperty(variable, "ADVANCED") || overwrite) {
  42. state->SetCacheEntryProperty(variable, "ADVANCED", value);
  43. }
  44. }
  45. return true;
  46. }