[CMake] ExternalProject and libraries again

Bruce Stephens bruce.r.stephens at gmail.com
Wed Mar 9 16:22:14 EST 2016


(This is really a continuation of a discussion from 25/26 January.)

I'm still confused about ExternalProject_Add and libraries.

I'd like to get to the point where I (or more likely a process
somewhere) can check out a project, then run cmake and ninja (or make
or whatever) and have that build the project and its dependencies.

Concretely, suppose I have a trivial project that uses libcrypto from
OpenSSL and I have a local repository with OpenSSL with some patches
to build it with cmake.

One suggestion is that I can use ExternalProject_Add to download and
build this openssl which can then export a FindOpenSSL.cmake script.
But that happens too late, doesn't it?

When I run cmake on my project it can't use find_library and things to
find the right library files since those won't exist until I actually
build the project?

Hence hunter's approach of downloading and building projects during
the cmake process, I imagine. Which feels a bit icky, but maybe it's
really the most straightforward way to do it?

I think I might resort to some trickery: build the various dependent
things on the platforms I care about, and then have my main project
just know about where the interesting targets are relative to
BINARY_DIR for each of the external projects. (Or use the approach of
hunter, or use some build script.)

Am I missing something obvious? It feels like I must be somehow.


More information about the CMake mailing list