MantisBT - CMake
View Issue Details
0006846CMakeCMakepublic2008-04-17 17:392008-04-21 17:59
Pino Toscano 
 
normalminoralways
closedno change required 
 
 
0006846: extra unneeded libraries are added
Let's say to have the following (simplified) CMakeLists.txt:

| add_library(mylib SHARED libsources...)
| target_link_libraries(mylib lib1 lib2)
|
| add_executable(myapp appsources...)
| target_link_libraries(myapp mylib)

Then, when linking myapp, "-llib1 -llib2" is added on the linking line.

The point is, is lib1 and lib2 are _private_ dependancies for mylib, why should they be added for myapp as well? After all, if myapp would need to use symbols from any of those, it must explicitely link to them (thus the developer must manually add the dependancy).

Tested with CMake 2.4.8, and the "Unix Makefiles" generator (default on unix).
No tags attached.
Issue History
2008-04-17 17:39Pino ToscanoNew Issue
2008-04-18 14:10Michael LampeNote Added: 0011437
2008-04-18 14:15Pino ToscanoNote Added: 0011438
2008-04-21 17:59Bill HoffmanStatusnew => closed
2008-04-21 17:59Bill HoffmanNote Added: 0011465
2008-04-21 17:59Bill HoffmanResolutionopen => no change required

Notes
(0011437)
Michael Lampe   
2008-04-18 14:10   
Your rationale fails for static linking.
(0011438)
Pino Toscano   
2008-04-18 14:15   
Where do you see "static linking" in the cmake snippet above?
Supposing that represents a real example, why should cmake even think about "static linking" when I'm explicitely requesting the creation of *dynamic* library?
(0011465)
Bill Hoffman   
2008-04-21 17:59   
This is expected behavior, but in cmake 2.6 there is now a way to change it with this target property:

http://www.cmake.org/HTML/cmake-2.6.html#command_LINK_INTERFACE_LIBRARIES [^]