View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006846CMakeCMakepublic2008-04-17 17:392008-04-21 17:59
ReporterPino Toscano 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0006846: extra unneeded libraries are added
DescriptionLet'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).
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0011437)
Michael Lampe (reporter)
2008-04-18 14:10

Your rationale fails for static linking.
(0011438)
Pino Toscano (reporter)
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 (manager)
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 [^]

 Issue History
Date Modified Username Field Change
2008-04-17 17:39 Pino Toscano New Issue
2008-04-18 14:10 Michael Lampe Note Added: 0011437
2008-04-18 14:15 Pino Toscano Note Added: 0011438
2008-04-21 17:59 Bill Hoffman Status new => closed
2008-04-21 17:59 Bill Hoffman Note Added: 0011465
2008-04-21 17:59 Bill Hoffman Resolution open => no change required


Copyright © 2000 - 2018 MantisBT Team