<div dir="ltr"><div><div><div><div><div><div><div><div>Hi Domen.<br><br></div>This is what helps me reason about it:<br><br></div>A string with a ';' in it is a list.<br></div>An unqouted ';' separates arguments to CMake commands.<br></div>string(REPLACE ...) simply concatenates all of its 'input' parameters.<br><br></div>So, when you expand ${list_1} in the last line, it will simply replace in the concatenation of its elements - so there's no semicolon in them, of course. What you want to do is treat the entire list_1 as a single string:<br><br></div>string(REPLACE ";" "." str_2 "${list_1}")<br><br></div>This should do what you expect.<br><br></div>Petr<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 23, 2014 at 3:49 PM, Domen Vrankar <span dir="ltr"><<a href="mailto:domen.vrankar@gmail.com" target="_blank">domen.vrankar@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hi,<br><br></div><div>I am trying to convert string to list and back with string(REPLACE) and it doesn't work as expected (tested with cmake 2.8.12 on Ubuntu 14.04 and main branch in git on Ubuntu 14.10).<br></div><div><br>cmake_minimum_required( VERSION 2.8.12 )<br>project(test_list)<br><br>set(str_1 "abc.def.ghi")<br>message("str_1: ${str_1}")<br>string(REPLACE "." ";" list_1 ${str_1})<br>message("list_1: ${list_1}")<br>string(REPLACE ";" "." str_2 ${list_1})<br>message("str_2: ${str_2}")<br><br><br></div>When I run cmake I get the following output:<br>str_1: abc.def.ghi<br>list_1: abc;def;ghi<br>str_2: abcdefghi<br><br></div>what I expected was that str_2 would be the same as str_1.<br><br></div>In case that semicolons are not used everything works as expected:<br><div><br>cmake_minimum_required( VERSION 2.8.12 )<br>project(test_list)<br><br>set(str_1 "abc.def.ghi")<br>message("str_1: ${str_1}")<br>string(REPLACE "." "'" list_1 ${str_1})<br>message("list_1: ${list_1}")<br>string(REPLACE "'" "." str_2 ${list_1})<br>message("str_2: ${str_2}")<br><br></div><div>Output:<br>str_1: abc.def.ghi<br>list_1: abc'def'ghi<br>str_2: abc.def.ghi<br><br></div><div>Is this a bug or is there a reason that ; is treated differently since it represents lists?<br></div><div>Is there any other simpler option than to run foreach on the list and convert it back to a string?<br></div><div><br></div><div>Thanks,<br></div><div>Domen<br></div></div>
<br>--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br></blockquote></div><br></div>