Using ExternalProject to download a header-only library

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 :slightly_frowning_face: 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

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).