[CMake] Linking hierarchy

Brad King brad.king at kitware.com
Thu May 11 15:41:42 EDT 2006


svoboda at fi.muni.cz wrote:
> It is shared library. A simple example of CMakeLists.txt is attached to 
> this mail. If you create a simple Makefile, you'll see the chaining of 
> all the libraries despite 'example' target should be dependent only on 
> 'mylib'.
[snip]
> ADD_LIBRARY(${MYLIBNAME} ${SOURCES})
> TARGET_LINK_LIBRARIES(${MYLIBNAME} ${TIFF} ${JPEG})
> 
> ADD_EXECUTABLE(example example.cc)
> TARGET_LINK_LIBRARIES(example ${MYLIBNAME})

I do not see how these extra dependencies break anything.  Either way 
when you run

   ldd example

you will see mylib, tiff, and jpeg as dependencies.  If you are building 
static libraries the chaining is needed.  It is needed for shared 
libraries on some UNIX systems too, though not Linux.

What you want is a feature which separates the *implementation* linking 
requirements from the *interface* linking requirements.  In the case of 
static libraries there is no difference, but in the case of shared 
libraries there is sometimes a difference.  We do have future plans to 
setup something like this, but may not get to it for a while.  You can 
submit a feature request here:

http://www.cmake.org/Bug

-Brad


More information about the CMake mailing list