<div dir="ltr"><div><div><div><div><div><div><div>Hi Saad,<br><br></div>have you read the docs on IMPORTED_LINK_INTERFACE_LIBRARIES? (<a href="https://cmake.org/cmake/help/latest/prop_tgt/IMPORTED_LINK_INTERFACE_LIBRARIES.html">https://cmake.org/cmake/help/latest/prop_tgt/IMPORTED_LINK_INTERFACE_LIBRARIES.html</a>):<br><br>  "This property is deprecated.  Use INTERFACE_LINK_LIBRARIES instead."<br><br></div>Setting INTERFACE_LINK_LIBRARIES to "LibA;LibB" should do exactly what you want.<br><br></div>As a side note, the shorthand funciton set_target_properties() and friends are best suited when multiple properties to one value each. When setting a list, it's usually more convenient to use the general set_property():<br><br></div>set_property(</div><div>  TARGET LibD<br></div>  PROPERTY INTERFACE_LINK_LIBRARIES<br></div>  LibA LibB<br>)<br><br></div>Petr<br><div><div><div><div><div><div><br></div></div></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 14 December 2017 at 03:19, Saad Khattak <span dir="ltr"><<a href="mailto:saadrustam@gmail.com" target="_blank">saadrustam@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 dir="ltr">Thanks Craig for your reply.<div><br></div><div>The issue is that both "LibA" and "LibB" have been set using "add_library(LibA STATIC IMPORTED)" and "add_library(LibB IMPORTED)" and both have some properties that are being set.</div><div><br></div><div>Ultimately, CMake recognizes LibA and LibB as CMake library projects, and they have their own include and link directories and other library dependencies.</div><div><br></div><div>The nice thing about using LibA directly is then LibD inherits all the include and link directories of LibA and LibB which then get inherited by any library or executable that includes LibD (and ultimately, the whole point of modern CMake):</div><div><br></div><div><div class="gmail_extra" style="color:rgb(117,117,117)"><div class="gmail_quote"><div><font face="monospace, monospace">set_target_properties(LibD</font></div></div></div><div class="gmail_extra" style="color:rgb(117,117,117)"><div class="gmail_quote"><div><font face="monospace, monospace">  PROPERTIES</font></div></div></div><div class="gmail_extra" style="color:rgb(117,117,117)"><div class="gmail_quote"><div><font face="monospace, monospace">    IMPORTED_LINK_INTERFACE_<wbr>LIBRARIES LibA #cmake recognizes LibA as IMPORTED CMake libraries</font></div></div></div><div class="gmail_extra" style="color:rgb(117,117,117)"><div class="gmail_quote"><div><font face="monospace, monospace">)</font></div></div></div></div><div><br></div><div>If I use "LibA;LibB" then first, I have to manually extract the library names of the imported CMake libraries LibA and LibB. Then, I have to call "target_include_directories" and "target_link_libraries" for all dependencies of LibA and LibB, even though these dependencies were defined in their own respective CMake files when calling "add_library(LibA STATIC IMPORTED)"</div><div><br></div><div><div class="gmail_extra" style="color:rgb(117,117,117)"><div class="gmail_quote"><div><font face="monospace, monospace">set_target_properties(LibD</font></div></div></div><div class="gmail_extra" style="color:rgb(117,117,117)"><div class="gmail_quote"><div><font face="monospace, monospace">  PROPERTIES</font></div></div></div><div class="gmail_extra" style="color:rgb(117,117,117)"><div class="gmail_quote"><div><font face="monospace, monospace">    IMPORTED_LINK_INTERFACE_<wbr>LIBRARIES "LibA;LibB" #cmake no longer recognizes LibA and LibB as IMPORTED CMake libraries</font></div></div></div><div class="gmail_extra" style="color:rgb(117,117,117)"><div class="gmail_quote"><div><font face="monospace, monospace">)</font></div></div></div></div><div><br></div><div>Regards,</div><div>Saad </div></div><div class="HOEnZb"><div class="h5"><br><div class="gmail_quote"><div dir="ltr">On Wed, Dec 13, 2017 at 4:32 PM Craig Scott <<a href="mailto:craig.scott@crascit.com" target="_blank">craig.scott@crascit.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Dec 14, 2017 at 8:22 AM, Saad Khattak <span dir="ltr"><<a href="mailto:saadrustam@gmail.com" target="_blank">saadrustam@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 dir="ltr">Hi,<div><br></div><div>I have several imported libraries:</div><div><br></div><div>LibA</div><div>LibB</div><div>LibC</div><div><br></div><div>Where each imported library has been populated by (where ${LIB_NAME} is either LibA, LibB or LibC):</div><div><br></div><div>add_library(${LIB_NAME} STATIC IMPORTED)</div><div><br></div><div>And each library has the properties IMPORT_LOCATION_${<wbr>CONFIGURATION} set properly:</div><div><br></div><div><div>set_target_properties(${LIB_<wbr>NAME}</div><div>    PROPERTIES IMPORTED_LOCATION_DEBUG # same for release</div><div>   "location/of/library.lib"</div><div>    )</div></div><div><br></div><div>Now let's say I have another imported library LibD that depends on LibA and LibB such that any executable that uses LibD must also link with LibA and LibB. To do that, I use:</div><div><br></div><div>set_target_properties(LibD</div><div>  PROPERTIES</div><div>    IMPORTED_LINK_INTERFACE_<wbr>LIBRARIES LibA LibB</div><div>  )</div></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>You probably want this instead:</div><div><br></div></div></div></div><div dir="ltr"><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace">set_target_properties(LibD</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace">  PROPERTIES</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace">    IMPORTED_LINK_INTERFACE_<wbr>LIBRARIES "LibA;LibB"</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace">)</font></div></div></div></blockquote></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>Note that if the property value is a list, you have to provide it as a single string (i.e. <font face="monospace, monospace">"LibA;LibB"</font> rather than <font face="monospace, monospace">LibA LibB</font>)</div><div><br></div><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div><br></div>-- <br><div class="m_915601100966052593m_-5059189817599157168gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com" target="_blank">https://crascit.com</a><br></div></div></div></div></div></div></div>
</div></div></blockquote></div>
</div></div><br>--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/<wbr>CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/cmake</a><br></blockquote></div><br></div>