[CMake] Proposal: extra option PRIVATE for target_link_libraries
Marcel Loose
loose at astron.nl
Wed Dec 23 08:59:46 EST 2009
On Wed, 2009-12-23 at 14:36 +0100, Alexander Neundorf wrote:
> On Wednesday 23 December 2009, Marcel Loose wrote:
> > Hi all,
> >
> > I suggested this in the quite long thread "third party library
> > dependencies", but it may have been overlooked. Hence, I started a new
> > thread.
> >
> > Upon (re)reading the Mandriva page
> > http://wiki.mandriva.com/en/Overlinking, I was thinking: maybe the issue
> > of overlinking can be solved more or less the same way as pkg-config
> > does: i.e. by defining private dependencies. This could be an extra
> > option to target_link_libraries.
> > Something like:
> >
> > target_link_libraries(mylib public1 public2 PRIVATE private1 private2)
>
> Assuming that public1 and public2 are libraries also built with cmake, that
> can be done already today:
>
> add_library(public1 ...)
> target_link_libraries(public1 private1)
> target_link_libraries(public1 LINK_INTERFACE_LIBRARIES "")
>
> add_library(public2 ...)
> target_link_libraries(public2 private2)
> target_link_libraries(public2 LINK_INTERFACE_LIBRARIES "")
>
> install(TARGETS public1 public2 ... EXPORT MyPublicLibs)
> install(EXPORT ...)
>
>
> Then later on, when loading these exported targets, you will get what you
> want. If public1/2 are shared libs, their "link interface" will be empty. If
> they are static, you will link against everything they have been "linked"
> against, independent of the LINK_INTERFACE_LIBRARIES (which is used only for
> shared libs).
>
> Alex
Hi Alex,
Seems I must unconciously have felt that LINK_INTERFACE_LIBRARIES had
something to do with the problem of overlinking I'm trying to solve
right now. Funny, this morning I came to the conclusion that I probably
wouldn't need LINK_INTERFACE_LIBRARIES (see thread: [Q]
LINK_INTERFACE_LIBRARIES and the like), and now it seems I will.
Guess I'll have to study carefully how this whole import/export and
interface libs stuff works. Could you point me to some examples?
Best regards,
Marcel Loose.
More information about the CMake
mailing list