1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmGetPropertyCommand.h,v $
6 Date: $Date: 2008-09-04 17:15:18 $
7 Version: $Revision: 1.8 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #ifndef cmGetPropertyCommand_h
18 #define cmGetPropertyCommand_h
20 #include "cmCommand.h"
22 class cmGetPropertyCommand
: public cmCommand
25 cmGetPropertyCommand();
27 virtual cmCommand
* Clone()
29 return new cmGetPropertyCommand
;
33 * This is called when the command is first encountered in
36 virtual bool InitialPass(std::vector
<std::string
> const& args
,
37 cmExecutionStatus
&status
);
40 * This determines if the command is invoked when in script mode.
42 virtual bool IsScriptable() { return true; }
45 * The name of the command as specified in CMakeList.txt.
47 virtual const char* GetName() { return "get_property";}
50 * Succinct documentation.
52 virtual const char* GetTerseDocumentation()
54 return "Get a property.";
58 * Longer documentation.
60 virtual const char* GetFullDocumentation()
63 " get_property(<variable>\n"
65 " DIRECTORY [dir] |\n"
66 " TARGET <target> |\n"
67 " SOURCE <source> |\n"
71 " [SET | DEFINED | BRIEF_DOCS | FULL_DOCS])\n"
72 "Get one property from one object in a scope. "
73 "The first argument specifies the variable in which to store the "
75 "The second argument determines the scope from which to get the "
76 "property. It must be one of the following:\n"
77 "GLOBAL scope is unique and does not accept a name.\n"
78 "DIRECTORY scope defaults to the current directory but another "
79 "directory (already processed by CMake) may be named by full or "
81 "TARGET scope must name one existing target.\n"
82 "SOURCE scope must name one source file.\n"
83 "TEST scope must name one existing test.\n"
84 "VARIABLE scope is unique and does not accept a name.\n"
85 "The required PROPERTY option is immediately followed by the name "
86 "of the property to get. "
87 "If the property is not set an empty value is returned. "
88 "If the SET option is given the variable is set to a boolean "
89 "value indicating whether the property has been set. "
90 "If the DEFINED option is given the variable is set to a boolean "
91 "value indicating whether the property has been defined "
92 "such as with define_property. "
93 "If BRIEF_DOCS or FULL_DOCS is given then the variable is set to "
94 "a string containing documentation for the requested property. "
95 "If documentation is requested for a property that has not been "
96 "defined NOTFOUND is returned.";
99 cmTypeMacro(cmGetPropertyCommand
, cmCommand
);
101 enum OutType
{ OutValue
, OutDefined
, OutBriefDoc
, OutFullDoc
, OutSet
};
102 std::string Variable
;
104 std::string PropertyName
;
107 // Implementation of result storage.
108 bool StoreResult(const char* value
);
110 // Implementation of each property type.
111 bool HandleGlobalMode();
112 bool HandleDirectoryMode();
113 bool HandleTargetMode();
114 bool HandleSourceMode();
115 bool HandleTestMode();
116 bool HandleVariableMode();