FetchContent does not support properly URLs with brackets

Hello,

I tried to fecth this URL : https://ecss.nl/wp-content/uploads/2020/04/ECSS_SMP_Issue1(2March2020).zip

I think that the correct way would be to write something like:

FetchContent_Declare(

ecss_smp

URL “https://ecss.nl/wp-content/uploads/2020/04/ECSS_SMP_Issue1(2March2020).zip

URL_HASH MD5=973D4CA21FDAC204A4419CD06CD65185

DOWNLOAD_EXTRACT_TIMESTAMP true

)

I tried to use single quotes, double quotes, to escape the brackets with a backslash, …, but it does not work.

The only way to make it work is to escape “(” and “)” with %28 and %29:

FetchContent_Declare(

ecss_smp

URL https://ecss.nl/wp-content/uploads/2020/04/ECSS_SMP_Issue1%282March2020%29.zip

URL_HASH MD5=973D4CA21FDAC204A4419CD06CD65185

DOWNLOAD_EXTRACT_TIMESTAMP true

)

This workaround works but it is not very intuitive.

Yannick

I suspect this might be because the URL ends up in a shell command line where () makes a subshell. I think some documentation updates would be good here.

Oh, this is for a plain file download. That is not a git clone where a shell might be involved. Hrm.

Cc: @craig.scott

This turned out to be a rather interesting case. Internally, FetchContent and ExternalProject implement the download with a foreach() loop over the URLs. Undocumented behavior of that command is causing the parentheses to act as a form of list item boundary (I opened a new issue to cover that undocumented behavior). I think I’ll need to make a small change to the ExternalProject implementation so that it avoids this particular case.

1 Like

MR 9193 fixes the underlying problem where special characters in URLs would interfere with CMake’s list handling.