Discussion:
[CMake] list of lists -possible?
Doug Reiland
2010-06-02 16:24:44 UTC
Permalink
Is it possible to implement a list of lists. The following example
shows cmake ending up with a list with 6 elements instead of
a list with 2 elements with each element being a list with 3 elements

set(fooa 1 2 3)
set(foob a b c)
message(${fooa})
message("${fooa}")
message("${foob}")
list(APPEND foos "${fooa}")
list(APPEND foos "${foob}")
message("${foos}")
foreach (a ${foos})
message(${a})
endforeach()


Thanks again
Clinton Stimpson
2010-06-02 16:34:56 UTC
Permalink
Post by Doug Reiland
Is it possible to implement a list of lists. The following example
shows cmake ending up with a list with 6 elements instead of
a list with 2 elements with each element being a list with 3 elements
set(fooa 1 2 3)
set(foob a b c)
message(${fooa})
message("${fooa}")
message("${foob}")
list(APPEND foos "${fooa}")
list(APPEND foos "${foob}")
message("${foos}")
foreach (a ${foos})
message(${a})
endforeach()
You can put the name of the list in another list, instead of its contents.
And use a nested foreach to extract all of the contents.

set(fooa 1 2 3)
set(foob a b c)
message(${fooa})
message("${fooa}")
message("${foob}")
list(APPEND foos fooa)
list(APPEND foos foob)
foreach(a ${foos})
message("new list")
foreach(b ${${a}})
message(${b})
endforeach(b)
endforeach(a)

Clint
Hendrik Sattler
2010-06-02 17:02:18 UTC
Permalink
Post by Clinton Stimpson
Post by Doug Reiland
Is it possible to implement a list of lists. The following example
shows cmake ending up with a list with 6 elements instead of
a list with 2 elements with each element being a list with 3 elements
set(fooa 1 2 3)
set(foob a b c)
message(${fooa})
message("${fooa}")
message("${foob}")
list(APPEND foos "${fooa}")
list(APPEND foos "${foob}")
message("${foos}")
foreach (a ${foos})
message(${a})
endforeach()
You can put the name of the list in another list, instead of its contents.
And use a nested foreach to extract all of the contents.
I couldn't find a non-hackish way to include a variable into a cmake list,
e.g. a java classpath argument into a cmake list of command line options.
IMHO, escaping the ';' would allow this but I couldn't find out how :-(

HS
Clinton Stimpson
2010-06-02 17:20:49 UTC
Permalink
Post by Hendrik Sattler
Post by Clinton Stimpson
Post by Doug Reiland
Is it possible to implement a list of lists. The following example
shows cmake ending up with a list with 6 elements instead of
a list with 2 elements with each element being a list with 3 elements
set(fooa 1 2 3)
set(foob a b c)
message(${fooa})
message("${fooa}")
message("${foob}")
list(APPEND foos "${fooa}")
list(APPEND foos "${foob}")
message("${foos}")
foreach (a ${foos})
message(${a})
endforeach()
You can put the name of the list in another list, instead of its
contents. And use a nested foreach to extract all of the contents.
I couldn't find a non-hackish way to include a variable into a cmake list,
e.g. a java classpath argument into a cmake list of command line options.
IMHO, escaping the ';' would allow this but I couldn't find out how :-(
How about using colons instead? At least that is what I see in the java docs.
Or use string(REPLACE ...) to replace ";" with "\;"

Clint
Hendrik Sattler
2010-06-02 17:37:36 UTC
Permalink
Post by Clinton Stimpson
Post by Hendrik Sattler
Post by Clinton Stimpson
Post by Doug Reiland
Is it possible to implement a list of lists. The following example
shows cmake ending up with a list with 6 elements instead of
a list with 2 elements with each element being a list with 3 elements
set(fooa 1 2 3)
set(foob a b c)
message(${fooa})
message("${fooa}")
message("${foob}")
list(APPEND foos "${fooa}")
list(APPEND foos "${foob}")
message("${foos}")
foreach (a ${foos})
message(${a})
endforeach()
You can put the name of the list in another list, instead of its
contents. And use a nested foreach to extract all of the contents.
I couldn't find a non-hackish way to include a variable into a cmake
list, e.g. a java classpath argument into a cmake list of command line
options. IMHO, escaping the ';' would allow this but I couldn't find out
how :-(
How about using colons instead? At least that is what I see in the java docs.
Not on every OS ;)
Post by Clinton Stimpson
Or use string(REPLACE ...) to replace ";" with "\;"
Nope, didn't work. Actually, I used a totally different approach, then (not
lists).

HS
Doug Reiland
2010-06-02 17:48:22 UTC
Permalink
perfect, thankyou!
Post by Clinton Stimpson
Post by Doug Reiland
Is it possible to implement a list of lists. The following example
shows cmake ending up with a list with 6 elements instead of
a list with 2 elements with each element being a list with 3 elements
set(fooa 1 2 3)
set(foob a b c)
message(${fooa})
message("${fooa}")
message("${foob}")
list(APPEND foos "${fooa}")
list(APPEND foos "${foob}")
message("${foos}")
foreach (a ${foos})
message(${a})
endforeach()
You can put the name of the list in another list, instead of its contents.
And use a nested foreach to extract all of the contents.
set(fooa 1 2 3)
set(foob a b c)
message(${fooa})
message("${fooa}")
message("${foob}")
list(APPEND foos fooa)
list(APPEND foos foob)
foreach(a ${foos})
 message("new list")
 foreach(b ${${a}})
   message(${b})
 endforeach(b)
endforeach(a)
Clint
_______________________________________________
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
http://www.cmake.org/mailman/listinfo/cmake
Loading...