# Is there any method to extract downloaded archives when using FetchContent\_Declare with DOWNLOAD\_COMMAND?

**URL:** <https://discourse.cmake.org/t/is-there-any-method-to-extract-downloaded-archives-when-using-fetchcontent-declare-with-download-command/4026>\
**Category:** Code\
**Created:** [September 3, 2021, 11:05am UTC](https://discourse.cmake.org/t/is-there-any-method-to-extract-downloaded-archives-when-using-fetchcontent-declare-with-download-command/4026 "2021-09-03T11:05:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![you74674](https://discourse.cmake.org/user_avatar/discourse.cmake.org/you74674/32/1746_2.png) [@you74674](https://discourse.cmake.org/u/you74674)\
**Post date:** [September 3, 2021, 11:05am UTC](https://discourse.cmake.org/t/is-there-any-method-to-extract-downloaded-archives-when-using-fetchcontent-declare-with-download-command/4026/1 "2021-09-03T11:05:23Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [September 3, 2021, 12:15pm UTC](https://discourse.cmake.org/t/is-there-any-method-to-extract-downloaded-archives-when-using-fetchcontent-declare-with-download-command/4026/2 "2021-09-03T12:15:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![you74674](https://discourse.cmake.org/user_avatar/discourse.cmake.org/you74674/32/1746_2.png) [@you74674](https://discourse.cmake.org/u/you74674)\
**Post date:** [September 3, 2021, 1:20pm UTC](https://discourse.cmake.org/t/is-there-any-method-to-extract-downloaded-archives-when-using-fetchcontent-declare-with-download-command/4026/3 "2021-09-03T13:20:39Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [September 3, 2021, 1:58pm UTC](https://discourse.cmake.org/t/is-there-any-method-to-extract-downloaded-archives-when-using-fetchcontent-declare-with-download-command/4026/4 "2021-09-03T13:58:44Z")

</div>

If you copy and replace `file(DOWNLOAD)`, you can just `execute_process` the github tool in its place.

---

<div class="post-metadata">

**Author:** ![you74674](https://discourse.cmake.org/user_avatar/discourse.cmake.org/you74674/32/1746_2.png) [@you74674](https://discourse.cmake.org/u/you74674)\
**Post date:** [September 3, 2021, 2:36pm UTC](https://discourse.cmake.org/t/is-there-any-method-to-extract-downloaded-archives-when-using-fetchcontent-declare-with-download-command/4026/5 "2021-09-03T14:36:46Z")

</div>

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!
