Language: arguments split around unquoted `(` characters
The docs for foreach()
state the following:
foreach(<loop_var> <items>) <commands> endforeach()
where is a list of items that are separated by semicolon or whitespace.
However, it appears that other characters also end up acting as list separators if <items>
is an unquoted value. Consider the following example:
# Same behavior if we use the old form without "IN ITEMS" too
foreach(url IN ITEMS https://ecss.nl/wp-content/uploads/2020/04/ECSS_SMP_Issue1(2March2020).zip)
message(STATUS "url = ${url}")
endforeach()
The output from the above shows the surprising result:
CMake Warning (dev) at checker.cmake:3:
Syntax Warning in cmake code at column 92
Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.
-- url = https://ecss.nl/wp-content/uploads/2020/04/ECSS_SMP_Issue1
-- url = (
-- url = 2March2020
-- url = )
-- url = .zip
The warning gives a clue as to what is happening. The example can be easily modified to give the desired result by quoting the URL, but since the foreach()
docs don't mention this case, it isn't obvious that one needs to protect against this sort of problem. See this forum post where this was first noticed in an example involving FetchContent/ExternalProject.
Edited by Craig Scott