[CMake] List in some cases ignores empty list items if they are at the beginning of the list
Svami Dhyan Nataraj
n at shaplov.ru
Sat Feb 21 11:59:07 EST 2009
List in some cases ignores empty list items if they are at the begining
of the list. Here is an example:
cmake_policy(SET CMP0007 NEW) # do not ignore empty list item in list
command SET(text "1;;2;;;;3;4;")
WHILE(${text})
list(GET text 0 str)
list(REMOVE_AT text 0)
MESSAGE(STATUS "-${str}-").
ENDWHILE(${ui_text})
running it we will get
-- -1-
-- -2-
-- -3-
empty lines are skipped
but if we add dummy non-empty at the beginning of the list, and then
remove second elements one by one, everything would work as expected:
cmake_policy(SET CMP0007 NEW) # do not ignore empty list item in list
command SET(text "1;;2;;;;3;4;")
SET(text "dummy_line;${text}")
WHILE(NOT text STREQUAL "dummy_line" )
list(GET text 1 str)
list(REMOVE_AT text 1)
MESSAGE(STATUS "-${str}-").
ENDWHILE(NOT text STREQUAL "dummy_line" )
we will get:
-- -1-
-- --
-- -2-
-- --
-- --
-- --
-- -3-
-- -4-
-- --
$ cmake --version
cmake version 2.6-patch 0
I think that is not nice behavior. If you consider it bug, I can
officially report it to the bug tracker.
PS, there is also problem with FOREACH with list with empty lines... I
do not know wether it should be so or not...
More information about the CMake
mailing list