cmMarkAsAdvancedCommand.cxx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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::InitialPass(std::vector<std::string> const& args)
  16. {
  17. if(args.size() < 1 )
  18. {
  19. this->SetError("called with incorrect number of arguments");
  20. return false;
  21. }
  22. unsigned int i =0;
  23. const char* value = "1";
  24. bool overwrite = false;
  25. if(args[0] == "CLEAR" || args[0] == "FORCE")
  26. {
  27. overwrite = true;
  28. if(args[0] == "CLEAR")
  29. {
  30. value = "0";
  31. }
  32. i = 1;
  33. }
  34. for(; i < args.size(); ++i)
  35. {
  36. std::string variable = args[i];
  37. cmCacheManager* manager = m_Makefile->GetCacheManager();
  38. cmCacheManager::CacheIterator it = manager->GetCacheIterator(variable.c_str());
  39. if ( it.IsAtEnd() )
  40. {
  41. m_Makefile->AddCacheDefinition(variable.c_str(), 0, 0,
  42. cmCacheManager::UNINITIALIZED);
  43. overwrite = true;
  44. }
  45. it.Find(variable.c_str());
  46. if ( it.IsAtEnd() )
  47. {
  48. cmSystemTools::Error("This should never happen...");
  49. return false;
  50. }
  51. if ( !it.PropertyExists("ADVANCED") || overwrite )
  52. {
  53. it.SetProperty("ADVANCED", value);
  54. }
  55. }
  56. return true;
  57. }