[CMake] Re: Help getting -l and -L arguments from apr-config

Thomas Christian Chust chust at web.de
Fri May 4 05:02:27 EDT 2007


Matthew Woehlke wrote:

> [...] So I think I still have the same problem, how to take a string
> that might look like '-lfoo -lbar -L"foo bar/thelib"' and split it
> into '-lfoo', '-lbar' and '-L"foo bar/thelib". From there I can use
> STRING to strip the flag and SET/LIST to build the needed variables.
> [...]

Hello,

as CMake apparently doesn't make a big difference between lists and
strings internally, you can simply replace all spaces with ';' in a
string to get a list.

The following snippet will send the strings "1", "2" and "3" to the
messages console, each of them on its own line:

  SET(FOO "1 2 3")
  STRING(REPLACE " " ";" FOO_LIST "${FOO}")
  FOREACH(item ${FOO_LIST})
    MESSAGE(${item})
  ENDFOREACH(item ${FOO_LIST})

If your string may contain spaces as payload data you will have to be
more careful when doing the replacement, though...

cu,
Thomas



More information about the CMake mailing list