cmGetFilenameComponentCommand.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. /**
  38. * This determines if the command is invoked when in script mode.
  39. */
  40. virtual bool IsScriptable() { return true; }
  41. /**
  42. * The name of the command as specified in CMakeList.txt.
  43. */
  44. virtual const char* GetName() { return "GET_FILENAME_COMPONENT";}
  45. /**
  46. * Succinct documentation.
  47. */
  48. virtual const char* GetTerseDocumentation()
  49. {
  50. return "Get a specific component of a full filename.";
  51. }
  52. /**
  53. * More documentation.
  54. */
  55. virtual const char* GetFullDocumentation()
  56. {
  57. return
  58. " GET_FILENAME_COMPONENT(VarName FileName\n"
  59. " PATH|ABSOLUTE|NAME|EXT|NAME_WE\n"
  60. " [CACHE])\n"
  61. "Set VarName to be the path (PATH), file name (NAME), file "
  62. "extension (EXT), file name without extension (NAME_WE) of FileName, "
  63. "or the full absolute (ABSOLUTE) file name without symlinks. "
  64. "Note that the path is converted to Unix slashes format and has no "
  65. "trailing slashes. The longest file extension is always considered. "
  66. "If the optional CACHE argument is specified, the result variable is "
  67. "added to the cache.\n"
  68. " GET_FILENAME_COMPONENT(VarName FileName\n"
  69. " PROGRAM [PROGRAM_ARGS ArgVar]\n"
  70. " [CACHE])\n"
  71. "The program in FileName will be found in the system search path or "
  72. "left as a full path. If PROGRAM_ARGS is present with PROGRAM, then "
  73. "any command-line arguments present in the FileName string are split "
  74. "from the program name and stored in ArgVar. This is used to separate "
  75. "a program name from its arguments in a command line string.";
  76. }
  77. cmTypeMacro(cmGetFilenameComponentCommand, cmCommand);
  78. };
  79. #endif