cmMarkAsAdvancedCommand.cxx 1.9 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::InitialPass(std::vector<std::string> const& argsIn)
  16. {
  17. if(argsIn.size() < 1 )
  18. {
  19. this->SetError("called with incorrect number of arguments");
  20. return false;
  21. }
  22. std::vector<std::string> args;
  23. cmSystemTools::ExpandListArguments(argsIn, args);
  24. unsigned int i =0;
  25. const char* value = "1";
  26. bool overwrite = false;
  27. if(args[0] == "CLEAR" || args[0] == "FORCE")
  28. {
  29. overwrite = true;
  30. if(args[0] == "CLEAR")
  31. {
  32. value = "0";
  33. }
  34. i = 1;
  35. }
  36. for(; i < args.size(); ++i)
  37. {
  38. std::string variable = args[i];
  39. cmCacheManager* manager = m_Makefile->GetCacheManager();
  40. cmCacheManager::CacheIterator it = manager->GetCacheIterator(variable.c_str());
  41. if ( it.IsAtEnd() )
  42. {
  43. m_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. }