Use includes of adjacent subproject in cmake

api, cmake, include, subdirectory

Solution

Encode the include directories in the target itself:

http://www.cmake.org/cmake/help/git-master/manual/cmake-buildsystem.7.html#include-directories-and-usage-requirements

That doc is new, but the target_include_directories command exists since CMake 2.8.11. Use it with the INTERFACE or PUBLIC option.

Problem

I develop a project which consisting of several shared libraries and build it with CMake. Each library is built via `add_subdirectory()`. What is the best way to add all the API headers of the fist library to the CMakeLists.txt of the second?

Original source