On 11/07/2010 02:07 AM, Russell L. Carter wrote:
> 
> Hi there,
> Happy cmake user here.  I want to retrieve the leaf name of
> the directory property "PARENT_DIRECTORY".  This is really
> a more general cmake question:  how do I most efficiently
> manipulate path components of the absolute pathnames that
> cmake uses and returns for many variables?
> 
> In the current case, suppose I have
> 
> "/home/me/project/src/module/help"
> 
> how do I, in the best CMAKE WAY, extract the leaf, "help"?
> 
> string(REGEXP) or something like that?
> 
> I would love to be able to run a bash script on the full
> path and return just the leaf...  can I do that?

You might try STRING(REGEX REPLACE "^.*/([^/]*)\$" "\\1" LEAF ${PATH}),
but also read about FILE(TO_CMAKE_PATH ...), FILE(TO_NATIVE_PATH ...)
and GET_FILENAME_COMPONENT().

Regards,

Michael

PS: Please don't start a new thread by replying to another one.
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to