cmMarkAsAdvancedCommand.cxx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmMarkAsAdvancedCommand.h"
  14. // cmMarkAsAdvancedCommand
  15. bool cmMarkAsAdvancedCommand
  16. ::InitialPass(std::vector<std::string> const& args)
  17. {
  18. if(args.size() < 1 )
  19. {
  20. this->SetError("called with incorrect number of arguments");
  21. return false;
  22. }
  23. unsigned int i =0;
  24. const char* value = "1";
  25. bool overwrite = false;
  26. if(args[0] == "CLEAR" || args[0] == "FORCE")
  27. {
  28. overwrite = true;
  29. if(args[0] == "CLEAR")
  30. {
  31. value = "0";
  32. }
  33. i = 1;
  34. }
  35. for(; i < args.size(); ++i)
  36. {
  37. std::string variable = args[i];
  38. cmCacheManager* manager = this->Makefile->GetCacheManager();
  39. cmCacheManager::CacheIterator it =
  40. manager->GetCacheIterator(variable.c_str());
  41. if ( it.IsAtEnd() )
  42. {
  43. this->Makefile->AddCacheDefinition(variable.c_str(), 0, 0,
  44. cmCacheManager::UNINITIALIZED);
  45. overwrite = true;
  46. }
  47. it.Find(variable.c_str());
  48. if ( it.IsAtEnd() )
  49. {
  50. cmSystemTools::Error("This should never happen...");
  51. return false;
  52. }
  53. if ( !it.PropertyExists("ADVANCED") || overwrite )
  54. {
  55. it.SetProperty("ADVANCED", value);
  56. }
  57. }
  58. return true;
  59. }