cmSetCommand.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. #ifndef cmSetCommand_h
  14. #define cmSetCommand_h
  15. #include "cmCommand.h"
  16. /** \class cmSetCommand
  17. * \brief Set a CMAKE variable
  18. *
  19. * cmSetCommand sets a variable to a value with expansion.
  20. */
  21. class cmSetCommand : public cmCommand
  22. {
  23. public:
  24. /**
  25. * This is a virtual constructor for the command.
  26. */
  27. virtual cmCommand* Clone()
  28. {
  29. return new cmSetCommand;
  30. }
  31. /**
  32. * This is called when the command is first encountered in
  33. * the CMakeLists.txt file.
  34. */
  35. virtual bool InitialPass(std::vector<std::string> const& args,
  36. cmExecutionStatus &status);
  37. /**
  38. * This determines if the command is invoked when in script mode.
  39. */
  40. virtual bool IsScriptable() { return true; }
  41. /**
  42. * The name of the command as specified in CMakeList.txt.
  43. */
  44. virtual const char* GetName() {return "set";}
  45. /**
  46. * Succinct documentation.
  47. */
  48. virtual const char* GetTerseDocumentation()
  49. {
  50. return "Set a CMAKE variable to a given value.";
  51. }
  52. /**
  53. * More documentation.
  54. */
  55. virtual const char* GetFullDocumentation()
  56. {
  57. return
  58. " set(<variable> <value> [[CACHE <type> <docstring> [FORCE]] | "
  59. "PARENT_SCOPE])\n"
  60. "Within CMake sets <variable> to the value <value>. <value> is expanded"
  61. " before <variable> is set to it. If CACHE is present, then the "
  62. "<variable> is put in the cache. <type> and <docstring> are then "
  63. "required. <type> is used by the CMake GUI to choose a widget with "
  64. "which the user sets a value. The value for <type> may be one of\n"
  65. " FILEPATH = File chooser dialog.\n"
  66. " PATH = Directory chooser dialog.\n"
  67. " STRING = Arbitrary string.\n"
  68. " BOOL = Boolean ON/OFF checkbox.\n"
  69. " INTERNAL = No GUI entry (used for persistent variables).\n"
  70. "If <type> is INTERNAL, then the <value> is always written into the "
  71. "cache, replacing any values existing in the cache. If it is not a "
  72. "cache variable, then this always writes into the current makefile. The "
  73. "FORCE option will overwrite the cache value removing any changes by "
  74. "the user.\n"
  75. "If PARENT_SCOPE is present, the variable will be set in the scope "
  76. "above the current scope. Each new directory or function creates a new "
  77. "scope. This command will set the value of a variable into the parent "
  78. "directory or calling function (whichever is applicable to the case at "
  79. "hand).\n"
  80. "If <value> is not specified then the variable is removed "
  81. "instead of set. See also: the unset() command.\n"
  82. " set(<variable> <value1> ... <valueN>)\n"
  83. "In this case <variable> is set to a semicolon separated list of "
  84. "values.\n"
  85. "<variable> can be an environment variable such as:\n"
  86. " set( ENV{PATH} /home/martink )\n"
  87. "in which case the environment variable will be set.";
  88. }
  89. cmTypeMacro(cmSetCommand, cmCommand);
  90. };
  91. #endif