Imported Upstream version 2.8.9
[platform/upstream/cmake.git] / Source / cmGetFilenameComponentCommand.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 cmGetFilenameComponentCommand_h
13 #define cmGetFilenameComponentCommand_h
14
15 #include "cmCommand.h"
16
17 /** \class cmGetFilenameComponentCommand
18  * \brief Get a specific component of a filename.
19  *
20  * cmGetFilenameComponentCommand is a utility command used to get the path,
21  * name, extension or name without extension of a full filename. 
22  */
23 class cmGetFilenameComponentCommand : public cmCommand
24 {
25 public:
26   /**
27    * This is a virtual constructor for the command.
28    */
29   virtual cmCommand* Clone() 
30     {
31     return new cmGetFilenameComponentCommand;
32     }
33
34   /**
35    * This is called when the command is first encountered in
36    * the CMakeLists.txt file.
37    */
38   virtual bool InitialPass(std::vector<std::string> const& args,
39                            cmExecutionStatus &status);
40
41   /**
42    * This determines if the command is invoked when in script mode.
43    */
44   virtual bool IsScriptable() const { return true; }
45
46   /**
47    * The name of the command as specified in CMakeList.txt.
48    */
49   virtual const char* GetName() const { return "get_filename_component";}
50
51   /**
52    * Succinct documentation.
53    */
54   virtual const char* GetTerseDocumentation() const
55     {
56     return "Get a specific component of a full filename.";
57     }
58   
59   /**
60    * More documentation.
61    */
62   virtual const char* GetFullDocumentation() const
63     {
64     return
65       "  get_filename_component(<VAR> FileName\n"
66       "                         PATH|ABSOLUTE|NAME|EXT|NAME_WE|REALPATH\n"
67       "                         [CACHE])\n"
68       "Set <VAR> to be the path (PATH), file name (NAME), file "
69       "extension (EXT), file name without extension (NAME_WE) of FileName, "
70       "the full path (ABSOLUTE), or the full path with all symlinks "
71       "resolved (REALPATH).  "
72       "Note that the path is converted to Unix slashes format and has no "
73       "trailing slashes. The longest file extension is always considered. "
74       "If the optional CACHE argument is specified, the result variable is "
75       "added to the cache.\n"
76       "  get_filename_component(<VAR> FileName\n"
77       "                         PROGRAM [PROGRAM_ARGS <ARG_VAR>]\n"
78       "                         [CACHE])\n"
79       "The program in FileName will be found in the system search path or "
80       "left as a full path.  If PROGRAM_ARGS is present with PROGRAM, then "
81       "any command-line arguments present in the FileName string are split "
82       "from the program name and stored in <ARG_VAR>.  This is used to "
83       "separate a program name from its arguments in a command line string.";
84     }
85   
86   cmTypeMacro(cmGetFilenameComponentCommand, cmCommand);
87 };
88
89
90
91 #endif