Hi,<br><br><div class="gmail_quote">On Thu, May 17, 2012 at 10:50 PM, David Doria <span dir="ltr"><<a href="mailto:daviddoria@gmail.com" target="_blank">daviddoria@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><div>On Thu, May 17, 2012 at 2:18 AM, Petr Kmoch <span dir="ltr"><<a href="mailto:petr.kmoch@gmail.com" target="_blank">petr.kmoch@gmail.com</a>></span> wrote:</div></div><div class="gmail_quote"><div class="im">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi David,<br>
<br>
there's a target property LINK_INTERFACE_LIBRARIES (and<br>
per-configuration variants) which can be used for this purpose.<br>
Starting with 2.8.7, target_link_libraries() also accepts<br>
LINK_INTERFACE_LIBRARIES as a new argument mode, setting the property<br>
instead of linking.<br>
<br>
Petr</blockquote><div><br></div></div><div>Petr,</div><div><br></div><div>I tried the following, but in both cases (target_link_libraries and set_target_properties) I still get a linker error that it can't find TestB().</div>
<div><br></div><div>cmake_minimum_required(VERSION 2.6)</div><div>PROJECT(Test)</div><div><br></div><div>add_library(TestB TestB.cpp)</div><div><br></div><div># TestA depends on TestB</div><div>add_library(TestA TestA.cpp)</div>
<div>#target_link_libraries(TestA LINK_INTERFACE_LIBRARIES TestB)</div><div>set_target_properties(TestA PROPERTIES LINK_INTERFACE_LIBRARIES "TestB")</div></div></blockquote><div><br></div><div>You forgot to link TestA to TestB here, I guess your c++ code currently does not actually expose any dependency? Thats why cmake doesn't include TestB when linking the executable.</div>
<div>The LINK_INTERFACES_LIBRARIES only helps cmake to decide when a particular library doesn't need to be added to the linker-command for the executable. By default cmake will link the executable against the libraries specified by you and any libraries these link to - recursively. The property just allows to disable this behaviour by defining which dependent libraries a</div>
<div>given library exposes in its public API and hence which dependent libraries an executable might need to link against in addition to the main library.</div><div><br></div><div>Andreas</div></div>