Imported Upstream version 2.8.12.2
[platform/upstream/cmake.git] / Source / cmGetPropertyCommand.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 cmGetPropertyCommand_h
13 #define cmGetPropertyCommand_h
14
15 #include "cmCommand.h"
16
17 class cmGetPropertyCommand : public cmCommand
18 {
19 public:
20   cmGetPropertyCommand();
21
22   virtual cmCommand* Clone()
23     {
24       return new cmGetPropertyCommand;
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    * This determines if the command is invoked when in script mode.
36    */
37   virtual bool IsScriptable() const { return true; }
38
39   /**
40    * The name of the command as specified in CMakeList.txt.
41    */
42   virtual const char* GetName() const { return "get_property";}
43
44   /**
45    * Succinct documentation.
46    */
47   virtual const char* GetTerseDocumentation() const
48     {
49     return "Get a property.";
50     }
51
52   /**
53    * Longer documentation.
54    */
55   virtual const char* GetFullDocumentation() const
56     {
57       return
58         "  get_property(<variable>\n"
59         "               <GLOBAL             |\n"
60         "                DIRECTORY [dir]    |\n"
61         "                TARGET    <target> |\n"
62         "                SOURCE    <source> |\n"
63         "                TEST      <test>   |\n"
64         "                CACHE     <entry>  |\n"
65         "                VARIABLE>\n"
66         "               PROPERTY <name>\n"
67         "               [SET | DEFINED | BRIEF_DOCS | FULL_DOCS])\n"
68         "Get one property from one object in a scope.  "
69         "The first argument specifies the variable in which to store the "
70         "result.  "
71         "The second argument determines the scope from which to get the "
72         "property.  It must be one of the following:\n"
73         "GLOBAL scope is unique and does not accept a name.\n"
74         "DIRECTORY scope defaults to the current directory but another "
75         "directory (already processed by CMake) may be named by full or "
76         "relative path.\n"
77         "TARGET scope must name one existing target.\n"
78         "SOURCE scope must name one source file.\n"
79         "TEST scope must name one existing test.\n"
80         "CACHE scope must name one cache entry.\n"
81         "VARIABLE scope is unique and does not accept a name.\n"
82         "The required PROPERTY option is immediately followed by the name "
83         "of the property to get.  "
84         "If the property is not set an empty value is returned.  "
85         "If the SET option is given the variable is set to a boolean "
86         "value indicating whether the property has been set.  "
87         "If the DEFINED option is given the variable is set to a boolean "
88         "value indicating whether the property has been defined "
89         "such as with define_property. "
90         "If BRIEF_DOCS or FULL_DOCS is given then the variable is set to "
91         "a string containing documentation for the requested property.  "
92         "If documentation is requested for a property that has not been "
93         "defined NOTFOUND is returned.";
94     }
95
96   cmTypeMacro(cmGetPropertyCommand, cmCommand);
97 private:
98   enum OutType { OutValue, OutDefined, OutBriefDoc, OutFullDoc, OutSet };
99   std::string Variable;
100   std::string Name;
101   std::string PropertyName;
102   OutType InfoType;
103
104   // Implementation of result storage.
105   bool StoreResult(const char* value);
106
107   // Implementation of each property type.
108   bool HandleGlobalMode();
109   bool HandleDirectoryMode();
110   bool HandleTargetMode();
111   bool HandleSourceMode();
112   bool HandleTestMode();
113   bool HandleVariableMode();
114   bool HandleCacheMode();
115 };
116
117 #endif