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> <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"
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.";
88 cmTypeMacro(cmGetFilenameComponentCommand, cmCommand);