[CMake] Building a DLL and test driver EXE using CMake -- error by design?

Michael Hertling mhertling at online.de
Wed Mar 23 12:52:17 EDT 2011


On 03/23/2011 03:21 PM, Chris Volpe ARA/SED wrote:
>> You might break this transitivity by explicitly setting
>> the LINK_INTERFACE_LIBRARIES target properties of FeatureViewer to ""
> 
> That did it!!!! Thanks, Michael. That's exactly what I needed. 
> 
> It's somewhat moot now, but your second suggestion confused me, and I'd like to understand better:
> 
>> As an alternative, you might use a second invocation
>>
>> TARGET_LINK_LIBRARIES(FeatureViewer TARGET_LINK_LIBRARIES ...)

Oops: TARGET_LINK_LIBRARIES(FeatureViewer LINK_INTERFACE_LIBRARIES ...)
                                          ^^^^^^^^^^^^^^^^^^^^^^^^
> Two questions:
> 1. Does a second invocation override the first invocation?
> 2. If I remove the VTK libs from this command, wouldn't that leave FeatureViewer with unresolved symbols?

No, for both questions. Each shared library target has a set of
transitive libraries, i.e. libraries other targets are additionally
linked against if they are linked against the shared library target.
As a default, this set consists of those libraries mentioned in the
shared library target's TARGET_LINK_LIBRARIES() command invocation.
Nevertheless, if the LINK_INTERFACE_LIBRARIES target property has a
defined value, this is used for the set of transitive libraries. Now,
TARGET_LINK_LIBRARIES() with the LINK_INTERFACE_LIBRARIES clause just
adds the specified libraries to the aforementioned property without an
impact on the libraries the target is actually linked against. Hence, a
second invocation with LINK_INTERFACE_LIBRARIES clause would affect the
TestDriver and further depending targets, but not the FeatureViewer one.

Regards,

Michael

> Thanks again for your help!!
> 
> -Chris
> 
> 
>> -----Original Message-----
>> From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On
>> Behalf Of Michael Hertling
>> Sent: Tuesday, March 22, 2011 7:30 PM
>> To: cmake at cmake.org
>> Subject: Re: [CMake] Building a DLL and test driver EXE using CMake --
>> error by design?
>>
>> [my original elided for brevity --CRV]
>>
>> The TARGET_LINK_LIBRARIES() command works transitively, i.e. TestDriver
>> will be linked against each shared library that FeatureViewer is linked
>> against, too. You might break this transitivity by explicitly setting
>> the LINK_INTERFACE_LIBRARIES target properties of FeatureViewer to ""
>> or, in general, to the set of libraries which are still to be linked
>> transitively. As an alternative, you might use a second invocation
>>
>> TARGET_LINK_LIBRARIES(FeatureViewer TARGET_LINK_LIBRARIES ...)
>>
>> in FeatureViewer/CMakeLists.txt to explicitly specify the transitive
>> libraries. Of course, the VTK ones should not appear in these lists.
>>
>> 'hope that helps.
>>
>> Regards,
>>
>> Michael


More information about the CMake mailing list