get_filename_component.rst 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. get_filename_component
  2. ----------------------
  3. Get a specific component of a full filename.
  4. ::
  5. get_filename_component(<VAR> <FileName> <COMP> [CACHE])
  6. Set ``<VAR>`` to a component of ``<FileName>``, where ``<COMP>`` is one of:
  7. ::
  8. DIRECTORY = Directory without file name
  9. NAME = File name without directory
  10. EXT = File name longest extension (.b.c from d/a.b.c)
  11. NAME_WE = File name without directory or longest extension
  12. ABSOLUTE = Full path to file
  13. REALPATH = Full path to existing file with symlinks resolved
  14. PATH = Legacy alias for DIRECTORY (use for CMake <= 2.8.11)
  15. Paths are returned with forward slashes and have no trailing slahes.
  16. The longest file extension is always considered. If the optional
  17. ``CACHE`` argument is specified, the result variable is added to the
  18. cache.
  19. ::
  20. get_filename_component(<VAR> FileName
  21. PROGRAM [PROGRAM_ARGS <ARG_VAR>]
  22. [CACHE])
  23. The program in ``FileName`` will be found in the system search path or
  24. left as a full path. If ``PROGRAM_ARGS`` is present with ``PROGRAM``, then
  25. any command-line arguments present in the ``FileName`` string are split
  26. from the program name and stored in ``<ARG_VAR>``. This is used to
  27. separate a program name from its arguments in a command line string.