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 <rcdai...@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
>

Attachment: array2d.cmake
Description: Binary data

--

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