[CMake] extract a folder name

Eric Noulard eric.noulard at gmail.com
Tue Jul 26 11:43:25 EDT 2011


2011/7/26 Julien Dardenne <julien.dardenne at technooliq.com>:
> Hi,
>
> I have a path and i try to extract the folder name of this one.
>
> example :
>
> For C:/Programs/game/test, i would get test
>
> Do you know a cmake command ? or should i use regular expressions ?
> If so, can you give me an example ?

set(ORIGNAME "C:/Programs/game/test")
get_filename_component(FNAME ${ORIGNAME} NAME)

You should get what you want in variable FNAME.

and....

you should read the doc of "get_filename_component" cmake builtin macro:

cmake --help-command get_filename_component

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list