cmGetFilenameComponentCommand.h 3.3 KB

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