[CMake] 2D arrays

Robert Dailey rcdailey at gmail.com
Tue Nov 29 18:28:45 EST 2011


I have created a pretty clean solution to this until there is native
support for multi-dimensional arrays in CMake. I have attached the module,
hopefully it will prove useful to others. Here is an example of how to use
it:

set( two_dee_array
apple cat
orange dog
banana elephant
)

array2d_begin_loop( advanced "${two_dee_array}" 2 "fruit;animal" )
while( advanced )
message( "Fruit: ${fruit}" )
message( "Animal: ${animal}" )
array2d_advance()
endwhile()

---------
Robert Dailey


On Mon, Nov 28, 2011 at 2:31 PM, Robert Dailey <rcdailey at gmail.com> wrote:

> Is it possible to have 2D arrays in CMake? As far as the core syntax is
> concerned, it seems like only 1D arrays are supported. So far I've had to
> work around this issue by using a flat array and skipping over elements
> using foreach() with a range and step.
>
> Any ideas? Thanks.
>
> ---------
> Robert Dailey
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111129/cbfe4981/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: array2d.cmake
Type: application/octet-stream
Size: 1519 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111129/cbfe4981/attachment.obj>


More information about the CMake mailing list