<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_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_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><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">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_${CONFIGURATION} set properly:</div><div><br></div><div><div>set_target_properties(${LIB_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_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_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_-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>