9
Necesitaba reemplazar un valor en una lista de CMake, sin embargo, no parece haber ningún soporte para esta operación de lista.Reemplazo de valores en listas de CMake
Yo he llegado con este código:
macro (LIST_REPLACE LIST INDEX NEWVALUE)
list (REMOVE_AT ${LIST} ${INDEX})
list (LENGTH ${LIST} __length)
# Cannot insert at the end
if (${__length} EQUAL ${INDEX})
list (APPEND ${LIST} ${NEWVALUE})
else (${__length} EQUAL ${INDEX})
list (INSERT ${LIST} ${INDEX} ${NEWVALUE})
endif (${__length} EQUAL ${INDEX})
endmacro (LIST_REPLACE)
# Example
set (fubar A;B;C)
LIST_REPLACE (fubar 2 "X")
message (STATUS ${fubar})
¿Tiene usted alguna idea mejor forma de lograr eso?