Imported Upstream version 2.8.12.2
[platform/upstream/cmake.git] / Source / cmSetPropertyCommand.h
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the License for more information.
11 ============================================================================*/
12 #ifndef cmSetsPropertiesCommand_h
13 #define cmSetsPropertiesCommand_h
14
15 #include "cmCommand.h"
16
17 class cmSetPropertyCommand : public cmCommand
18 {
19 public:
20   cmSetPropertyCommand();
21
22   virtual cmCommand* Clone()
23     {
24       return new cmSetPropertyCommand;
25     }
26
27   /**
28    * This is called when the command is first encountered in
29    * the input file.
30    */
31   virtual bool InitialPass(std::vector<std::string> const& args,
32                            cmExecutionStatus &status);
33
34   /**
35    * The name of the command as specified in CMakeList.txt.
36    */
37   virtual const char* GetName() const { return "set_property";}
38
39   /**
40    * Succinct documentation.
41    */
42   virtual const char* GetTerseDocumentation() const
43     {
44     return "Set a named property in a given scope.";
45     }
46
47   /**
48    * Longer documentation.
49    */
50   virtual const char* GetFullDocumentation() const
51     {
52       return
53         "  set_property(<GLOBAL                            |\n"
54         "                DIRECTORY [dir]                   |\n"
55         "                TARGET    [target1 [target2 ...]] |\n"
56         "                SOURCE    [src1 [src2 ...]]       |\n"
57         "                TEST      [test1 [test2 ...]]     |\n"
58         "                CACHE     [entry1 [entry2 ...]]>\n"
59         "               [APPEND] [APPEND_STRING]\n"
60         "               PROPERTY <name> [value1 [value2 ...]])\n"
61         "Set one property on zero or more objects of a scope.  "
62         "The first argument determines the scope in which the property "
63         "is set.  It must be one of the following:\n"
64         "GLOBAL scope is unique and does not accept a name.\n"
65         "DIRECTORY scope defaults to the current directory but another "
66         "directory (already processed by CMake) may be named by full or "
67         "relative path.\n"
68         "TARGET scope may name zero or more existing targets.\n"
69         "SOURCE scope may name zero or more source files.  "
70         "Note that source file properties are visible only to targets "
71         "added in the same directory (CMakeLists.txt).\n"
72         "TEST scope may name zero or more existing tests.\n"
73         "CACHE scope must name zero or more cache existing entries.\n"
74         "The required PROPERTY option is immediately followed by the name "
75         "of the property to set.  Remaining arguments are used to "
76         "compose the property value in the form of a semicolon-separated "
77         "list.  "
78         "If the APPEND option is given the list is appended to any "
79         "existing property value."
80         "If the APPEND_STRING option is given the string is append to any "
81         "existing property value as string, i.e. it results in a longer "
82         "string and not a list of strings."
83         ;
84     }
85
86   /**
87    * This determines if the command is invoked when in script mode.
88    */
89   virtual bool IsScriptable() const { return true; }
90
91   cmTypeMacro(cmSetPropertyCommand, cmCommand);
92
93 private:
94   std::set<cmStdString> Names;
95   std::string PropertyName;
96   std::string PropertyValue;
97   bool Remove;
98   bool AppendMode;
99   bool AppendAsString;
100
101   // Implementation of each property type.
102   bool HandleGlobalMode();
103   bool HandleDirectoryMode();
104   bool HandleTargetMode();
105   bool HandleTarget(cmTarget* target);
106   bool HandleSourceMode();
107   bool HandleSource(cmSourceFile* sf);
108   bool HandleTestMode();
109   bool HandleTest(cmTest* test);
110   bool HandleCacheMode();
111   bool HandleCacheEntry(cmCacheManager::CacheIterator&);
112 };
113
114
115
116 #endif