cmMarkAsAdvancedCommand.cxx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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
  13. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  14. {
  15. if(args.size() < 1 )
  16. {
  17. this->SetError("called with incorrect number of arguments");
  18. return false;
  19. }
  20. unsigned int i =0;
  21. const char* value = "1";
  22. bool overwrite = false;
  23. if(args[0] == "CLEAR" || args[0] == "FORCE")
  24. {
  25. overwrite = true;
  26. if(args[0] == "CLEAR")
  27. {
  28. value = "0";
  29. }
  30. i = 1;
  31. }
  32. for(; i < args.size(); ++i)
  33. {
  34. std::string variable = args[i];
  35. cmState* state = this->Makefile->GetState();
  36. if (!state->GetCacheEntryValue(variable))
  37. {
  38. state->AddCacheEntry(variable, 0, 0, cmCacheManager::UNINITIALIZED);
  39. overwrite = true;
  40. }
  41. if (!state->GetCacheEntryValue(variable))
  42. {
  43. cmSystemTools::Error("This should never happen...");
  44. return false;
  45. }
  46. if (!state->GetCacheEntryProperty(variable, "ADVANCED") || overwrite)
  47. {
  48. state->SetCacheEntryProperty(variable, "ADVANCED", value);
  49. }
  50. }
  51. return true;
  52. }