1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmGetFilenameComponentCommand.h,v $
6 Date: $Date: 2008-01-23 15:27:59 $
7 Version: $Revision: 1.14 $
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 cmGetFilenameComponentCommand_h
18 #define cmGetFilenameComponentCommand_h
20 #include "cmCommand.h"
22 /** \class cmGetFilenameComponentCommand
23 * \brief Get a specific component of a filename.
25 * cmGetFilenameComponentCommand is a utility command used to get the path,
26 * name, extension or name without extension of a full filename.
28 class cmGetFilenameComponentCommand
: public cmCommand
32 * This is a virtual constructor for the command.
34 virtual cmCommand
* Clone()
36 return new cmGetFilenameComponentCommand
;
40 * This is called when the command is first encountered in
41 * the CMakeLists.txt file.
43 virtual bool InitialPass(std::vector
<std::string
> const& args
,
44 cmExecutionStatus
&status
);
47 * This determines if the command is invoked when in script mode.
49 virtual bool IsScriptable() { return true; }
52 * The name of the command as specified in CMakeList.txt.
54 virtual const char* GetName() { return "get_filename_component";}
57 * Succinct documentation.
59 virtual const char* GetTerseDocumentation()
61 return "Get a specific component of a full filename.";
67 virtual const char* GetFullDocumentation()
70 " get_filename_component(VarName FileName\n"
71 " PATH|ABSOLUTE|NAME|EXT|NAME_WE\n"
73 "Set VarName to be the path (PATH), file name (NAME), file "
74 "extension (EXT), file name without extension (NAME_WE) of FileName, "
75 "or the full absolute (ABSOLUTE) file name without symlinks. "
76 "Note that the path is converted to Unix slashes format and has no "
77 "trailing slashes. The longest file extension is always considered. "
78 "If the optional CACHE argument is specified, the result variable is "
79 "added to the cache.\n"
80 " get_filename_component(VarName FileName\n"
81 " PROGRAM [PROGRAM_ARGS ArgVar]\n"
83 "The program in FileName will be found in the system search path or "
84 "left as a full path. If PROGRAM_ARGS is present with PROGRAM, then "
85 "any command-line arguments present in the FileName string are split "
86 "from the program name and stored in ArgVar. This is used to separate "
87 "a program name from its arguments in a command line string.";
90 cmTypeMacro(cmGetFilenameComponentCommand
, cmCommand
);