Imported Upstream version 2.8.12.2
[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> <COMP> [CACHE])\n"
66       "Set <VAR> to a component of <FileName>, where <COMP> is one of:\n"
67       " DIRECTORY = Directory without file name\n"
68       " NAME      = File name without directory\n"
69       " EXT       = File name longest extension (.b.c from d/a.b.c)\n"
70       " NAME_WE   = File name without directory or longest extension\n"
71       " ABSOLUTE  = Full path to file\n"
72       " REALPATH  = Full path to existing file with symlinks resolved\n"
73       " PATH      = Legacy alias for DIRECTORY (use for CMake <= 2.8.11)\n"
74       "Paths are returned with forward slashes and have no trailing slahes. "
75       "The longest file extension is always considered. "
76       "If the optional CACHE argument is specified, the result variable is "
77       "added to the cache.\n"
78       "  get_filename_component(<VAR> FileName\n"
79       "                         PROGRAM [PROGRAM_ARGS <ARG_VAR>]\n"
80       "                         [CACHE])\n"
81       "The program in FileName will be found in the system search path or "
82       "left as a full path.  If PROGRAM_ARGS is present with PROGRAM, then "
83       "any command-line arguments present in the FileName string are split "
84       "from the program name and stored in <ARG_VAR>.  This is used to "
85       "separate a program name from its arguments in a command line string.";
86     }
87
88   cmTypeMacro(cmGetFilenameComponentCommand, cmCommand);
89 };
90
91
92
93 #endif