[CMake] Splitting directory and file.

Pablo Zurita pzurita at gmail.com
Tue Mar 1 22:17:59 EST 2011


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.


More information about the CMake mailing list