On 11/30/2011 12:28 AM, Robert Dailey wrote: > 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
Just some spontaneous questions/remarks: - Why do you use macros instead of functions? - What's about cleaning up the numerous helper variables, e.g. by an additional array2d_cleanup() function or the like? - In array2d_begin_loop(), couldn't you rearrange the parameters, array2d_begin_loop(advanced "fruit;animal" ${two_dee_array}), use LIST(LENGTH var_names _array2d_width) and take ARGN as the array? Regards, Michael > 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 -- 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