Closed jtojnar closed 4 years ago
Here is an example of CMake macro for downloading at build time but it is ugly and downloads to some convoluted path so unlike plain file(DOWNLOAD …)
distros cannot easily recreate it.
macro(download name url hash)
ExternalProject_Add(
"asset-${name}" # needs to be different or it will crash https://gitlab.kitware.com/cmake/cmake/-/issues/20600
URL "${url}"
URL_HASH "${hash}"
DOWNLOAD_NO_EXTRACT TRUE
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
ExternalProject_Get_Property("asset-${name}" DOWNLOADED_FILE)
list(APPEND TEST_FILES ${DOWNLOADED_FILE})
endmacro()
Yes, the problem needs be solved with downloading the files upfront and showing the testsuite a path where it can find the files. Having a cmake target definition is a good thing but may be that can be solved in an easier fashion. I did not know about ExternalProject so far - I need to read up on it.
see 9758d921540b28224477708a76c99ea9a1caf909
test: Use CMake to download files
It will make it easier for packagers to run tests.
I would prefer if it was downloaded during build instead of during project configuration with CMake but
ExternalData
module requires URLs in static format,ExternalProject
is ugly and downloads the files into a weird destination. Nicest option is re-creating the download part from ExternalProject but that is basically generating CMake files containingfile(DOWNLOAD, …)
and then running them at the build time and I do not want to write any more CMake than stritly necessary.