Replace an item in a list with cmake
To replace string in a list of strings:
list(FIND ${MYLIST} "foo bar search string" ${find_idx})
if(find_idx GREATER -1)
LIST_REPLACE(MYLIST ${find_idx} "my replace string")
endif()
depends on this macro:
macro(LIST_REPLACE LIST INDEX NEWVALUE)
list(INSERT ${LIST} ${INDEX} ${NEWVALUE})
MATH(EXPR __INDEX "${INDEX} + 1")
list (REMOVE_AT ${LIST} ${__INDEX})
endmacro(LIST_REPLACE)
Written by Ian
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Cmake
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#