Add list SET modification analog to list GET reading
Currently I have to use REMOVE_AT
and INSERT
to emulate a SET
:
cmake_minimum_required(VERSION 3.28)
set(my_list a b c d)
set(my_index 2)
list(GET my_list "${my_index}" my_value)
set(my_value "${my_value}2") # some processing
list(REMOVE_AT my_list "${my_index}")
list(INSERT my_list "${my_index}" "${my_value}")
message(STATUS "${my_list}")
It would be great if your could just write:
cmake_minimum_required(VERSION 3.28)
set(my_list a b c d)
set(my_index 2)
list(GET my_list "${my_index}" my_value)
set(my_value "${my_value}2") # some processing
list(SET my_list "${my_index}" "${my_value}")
message(STATUS "${my_list}")
It would also eliminate the asymmetry in the interface. A GET
without SET
is very unusual. Of course, this would also be very useful together with 'FIND'.