[CMake] How to depend on external cmake projects?

Robert Dailey rcdailey.lists at gmail.com
Sat Aug 22 22:43:17 EDT 2015


On Mon, Aug 17, 2015 at 10:17 AM, James Johnston
<JamesJ at motionview3d.com> wrote:
> Well, you'd do this in conjunction with ExternalProject_Add.  A well-written
> CMake external project will provide a <project>Config.cmake file which you
> will then find using find_package.

After toying around with this idea for a bit, I've found out that
ExternalProject_Add() actually builds the project from a custom target
within Visual Studio (I'm using VS as my generator). However,
find_package() works at CMake configure time, so this is a chicken &
egg problem. find_package() won't work because the external project
has not been built yet.

How do you solve this problem?

> A high-level CMake project that does nothing but call ExternalProject_Add;
> this is called a superbuild.  Your own CMake projects will be
> ExternalProjects to this high-level project and the superbuild would pass
> the location to your project via -D<project>_DIR=<location> so that
> find_package can locate the Config file.

I'm not sure I understand this. This smells related to my question
above, maybe an answer even. Can you clarify/go into more detail?
Thanks a bunch.


More information about the CMake mailing list