[CMake] linking question

Bill Newcomb bnewcomb at nvidia.com
Thu Apr 16 17:53:37 EDT 2015


This solved the cmake end of this.  Thanks!

B.

On 04/15/2015 11:53 PM, Petr Kmoch wrote:
> Hi Bill.
>
> Probably the easiest way to set the interface properties to just what
> you need is to use the PUBLIC (which is the default), PRIVATE and
> INTERFACE keywords when specifying dependencies. In your case, you'd
> apply them like this:
>
> add_library(joe STATIC joe.c joe_a.c)
> add_library(fred SHARED fred.c fred_a.c)
> target_link_libraries(fred PRIVATE joe)  # PRIVATE means it will not
> form part of the transitive linking interface
>
> add_executable(mike mike.c)
> # mike only contains calls to functions in fred
> target_link_libraries(mike fred)
>
> I hope this helps.
>
> Petr
>
>
> On Thu, Apr 16, 2015 at 12:07 AM, Bill Newcomb <bnewcomb at nvidia.com
> <mailto:bnewcomb at nvidia.com>> wrote:
>
>     The following is all on Linux (with gcc, gnu binutils, etc).
>
>     I'm trying to build libfred.so that uses code from libjoe.a, but I
>     want libfred.so to be complete, i.e. I don't want any program that I
>     build that links to libfred.so also need libjoe.a.
>
>     Then I want to build executable mike that is dynamically linked with
>     libfred.so .  However, the link script for mike puts libjoe.a on the
>     command line.
>
>     add_library(joe STATIC joe.c joe_a.c)
>     add_library(fred SHARED fred.c fred_a.c)
>     target_link_libraries(fred joe)
>
>     add_executable(mike mike.c)
>     # mike only contains calls to functions in fred
>     target_link_libraries(mike fred)
>
>
>     The docs give me the impression that I should set the
>     INTERFACE_LINK_LIBRARIES property on moo to override the inherited
>     transitive dependencies, but setting it to "" has no effect.  Same
>     for LINK_INTERFACE_LIBRARIES.
>
>     Any idea how to make this work?
>
>     Thanks,
>     B.
>
>     ------------------------------__------------------------------__-----------------------
>     This email message is for the sole use of the intended recipient(s)
>     and may contain
>     confidential information.  Any unauthorized review, use, disclosure
>     or distribution
>     is prohibited.  If you are not the intended recipient, please
>     contact the sender by
>     reply email and destroy all copies of the original message.
>     ------------------------------__------------------------------__-----------------------
>     --
>
>     Powered by www.kitware.com <http://www.kitware.com>
>
>     Please keep messages on-topic and check the CMake FAQ at:
>     http://www.cmake.org/Wiki/__CMake_FAQ
>     <http://www.cmake.org/Wiki/CMake_FAQ>
>
>     Kitware offers various services to support the CMake community. For
>     more information on each offering, please visit:
>
>     CMake Support: http://cmake.org/cmake/help/__support.html
>     <http://cmake.org/cmake/help/support.html>
>     CMake Consulting: http://cmake.org/cmake/help/__consulting.html
>     <http://cmake.org/cmake/help/consulting.html>
>     CMake Training Courses: http://cmake.org/cmake/help/__training.html
>     <http://cmake.org/cmake/help/training.html>
>
>     Visit other Kitware open-source projects at
>     http://www.kitware.com/__opensource/opensource.html
>     <http://www.kitware.com/opensource/opensource.html>
>
>     Follow this link to subscribe/unsubscribe:
>     http://public.kitware.com/__mailman/listinfo/cmake
>     <http://public.kitware.com/mailman/listinfo/cmake>
>
>


More information about the CMake mailing list