gdraheim / zziplib

The ZZIPlib provides read access on ZIP-archives and unpacked data. It features an additional simplified API following the standard Posix API for file access
Other
62 stars 50 forks source link

test: Use CMake to download files #92

Closed jtojnar closed 4 years ago

jtojnar commented 4 years ago

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 containing file(DOWNLOAD, …) and then running them at the build time and I do not want to write any more CMake than stritly necessary.

jtojnar commented 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()
gdraheim commented 4 years ago

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.

gdraheim commented 4 years ago

see 9758d921540b28224477708a76c99ea9a1caf909