[cmake-developers] Misleading documentation for list(APPEND ....) signature

Alan W. Irwin irwin at beluga.phys.uvic.ca
Tue Dec 17 20:52:10 EST 2013


The documentation says

list(APPEND <list> <element> [<element> ...])

That should be changed to

list(APPEND <list> [<element> ...])

The first form of documentation implies at least one element is mandatory, but this
test case shows otherwise.

software at raven> cat test.cmake
set(LIB_INSTALL_RPATH a b c)
message(STATUS "LIB_INSTALL_RPATH = ${LIB_INSTALL_RPATH}")
list(APPEND LIB_INSTALL_RPATH ${TCL_TK_ITCL_ITK_RPATH})
message(STATUS "LIB_INSTALL_RPATH = ${LIB_INSTALL_RPATH}")

The result of "cmake -P test.cmake" is

-- LIB_INSTALL_RPATH = a;b;c
-- LIB_INSTALL_RPATH = a;b;c

i.e., no error because TCL_TK_ITCL_ITK_RPATH (in my actual use case, a
list of RPATH directories with the system locations removed) is empty.
(An even simpler test case with ${TCL_TK_ITCL_ITK_RPATH} removed
altogether gives the same result as well although there is no
practical use for that.) This behaviour of list(APPEND ...) is
desireable, of course, because it means you don't have to check for an
empty variable when appending it to a list, and the unchanged result
from such an append seems reasonable as well (rather than adding an
empty element on the end).

But please fix the documentation which implies you do have to make such a
check for an empty variable.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________



More information about the cmake-developers mailing list