Appending to lists and macros do not work together
For the following code:
macro(add_to_array arr1)
set(cflags ${arr1})
list(APPEND cflags "myitem")
message("Resulting list inside macro = ${cflags}")
endmacro()
set(my_array "list1")
list(APPEND my_array "list2")
message("Resulting list before calling the macro = ${my_array}")
add_to_array(${my_array})
message("Resulting list outside of macro = ${my_array}")
CMake prints:
Resulting list before calling the macro = list1;list2
Resulting list inside macro = list1;myitem
Resulting list outside of macro = list1;list2
Why is the update outside of the macro not seen inside? Also if I start modifying the passed variable inside the macro all kinds of very strange things start to happen.