Piotr Dobrogost wrote:
Bill Hoffman wrote:

Piotr Dobrogost wrote:
Bill Hoffman wrote:

There is no such thing as a list with spaces in CMake, that is a string.
 So, no there is no way to use the list command on strings directly. You
could use string(replace ) to do what you are trying to do.
I've seen people already asking about this feature.
Wouldn't that be useful to have this?
I don't see any reason why not to support both kinds of commonly used
lists instead of only one.


But, it is not a list....   Why not use string replace?

Because it is a list in its very nature. The fact we _can_ treat it as
string doesn't change its inherent identity. That's even reflected when
you name such variables. How would you name
${CMAKE_C_STANDARD_LIBRARIES} variable? It's a _list_ of some libraries.
It's neither a set nor a graph nor a tree :) It's simply a list.

Every structure can be treated like a string because every structure can
be serialized. But it doesn't help to understand this structure's
inherent properties when we look at it mainly or only as a string. It
doesn't help to manage such structure as well.

Take for an example a localization string. The main properties we are
interested in are the language and maybe string's length. We don't
usually do any operations on its words. And because of this it's _more_
a string than a list. On the other hand we very often have to add/remove
elements of variables like ${CMAKE_C_STANDARD_LIBRARIES}. And because of
this it's _more_ a list than a string.

Bill, would you mind be so kind and show this topic to other people
writing cmake in Kiteware? I'd like to know what they think about this.

I'd like to know what others on this list think about it as well. So if
you're reading this post please tell us what you think.


The real solution is to use the list already in CMake. It was a mistake to have CMAKE_CXX_FLAGS and CMAKE_C_STANDARD_LIBRARIES be strings they should have been lists. If you want to convert a string to a list you can do it like this:

set(list ${string})

That will make the space separated list string into a ; separated list. If you want to keep string a string you need quotes:
set(newstring "${string}").

Converting a list back into a string requires a foreach loop or a regex.

The problem is there are some variables in CMake which are currently strings that should be lists. I don't think the solution is to add list operations for strings. And you are right CMAKE_C_STANDARD_LIBRARIES should be a list.

-Bill



_______________________________________________
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