[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-finance-apps
Subject:    Re: Phase 2 commits - cmake link interface
From:       Ralf Habacker <ralf.habacker () freenet ! de>
Date:       2020-08-24 9:41:33
Message-ID: 46d46f7d-12e7-15bf-6bc7-b1e4e2622654 () freenet ! de
[Download RAW message or body]

Am 24.08.20 um 05:47 schrieb Prasun Kumar:
>     target_link_libraries(ktoblzcheck PRIVATE stdc++ ${LIBS} 
> 
> 
> What does 'PRIVATE' do here? The docs say " Libraries and targets 
> following |PRIVATE| are linked to, but are not made part of the link 
> interface."
> which I didn't fully understand.
> 
I quote from 
https://cmake.org/cmake/help/latest/command/target_link_libraries.html

The PUBLIC, PRIVATE and INTERFACE keywords can be used to specify both 
the link dependencies and the link interface in one command. Libraries 
and targets following PUBLIC are linked to, and are made part of the 
link interface. Libraries and targets following PRIVATE are linked to, 
but are not made part of the link interface. Libraries following 
INTERFACE are appended to the link interface and are not used for 
linking <target>.

The link interface of a target is used by cmake to find out definitions 
and libraries required to link a library or executable which depends on 
a given target. See 
https://cmake.org/cmake/help/v3.7/prop_tgt/LINK_INTERFACE_LIBRARIES.html 
for more details.

If stdc++ would be added PUBLIC, then any client following the how to 
"Using ktoblzcheck" at 
https://sourceforge.net/p/ktoblzcheck/code/ci/master/tree/README.md 
would also link to stdc++ by default, which is not wanted except the 
case that the public api of ktoblzcheck uses some structures/classes 
from stdc++, which requires that clients must link to stdc++ to avoid 
undefined symbol errors or similar.

Regards
Ralf
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic