cmGetFilenameComponentCommand.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmGetFilenameComponentCommand_h
  11. #define cmGetFilenameComponentCommand_h
  12. #include "cmCommand.h"
  13. /** \class cmGetFilenameComponentCommand
  14. * \brief Get a specific component of a filename.
  15. *
  16. * cmGetFilenameComponentCommand is a utility command used to get the path,
  17. * name, extension or name without extension of a full filename.
  18. */
  19. class cmGetFilenameComponentCommand : public cmCommand
  20. {
  21. public:
  22. /**
  23. * This is a virtual constructor for the command.
  24. */
  25. virtual cmCommand* Clone()
  26. {
  27. return new cmGetFilenameComponentCommand;
  28. }
  29. /**
  30. * This is called when the command is first encountered in
  31. * the CMakeLists.txt file.
  32. */
  33. virtual bool InitialPass(std::vector<std::string> const& args,
  34. cmExecutionStatus &status);
  35. /**
  36. * This determines if the command is invoked when in script mode.
  37. */
  38. virtual bool IsScriptable() { return true; }
  39. /**
  40. * The name of the command as specified in CMakeList.txt.
  41. */
  42. virtual const char* GetName() { return "get_filename_component";}
  43. /**
  44. * Succinct documentation.
  45. */
  46. virtual const char* GetTerseDocumentation()
  47. {
  48. return "Get a specific component of a full filename.";
  49. }
  50. /**
  51. * More documentation.
  52. */
  53. virtual const char* GetFullDocumentation()
  54. {
  55. return
  56. " get_filename_component(VarName FileName\n"
  57. " PATH|ABSOLUTE|NAME|EXT|NAME_WE|REALPATH\n"
  58. " [CACHE])\n"
  59. "Set VarName to be the path (PATH), file name (NAME), file "
  60. "extension (EXT), file name without extension (NAME_WE) of FileName, "
  61. "the full path (ABSOLUTE), or the full path with all symlinks "
  62. "resolved (REALPATH). "
  63. "Note that the path is converted to Unix slashes format and has no "
  64. "trailing slashes. The longest file extension is always considered. "
  65. "If the optional CACHE argument is specified, the result variable is "
  66. "added to the cache.\n"
  67. " get_filename_component(VarName FileName\n"
  68. " PROGRAM [PROGRAM_ARGS ArgVar]\n"
  69. " [CACHE])\n"
  70. "The program in FileName will be found in the system search path or "
  71. "left as a full path. If PROGRAM_ARGS is present with PROGRAM, then "
  72. "any command-line arguments present in the FileName string are split "
  73. "from the program name and stored in ArgVar. This is used to separate "
  74. "a program name from its arguments in a command line string.";
  75. }
  76. cmTypeMacro(cmGetFilenameComponentCommand, cmCommand);
  77. };
  78. #endif