You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.2 KiB

25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
22 years ago
25 years ago
25 years ago
  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 "cmOptionCommand.h"
  14. // cmOptionCommand
  15. bool cmOptionCommand::InitialPass(std::vector<std::string> const& args)
  16. {
  17. bool argError = false;
  18. if(args.size() < 2)
  19. {
  20. argError = true;
  21. }
  22. // for VTK 4.0 we have to support the option command with more than 3
  23. // arguments if CMAKE_MINIMUM_REQUIRED_VERSION is not defined, if
  24. // CMAKE_MINIMUM_REQUIRED_VERSION is defined, then we can have stricter
  25. // checking.
  26. if(this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION"))
  27. {
  28. if(args.size() > 3)
  29. {
  30. argError = true;
  31. }
  32. }
  33. if(argError)
  34. {
  35. std::string m = "called with incorrect number of arguments: ";
  36. for(size_t i =0; i < args.size(); ++i)
  37. {
  38. m += args[i];
  39. m += " ";
  40. }
  41. this->SetError(m.c_str());
  42. return false;
  43. }
  44. std::string initialValue = "Off";
  45. // Now check and see if the value has been stored in the cache
  46. // already, if so use that value and don't look for the program
  47. cmCacheManager::CacheIterator it =
  48. this->Makefile->GetCacheManager()->GetCacheIterator(args[0].c_str());
  49. if(!it.IsAtEnd())
  50. {
  51. if ( it.GetType() != cmCacheManager::UNINITIALIZED )
  52. {
  53. it.SetProperty("HELPSTRING", args[1].c_str());
  54. return true;
  55. }
  56. if ( it.GetValue() )
  57. {
  58. initialValue = it.GetValue();
  59. }
  60. }
  61. if(args.size() == 3)
  62. {
  63. initialValue = args[2];
  64. }
  65. this->Makefile->AddCacheDefinition(args[0].c_str(),
  66. cmSystemTools::IsOn(initialValue.c_str()),
  67. args[1].c_str());
  68. return true;
  69. }