My code is extremely simple, it’s a single C file:
cmake_minimum_required(VERSION 3.19) project(MyApp) add_executable(MyApp myapp.c)
But I want to
#include a header from an external library (specifically SQLite). There’s nothing I need to link to, I just want the include. (This is a stripped down version of a project where I’m writing a SQLite extension, which is a shared library target that needs the SQLite header).
I’m extremely new with CMake, so I was floundering around a bit trying to find out where to start (this isn’t a scenario that gets covered in tutorials!) but I discovered
ExternalProject_Add, which seems like it should work for me:
include(ExternalProject) ExternalProject_Add(SQLite URL https://sqlite.org/2021/sqlite-amalgamation-3350300.zip CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" )
I’ve given empty commands for everything as I don’t need to configure, build or install (or if I do, I don’t know how to, as this is just a zipfile with a couple of
That does everything I want (downloads and unpacks the file) but I don’t know how to tell my main project where to find the include directory (which is buried in the build directory somewhere CMake chooses to put it). I think this is communicated via properties on the external project, but I don’t know what properties I need or how to find them (if they are automatically set) or set them (if I need to do that myself via a configure command).
The simpler tutorial examples using a library in a subdirectory don’t help much here, as they assume the library is built with CMake, and don’t explain how the sub-project communicates with the main project.
It’s possible this is covered in the documentation, but I find it awfully hard to find “how things work” information like this in the manuals - so a pointer to where to look, or better still a summary of the important points, would be very much appreciated.