1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
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
15 #include "cmCommand.h"
17 class cmGetPropertyCommand : public cmCommand
20 cmGetPropertyCommand();
22 virtual cmCommand* Clone()
24 return new cmGetPropertyCommand;
28 * This is called when the command is first encountered in
31 virtual bool InitialPass(std::vector<std::string> const& args,
32 cmExecutionStatus &status);
35 * This determines if the command is invoked when in script mode.
37 virtual bool IsScriptable() const { return true; }
40 * The name of the command as specified in CMakeList.txt.
42 virtual const char* GetName() const { return "get_property";}
45 * Succinct documentation.
47 virtual const char* GetTerseDocumentation() const
49 return "Get a property.";
53 * Longer documentation.
55 virtual const char* GetFullDocumentation() const
58 " get_property(<variable>\n"
60 " DIRECTORY [dir] |\n"
61 " TARGET <target> |\n"
62 " SOURCE <source> |\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 "
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 "
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.";
96 cmTypeMacro(cmGetPropertyCommand, cmCommand);
98 enum OutType { OutValue, OutDefined, OutBriefDoc, OutFullDoc, OutSet };
101 std::string PropertyName;
104 // Implementation of result storage.
105 bool StoreResult(const char* value);
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();