You are wrongly using the STRING(REPLACE …) command. The right way to use it to avoid list conversion is to expand the list inside quotes (to preserve list items separators):
STRING (REPLACE "../" "" SIMPLE_LIST "${SIMPLE_LIST}") Without the quotes, all list elements are concatenated in the result string (see documentation). Another possibility is using LIST(TRANSFORM …): LIST(TRANSFORM SIMPLE_LIST REPLACE « ^\\.\\./" "") Le 12 juin 2019 à 12:22 +0200, J Decker <d3c...@gmail.com>, a écrit : > I know... just need to rebuild a new list... something like.... > > set( _ALL_INCLUDES ) > foreach( INC ${ALL_INCLUDES}) > string(REPLACE "../" "" INC ${INC}) > LIST( APPEND _ALL_INCLUDES ${INC} ) > endforeach( INC ) > set( ALL_INCLUDES ${_ALL_INCLUDES}) > > > On Wed, Jun 12, 2019 at 3:10 AM J Decker <d3c...@gmail.com> wrote: > > > I'm collecting sources and includes into a parent scope variable, and > > > then attempting to use that variable to reference the right sources. > > > Sources get added to the list as ../(theirpath)/(source) so in the parent > > > level I can simply replace "../" with "" and then they are relative in > > > the right place. > > > This works; as far as, the includes, sources and defines get all > > > collected into the top level, but when i try to remove the ../ the list > > > gets converted into a string. > > > > > > # Create a list of things > > > set( SIMPLE_LIST -I../lib1/include -I../lib2/include -I../lib3/include ) > > > # set a variable using that list... > > > set( AMALG_COMMAND echo ${SIMPLE_LIST} ) > > > # this outputs > > > COMMAND:echo;-I../lib1/include;-I../lib2/include;-I../lib3/include > > > message( "COMMAND:${AMALG_COMMAND}") > > > > > > # replace ../ with nothing > > > STRING( REPLACE "../" "" SIMPLE_LIST ${SIMPLE_LIST} ) > > > # re-set a variable with the eventual command to run > > > set( AMALG_COMMAND echo ${SIMPLE_LIST} ) > > > # this outputs COMMAND:echo;-Ilib1/include -Ilib2/include -Ilib3/include > > > message( "COMMAND:${AMALG_COMMAND}") > > > > > > When that final command actually gets run in a > > > add_custom_command( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/out.c COMMAND > > > ${AMALG_COMMAND} ) > > > > > > Then the command is 'echo "-Ilib1/include -Ilib2/include -Ilib3/include"' > > > which is incorrect. > > > > > > > > > I tried first LIST(JOIN) but that defiantly makes a string and doesn't > > > help. > > > string(REPLACE " " ";" SIMPLE_LIST ${SIMPLE_LIST}) to try and reverse it > > > back to a list doesn't seem to help... > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > https://cmake.org/mailman/listinfo/cmake
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: https://cmake.org/mailman/listinfo/cmake