# Using ExternalProject to download a header-only library

**URL:** https://discourse.cmake.org/t/using-externalproject-to-download-a-header-only-library/3046
**Category:** Code
**Created:** [March 30, 2021, 12:39pm UTC](https://discourse.cmake.org/t/using-externalproject-to-download-a-header-only-library/3046 "2021-03-30T12:39:10Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![PaulMoore](https://discourse.cmake.org/user_avatar/discourse.cmake.org/paulmoore/32/1333_2.png) [@PaulMoore](https://discourse.cmake.org/u/PaulMoore)
#### Post date: [March 31, 2021, 10:50am UTC](https://discourse.cmake.org/t/using-externalproject-to-download-a-header-only-library/3046/5 "2021-03-31T10:50:36Z")

</div>

Thanks. So is reading properties the “correct” way of doing this? You seem to be saying it’s internal details - or am I misunderstanding you?

Taking a step back here, am I approaching my problem in the wrong way altogether? Basically, all I want to do is:

1. Download and unpack a file from a URL - I don’t care where it gets unpacked, but see the next point.
2. Add a reference to the unpacked location of a particular `.h` file in the archive to my project.

Doing this in a shell script would be easy, but the result wouldn’t be portable, and I’d have to deal with a bunch of admin like picking somewhere to download and unpack the file, and dealing with errors. I get the feeling that I’m getting caught in a process of making more and more complex solutions, simply because I’m missing something basic - but I don’t know what 🙁 Unfortunately, none of the tutorials I’ve read really cover this sort of situation.

It sounds like `FetchContent` might be closer to what I want, but trying to work out what to do based on the documentation, I got as far as

```auto
include(FetchContent)
FetchContent_Populate(SQLite
    URL https://sqlite.org/2021/sqlite-amalgamation-3350300.zip
)

target_include_directories(MyApp PUBLIC "${SQLite_SOURCE_DIR}")

```

and I’m still getting “Cannot open include file ‘sqlite3.h’”. The library did get downloaded, it’s in `build/sqlite-src`, and it did get downloaded at configure time, but if I add a `message()` call, it looks like the variable `SQLite_SOURCE_DIR` is empty… (And adding `FetchContent_GetProperties(SQLite)` mde no difference, either).

(By the way, another reason I want to properly understand all this is that I have another situation where I think `ExternalProject` is what I need, but I need a custom command because the project isn’t CMake-based. I don’t know how to communicate information back from that command to my CMake script, so that it knows what to link into my project and where to find headers, etc. I think that’s _again_ because I don’t really understand what’s going on - but I’ll ask that question separately, once I better understand how to handle the example here, as I think that’ll make it easier to formulate the next question).

---

_[View the full topic](https://discourse.cmake.org/t/using-externalproject-to-download-a-header-only-library/3046)._
