[CMake] How to use subdirectories that need to be installed first?

Danijar Hafner mail at danijar.com
Sat Aug 1 11:54:58 EDT 2015


After some hours of research and getting no help on Stackoverflow, I
decided to ask here on the mailing list.

I have a problem with my CMake build system. There are CMakeLists.txt files
defining runtimes or libraries or using ExternalProjects_Add() to download
and build external code. Because of dependencies, those projects have to
find each other. Now I want to have a CMakeLists.txt at the top level that
builds all those at once. In order to find a project, is must be installed.
But finding projects is already done at configuration time in CMake.

Those are two approaches I already tried:

1. Run a CMake process for every project: Using
execute_process(${CMAKE_COMMAND} ...), I can configure and build each
project after another at configure time. However, this means I always have
to run CMake after editing the code and cannot compile from within the IDE
I generated project files for.

2. Linking to CMake targets: Running a CMake process for all external
libraries is okay since I don't work on them. My own libraries could be
used by calling target_link_libraries() with their target names. However,
linking isn't enough. My libraries include directories of external
libraries. Those must be made available to the using project, as well.

How can I use libraries within my CMake project that need to be installed
first?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150801/4184eb95/attachment.html>


More information about the CMake mailing list