cmSetPropertyCommand.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 cmSetsPropertiesCommand_h
  14. #define cmSetsPropertiesCommand_h
  15. #include "cmCommand.h"
  16. class cmSetPropertyCommand : public cmCommand
  17. {
  18. public:
  19. cmSetPropertyCommand();
  20. virtual cmCommand* Clone()
  21. {
  22. return new cmSetPropertyCommand;
  23. }
  24. /**
  25. * This is called when the command is first encountered in
  26. * the input file.
  27. */
  28. virtual bool InitialPass(std::vector<std::string> const& args,
  29. cmExecutionStatus &status);
  30. /**
  31. * The name of the command as specified in CMakeList.txt.
  32. */
  33. virtual const char* GetName() { return "set_property";}
  34. /**
  35. * Succinct documentation.
  36. */
  37. virtual const char* GetTerseDocumentation()
  38. {
  39. return "Set a named property in a given scope.";
  40. }
  41. /**
  42. * Longer documentation.
  43. */
  44. virtual const char* GetFullDocumentation()
  45. {
  46. return
  47. " set_property(<GLOBAL |\n"
  48. " DIRECTORY [dir] |\n"
  49. " TARGET [target1 [target2 ...]] |\n"
  50. " SOURCE [src1 [src2 ...]] |\n"
  51. " TEST [test1 [test2 ...]] |\n"
  52. " CACHE [entry1 [entry2 ...]]>\n"
  53. " [APPEND]\n"
  54. " PROPERTY <name> [value1 [value2 ...]])\n"
  55. "Set one property on zero or more objects of a scope. "
  56. "The first argument determines the scope in which the property "
  57. "is set. It must be one of the following:\n"
  58. "GLOBAL scope is unique and does not accept a name.\n"
  59. "DIRECTORY scope defaults to the current directory but another "
  60. "directory (already processed by CMake) may be named by full or "
  61. "relative path.\n"
  62. "TARGET scope may name zero or more existing targets.\n"
  63. "SOURCE scope may name zero or more source files.\n"
  64. "TEST scope may name zero or more existing tests.\n"
  65. "CACHE scope must name zero or more cache existing entries.\n"
  66. "The required PROPERTY option is immediately followed by the name "
  67. "of the property to set. Remaining arguments are used to "
  68. "compose the property value in the form of a semicolon-separated "
  69. "list. "
  70. "If the APPEND option is given the list is appended to any "
  71. "existing property value."
  72. ;
  73. }
  74. /**
  75. * This determines if the command is invoked when in script mode.
  76. */
  77. virtual bool IsScriptable() { return true; }
  78. cmTypeMacro(cmSetPropertyCommand, cmCommand);
  79. private:
  80. std::set<cmStdString> Names;
  81. std::string PropertyName;
  82. std::string PropertyValue;
  83. bool Remove;
  84. bool AppendMode;
  85. // Implementation of each property type.
  86. bool HandleGlobalMode();
  87. bool HandleDirectoryMode();
  88. bool HandleTargetMode();
  89. bool HandleTarget(cmTarget* target);
  90. bool HandleSourceMode();
  91. bool HandleSource(cmSourceFile* sf);
  92. bool HandleTestMode();
  93. bool HandleTest(cmTest* test);
  94. bool HandleCacheMode();
  95. bool HandleCacheEntry(cmCacheManager::CacheIterator&);
  96. };
  97. #endif