[Cmake] module dependencies

Brad King brad.king at kitware.com
Thu Aug 19 08:08:33 EDT 2004


Dekeyser, Kris wrote:
> Hi,
> 
> While CMake's TARGET_LINK_LIBRARIES command nicely resolves
> sub-dependencies, it does not add the module's library target directory
> (LINK_DIRECTORIES) nor the module's exported header file directories
> (INCLUDE_DIRECTORIES) to the current project.
> 
> Is there an easy way to do have CMake add the proper include directories for
> the module dependencies?

Automatic include directory propagation may be very tricky.  The 
"exported" include directories should probably be set as a target 
property on each library by the CMakeLists.txt file author.  Then CMake 
would add these directories when building the source files of any 
targets that link against the library.  Getting the ordering right might 
be an issue, though.

Automatic link directory propagation is certainly possible to implement. 
   Please add these ideas as feature requests here:

http://www.cmake.org/Bug

and you will automatically be notified of progress.  Until a release of 
CMake includes such features, you can try one of these options:

For a single project with multiple libraries, we usually set 
LIBRARY_OUTPUT_PATH so that all libraries are put in the same place in 
the build tree.  Then only one link directory is needed.  Also, it is 
usually preferable to have the whole source tree use a single set of 
include directories.

For multiple related projects each of which builds on its own and looks 
for the others, you can use the PackageConfig.cmake/FIND_PACKAGE 
mechanism described in section 6.7 of the book "Mastering CMake". 
Several open-source projects (www.vtk.org, www.itk.org, 
www.paraview.org, vxl.sourceforge.net) include implementations of this 
mechanism.

-Brad


More information about the Cmake mailing list