cmSetCommand.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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() { return true; }
  38. /**
  39. * The name of the command as specified in CMakeList.txt.
  40. */
  41. virtual const char* GetName() {return "set";}
  42. /**
  43. * Succinct documentation.
  44. */
  45. virtual const char* GetTerseDocumentation()
  46. {
  47. return "Set a CMAKE variable to a given value.";
  48. }
  49. /**
  50. * More documentation.
  51. */
  52. virtual const char* GetFullDocumentation()
  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 and <variable> "
  59. "is not yet in the cache, then <variable> is put in the cache. If it is "
  60. "already in the cache, <variable> is assigned the value stored in the "
  61. "cache. If CACHE is present, also <type> and <docstring> are "
  62. "required. <type> is used by the CMake GUI to choose a widget with "
  63. "which the user sets a value. The value for <type> may be one of\n"
  64. " FILEPATH = File chooser dialog.\n"
  65. " PATH = Directory chooser dialog.\n"
  66. " STRING = Arbitrary string.\n"
  67. " BOOL = Boolean ON/OFF checkbox.\n"
  68. " INTERNAL = No GUI entry (used for persistent variables).\n"
  69. "If <type> is INTERNAL, then the <value> is always written into the "
  70. "cache, replacing any values existing in the cache. If it is not a "
  71. "cache variable, then this always writes into the current makefile. The "
  72. "FORCE option will overwrite the cache value removing any changes by "
  73. "the user.\n"
  74. "If PARENT_SCOPE is present, the variable will be set in the scope "
  75. "above the current scope. Each new directory or function creates a new "
  76. "scope. This command will set the value of a variable into the parent "
  77. "directory or calling function (whichever is applicable to the case at "
  78. "hand).\n"
  79. "If <value> is not specified then the variable is removed "
  80. "instead of set. See also: the unset() command.\n"
  81. " set(<variable> <value1> ... <valueN>)\n"
  82. "In this case <variable> is set to a semicolon separated list of "
  83. "values.\n"
  84. "<variable> can be an environment variable such as:\n"
  85. " set( ENV{PATH} /home/martink )\n"
  86. "in which case the environment variable will be set.";
  87. }
  88. cmTypeMacro(cmSetCommand, cmCommand);
  89. };
  90. #endif