I’m trying to use FetchContent_Declare and DOWNLOAD_COMMAND to download my dependency.
My dependency is a zip file(which contains a big pre-built library) on release of my private github repo, so I’m using github cli to download it. With DOWNLOAD_COMMAND, I can download it successfully.
But I cannot find a way to extract it since both CONFIGURE_COMMAND and BUILD_COMMAND are all disabled for FetchContent, and I’m not sure if UPDATE_COMMAND or PATCH_COMMAND is for this kind of situation.
FetchContent with URL can extract archives automatically and put the output to SOURCE_DIR, so I wonder if there’s any method to do it with DOWNLOAD_COMMAND.
Is it possible? Or should I use ExternalProject or execute_process instead?
Why are you using DOWNLOAD_COMMAND? Is giving a URL via the URL parameter not working if you provide it with a username and token? CMake will then automatically generate the download, verification, and extraction.
If you have to use the github downloader, you’ll have to extract out the tarball like the template script used for ExternalProject does. You can copy and use that while replacing file(DOWNLOAD) as a start.
If possible I don’t want to use token. Although I really should learn it, but I just have no idea where should I store it and pass it into the script, and it seems like I have to do it every time when I(or my coworker) need to develop on another computer. Login just looks much simpler. Maybe it just handles the token for me, but that’s exactly what I want.
What do you mean “the template script for ExternalProject”? Is it the ExternalProject.cmake script from cmake source code?
Are you referring to ExternalProject-download.cmake.in? I found that there’s a file(DOWNLOAD).
I think I’m going to try this way.
Thank you for your help!