[CMake] Get include directories for package dependencies

Alexander Neundorf a.neundorf-work at gmx.net
Thu Aug 16 15:23:19 EDT 2007


On Wednesday 15 August 2007 21:08, Kyle Heath wrote:
> I have read the Mastering CMake book and I'm still having trouble
> getting inter package dependencies working (in source trees).
>
> The Situation:
> I have a CMake managed static lib package called libA with a
> libAConfig.cmake file as described in section 6.7 of Mastering CMake.
> I have another Cmake managed package libB also with a libBConfig.cmake
> file that uses package libA.  I have another cmake project that
> generates an executable that directly depends only on libB.
>
> The Problem:
> The header directories for libB are included for the executable target
> but not those of libA (on which libB depends).  The
> EXPORT_LIBRARY_DEPENDENCIES macro doesn't record any of the include
> directories or the name of the package so I don't see any mechanism
> for CMake to walk the dependency chain to collect this information.
>
> The Question:
> For CMake to handle package dependencies correctly, it must have a way
> to collect all the required header include directories by walking the
> dependency chain.  This doesn't seem to happen by default.  What is
> the mechanism to do this correctly?

There are different ways to do this.

You can either write a FindLibA.cmake, which searches the LibAConfig.cmake 
file and also searches the include directory and sets it.
Or you can embed a variable which holds the required include directory in the 
LibAConfig.cmake file, by using FILE(APPEND LibAConfig.cmake ....) after the 
EXPORT_LIBRARY_DEPENDENCIES().

Bye
Alex


More information about the CMake mailing list