[CMake] multi platform path

Andrea Crotti andrea.crotti.0 at gmail.com
Tue Feb 21 08:27:38 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?



More information about the CMake mailing list