[CMake] Splitting directory and file.

Pablo Zurita pzurita at gmail.com
Wed Mar 2 07:41:06 EST 2011


Yes, that works.

Now I just need to remove the last character if it is a forward slash. How can I do that?

Thanks,
Pablo Zurita.

Sent from my iPhone

On Mar 2, 2011, at 1:47 AM, Yuri Timenkov <yuri at timenkov.ru> wrote:

> Does get_filename_component help?
> 
> On Wed, Mar 2, 2011 at 6:17 AM, Pablo Zurita <pzurita at gmail.com> wrote:
> Hello everybody,
> 
> I'm just getting started and I need some help dealing with strings in
> CMake. Basically what I have a bunch of strings such as the ones
> below:
> 
> "Main.cpp"
> "Window/Example/Example.cpp"
> "Window/Window.cpp"
> 
> What I need to do is create two strings for each, one is going to be
> the directory, so the output in order for the list above is:
> 
> ""
> "Window/Example"
> "Window"
> 
> And the other string I need is the file itself. So the output for that would be
> 
> "Main.cpp"
> "Example.cpp"
> "Window.cpp"
> 
> Since I'm processing each one by one it doesn't matter if there are collisions.
> 
> As you can see all I need to is find the first forward slash on the
> string reading from right to left, and then put what's on the left of
> that string on one variable, and what is to the right in another.
> 
> Does anybody know how I can do that?
> 
> Thanks,
> Pablo Zurita.
> _______________________________________________
> 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
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110302/5e0e5104/attachment-0001.htm>


More information about the CMake mailing list