How does one set up an External project to download a link that isn't a .tgz file?
For example Catch provides a release that is a single header distribution. I would like to just download this rather than the git repo or the .tgz release. But I haven't figured out how to tell CMake to do this.
I would like to do something like:
Include(ExternalProject)
ExternalProject_Add(
catch
PREFIX ${CMAKE_BINARY_DIR}/catch
URL https://github.com/philsquared/Catch/releases/download/v1.9.6/catch.hpp ${CMAKE_BINARY_DIR}/catch
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
LOG_DOWNLOAD ON
)
This fails as URL assumes that url is a compressed tar file. I have tried various variants of the DOWNLOAD_COMMAND without any success either.
Use DOWNLOAD_NO_EXTRACT option of ExternalProject_Add
:
Just download the file and do not extract it; the full path to the downloaded file is available as <DOWNLOADED_FILE>.
Code example:
ExternalProject_Add(
catch
PREFIX ${CMAKE_BINARY_DIR}/catch
URL https://github.com/philsquared/Catch/releases/download/v1.9.6/catch.hpp
DOWNLOAD_NO_EXTRACT 1
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
File will be downloaded into <prefix>/src
directory.
If use LOG_DOWNLOAD option alongside with DOWNLOAD_NO_EXTRACT, you need CMake 3.9 for work correctly. See these bugreports: https://gitlab.kitware.com/cmake/cmake/issues/16544, https://gitlab.kitware.com/cmake/cmake/issues/17046.