Nested list support is thoroughly broken
There are only a few cases where it works as expected, for example this:
set(LIST "x\\\;y\;a\\\;b;q\\\;w\;a\\\;s")
foreach(X IN LISTS LIST)
string(APPEND STR "(")
foreach(Y IN LISTS X)
string(APPEND STR "(")
foreach(Z IN LISTS Y)
string(APPEND STR "${Z}")
endforeach()
string(APPEND STR ")")
endforeach()
string(APPEND STR ")")
endforeach()
message("${STR}")
Produces expected result:
((xy)(ab))((qw)(as))
In most other context the support is broken:
list(APPEND LIST "x;y;z" "a;b;c")
list(LENGTH LIST LEN)
message("${LEN}") # result: 6, expected: 2
function(test)
list(LENGTH ARGV LEN)
message("${ARGV}") # result: x;y;z, expected: x\;y;z
message("${ARGC}") # result: 2, expected: 2
message("${LEN}") # result: 3, expected: 2
endfunction()
test("x;y" "z")
Also, the set
function and the lack of list(SET)
function may encourage broken lists:
# Broken if source directory contains a semicolon.
set(SOURCES main.c "${PROJECT_BINARY_DIR}/config.c")
# This would work fine.
list(SET SOURCES main.c "${PROJECT_BINARY_DIR}/config.c")
Edited by Nikita Churaev