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 cmGetFilenameComponentCommand_h
13 #define cmGetFilenameComponentCommand_h
15 #include "cmCommand.h"
17 /** \class cmGetFilenameComponentCommand
18 * \brief Get a specific component of a filename.
20 * cmGetFilenameComponentCommand is a utility command used to get the path,
21 * name, extension or name without extension of a full filename.
23 class cmGetFilenameComponentCommand : public cmCommand
27 * This is a virtual constructor for the command.
29 virtual cmCommand* Clone()
31 return new cmGetFilenameComponentCommand;
35 * This is called when the command is first encountered in
36 * the CMakeLists.txt file.
38 virtual bool InitialPass(std::vector<std::string> const& args,
39 cmExecutionStatus &status);
42 * This determines if the command is invoked when in script mode.
44 virtual bool IsScriptable() const { return true; }
47 * The name of the command as specified in CMakeList.txt.
49 virtual const char* GetName() const { return "get_filename_component";}
52 * Succinct documentation.
54 virtual const char* GetTerseDocumentation() const
56 return "Get a specific component of a full filename.";
62 virtual const char* GetFullDocumentation() const
65 " get_filename_component(<VAR> FileName\n"
66 " PATH|ABSOLUTE|NAME|EXT|NAME_WE|REALPATH\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"
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.";
86 cmTypeMacro(cmGetFilenameComponentCommand, cmCommand);