Hi,

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).

cmake_minimum_required( VERSION 2.8.12 )
project(test_list)

set(str_1 "abc.def.ghi")
message("str_1: ${str_1}")
string(REPLACE "." ";" list_1 ${str_1})
message("list_1: ${list_1}")
string(REPLACE ";" "." str_2 ${list_1})
message("str_2: ${str_2}")


When I run cmake I get the following output:
str_1: abc.def.ghi
list_1: abc;def;ghi
str_2: abcdefghi

what I expected was that str_2 would be the same as str_1.

In case that semicolons are not used everything works as expected:

cmake_minimum_required( VERSION 2.8.12 )
project(test_list)

set(str_1 "abc.def.ghi")
message("str_1: ${str_1}")
string(REPLACE "." "'" list_1 ${str_1})
message("list_1: ${list_1}")
string(REPLACE "'" "." str_2 ${list_1})
message("str_2: ${str_2}")

Output:
str_1: abc.def.ghi
list_1: abc'def'ghi
str_2: abc.def.ghi

Is this a bug or is there a reason that ; is treated differently since it
represents lists?
Is there any other simpler option than to run foreach on the list and
convert it back to a string?

Thanks,
Domen
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to