cmSetCommand.h 3.5 KB

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