[CMake] Unable to fetch directory name from path

Alexander Neundorf a.neundorf-work at gmx.net
Thu Feb 5 12:53:00 EST 2009

On Thursday 05 February 2009, Ashutosh Juneja wrote:
> Hi,
> I am unable to fetch only directory name from an absolute path in
> CMakeList.txt file.
> GET_FILENAME_COMPONENT(c:/path/to/dir dirname NAME) does no produce any
> output.

First the variable, then the path:
GET_FILENAME_COMPONENT(dirname c:/path/to/dir NAME)

> 2. Is it possible to split a path in an list/array? ( like extract 'abc'
> and 'def' from /path/to/split/abc/and/def )

You can call GET_FILENAME_COMPONENT() multiple times, ot you could replace all 
the "/" in the string with ";" and then use separate_arguments()


More information about the CMake mailing list