[CMake] multi platform path

Rolf Eike Beer eike at sf-mail.de
Tue Feb 21 08:39:51 EST 2012


> I want to be able to have this simple translation between full path and
> filename.
>
> For example = /very/long/path/file.py ->  file.py
>
> So I did this quite ugly function:
>
> function (get_filename FULLPATH)
>     string(REPLACE "/" ";" p2list "${FULLPATH}")
>     list(REVERSE p2list)
>     list(GET p2list 0 last)
>     set(RESULT_VAR ${last} PARENT_SCOPE)
> endfunction()
>
> but the problem is that it doesn't work on windows unfortunately.
> Is there some library/code to do multi-platform path manipulations in
> CMake maybe?

get_filename_component()

Eike


More information about the CMake mailing list