file(STRINGS) documentation is unclear and incorrect
https://cmake.org/cmake/help/v3.16/command/file.html?highlight=file#reading is unclear and incorrect.
It says Parse a list of ASCII strings from <filename>
but "Parse a list" is not defined, and in CMake that can be expected to split the input at white space and at semicolon. Instead, a description something like what is used in the example would be clearer, e.g. "Stores a list in the variable <variable>
in which each item is a line from the input file <filename>
".
Also, the rest of the description uses "strings" when it means "lines", e.g.
Consider only strings that match the given regular expression.
where I think it means "Consider only lines that match ...".
Also, LIMIT_COUNT
is incorrectly saying Limit the number of distinct strings to be extracted.
, but "distinct" has nothing to do with what it does, as the following transcript shows (the last script uses LIMIT_COUNT 4
but clearly adds the same string more than once, i.e. the entries are not distinct
:
bash$ cat theFile.txt
foo
bar
baz
foo
blip
bork
bash$ cmake -P f1.cmake
-- theList="foo;bar;baz;foo;blip;bork"
bash$ cat f1.cmake
file(STRINGS "theFile.txt" theList)
message(STATUS "theList=\"${theList}\"")
bash$ cmake -P f2.cmake
-- theList="foo;bar;baz;foo"
bash$ cat f2.cmake
file(STRINGS "theFile.txt" theList LIMIT_COUNT 4)
message(STATUS "theList=\"${theList}\"")
bash$ cmake --version
cmake version 3.16.3
CMake suite maintained and supported by Kitware (kitware.com/cmake).
bash$