cmGetFilenameComponentCommand.h 3.2 KB

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