# How downloading a single file from GitHub/GitLab using FetchContent

**URL:** https://discourse.cmake.org/t/how-downloading-a-single-file-from-github-gitlab-using-fetchcontent/11652
**Category:** Usage
**Created:** [September 12, 2024, 9:19am UTC](https://discourse.cmake.org/t/how-downloading-a-single-file-from-github-gitlab-using-fetchcontent/11652 "2024-09-12T09:19:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![RSin](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/r/57b2e6/32.png) [@RSin](https://discourse.cmake.org/u/RSin)
#### Post date: [September 12, 2024, 9:19am UTC](https://discourse.cmake.org/t/how-downloading-a-single-file-from-github-gitlab-using-fetchcontent/11652/1 "2024-09-12T09:19:30Z")

</div>

Hello all,

I’m failing using

FetchContent\_Declare(  
myArchive  
URL https://somerepo\_on\_gitlab/link\_of\_an\_archive.zip)

to provide an archive for my project.

What is downloaded is the website, not the archive.

Using a local path works as expected. The link is valid. When passed to my  
browser, the file is being downloaded.

FILE(DOWNLOAD …) fails as well - for the same reasons I guess.

How to tell CMake, to follow the given link to download that file?

Sorry for this stupid question that certainly has been answered many times.

Thanks in advance!  
Roman

---

<div class="post-metadata">

### Author: ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)
#### Post date: [September 13, 2024, 1:38pm UTC](https://discourse.cmake.org/t/how-downloading-a-single-file-from-github-gitlab-using-fetchcontent/11652/2 "2024-09-13T13:38:40Z")

</div>

FetchContent\_Populate(  
myArchive  
URL https://somerepo\_on\_gitlab/link\_of\_an\_archive.zip)

---

<div class="post-metadata">

### Author: ![RSin](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/r/57b2e6/32.png) [@RSin](https://discourse.cmake.org/u/RSin)
#### Post date: [September 16, 2024, 7:12am UTC](https://discourse.cmake.org/t/how-downloading-a-single-file-from-github-gitlab-using-fetchcontent/11652/3 "2024-09-16T07:12:01Z")

</div>

Tried it out - but the same result. I get a 13 kb file named as the archive but containing HTML code.  
I looks like it’s a login site. So, that’s the problem. I wonder, because using FetchContent for Git repositories on the same server that require the same authentification works (authentification done using OpenSSH-Agent in the Bash).
