set_property: Document that APPEND ignores empty elements
Unlike list(APPEND lst "")
, set_property(GLOBAL APPEND PROPERTY MY_PROP "")
cannot append empty elements.
I suppose, set_property
should behave consistently like list
, possibly with a new policy?
# We can append empty elements to lists:
cmake_policy(SET CMP0007 NEW)
set(lst "BEGIN")
list(APPEND lst "")
list(APPEND lst "END")
message("lst: ${lst}")
list(LENGTH lst n)
math(EXPR n "${n} - 1")
foreach(i RANGE ${n})
list(GET lst ${i} item)
message("-${item}")
endforeach()
# We CANNOT append empty elements to properties:
set_property(GLOBAL PROPERTY MY_PROP "BEGIN")
set_property(GLOBAL APPEND PROPERTY MY_PROP "")
set_property(GLOBAL APPEND PROPERTY MY_PROP "END")
get_property(lst GLOBAL PROPERTY MY_PROP)
message("lst from MY_PROP: ${lst}")
list(LENGTH lst n)
math(EXPR n "${n} - 1")
foreach(i RANGE ${n})
list(GET lst ${i} item)
message("!${item}")
endforeach()
# Properties can contain empty elements in principle:
set_property(GLOBAL PROPERTY MY_PROP "BEGIN;;END")
get_property(lst GLOBAL PROPERTY MY_PROP)
message("lst from MY_PROP: ${lst}")
list(LENGTH lst n)
math(EXPR n "${n} - 1")
foreach(i RANGE ${n})
list(GET lst ${i} item)
message("!${item}")
endforeach()
Output of the above code is:
lst: BEGIN;;END
-BEGIN
-
-END
lst from MY_PROP: BEGIN;END
!BEGIN
!END
lst from MY_PROP: BEGIN;;END
!BEGIN
!
!END