<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 8, 2018 at 1:50 AM, Franck Houssen <span dir="ltr"><<a href="mailto:franck.houssen@inria.fr" target="_blank">franck.houssen@inria.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">And so, if I have an executable (add_executable), the default thing to do is to use target_link_libraries(mylib PRIVATE ...). Not PUBLIC (as I do). Correct ?<br></blockquote><div> </div><div>Yes, unless you have plugins that then back-ljnk against that executable. (and that also use the libraries that executable uses... if it just uses things from that library/executable then private should always be used)  </div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
----- Mail original -----<br>
> De: "Franck Houssen" <<a href="mailto:franck.houssen@inria.fr">franck.houssen@inria.fr</a>><br>
> À: "Rainer Poisel" <<a href="mailto:rainer.poisel@gmail.com">rainer.poisel@gmail.com</a>><br>
<span class="gmail-">> Cc: "CMake Mail List" <<a href="mailto:cmake@cmake.org">cmake@cmake.org</a>><br>
</span>> Envoyé: Lundi 8 Janvier 2018 10:41:25<br>
<div class="gmail-HOEnZb"><div class="gmail-h5">> Objet: Re: [CMake] CMake: using dlopen<br>
><br>
><br>
><br>
> ----- Mail original -----<br>
> > De: "Rainer Poisel" <<a href="mailto:rainer.poisel@gmail.com">rainer.poisel@gmail.com</a>><br>
> > À: "Franck Houssen" <<a href="mailto:franck.houssen@inria.fr">franck.houssen@inria.fr</a>><br>
> > Envoyé: Dimanche 7 Janvier 2018 19:34:21<br>
> > Objet: Re: [CMake] CMake: using dlopen<br>
> ><br>
> > Hi,<br>
> ><br>
> > On Sun, Jan 7, 2018 at 7:13 PM, Franck Houssen <<a href="mailto:franck.houssen@inria.fr">franck.houssen@inria.fr</a>><br>
> > wrote:<br>
> > > Difference between PUBLIC/PRIVATE has never been clear to me (usually I<br>
> > > always use PUBLIC).<br>
> > > main.cpp includes dlfcn.h and uses it: not sure to get what you meant<br>
> > > (PRIVATE is for templates ? when a header include headers ?)<br>
> ><br>
> > you are looking for the "Transitive Dependencies" feature of CMake:<br>
><br>
> OK, I didn't get that. It's more clear to me now. Thanks !<br>
><br>
> >   *<br>
> >   <a href="https://cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html#transitive-usage-requirements" rel="noreferrer" target="_blank">https://cmake.org/cmake/help/<wbr>v3.0/manual/cmake-buildsystem.<wbr>7.html#transitive-usage-<wbr>requirements</a><br>
> ><br>
> > Generally speaking and from my personal experience, use the<br>
> > target_-commands as much as possible because properties are bound to<br>
> > targets and their dependencies rather than a file/directory structure.<br>
> ><br>
> > So, that means, use target_include_directories(),<br>
> > target_compile_options(), target_compile_definitions(),<br>
> > target_sources(), ... for your targets. The magic keyword to propagate<br>
> > the properties of your targets is target_link_libraries(). Depending<br>
> > on what scope (PRIVATE, PUBLIC, INTERFACE) the properties have been<br>
> > defined using the other target_-commands, the target_link_libraries()<br>
> > command propagates these properties to other targets. E. g.<br>
> ><br>
> > add_library(otherlib SHARED<br>
> >   foo.c<br>
> > )<br>
> ><br>
> > target_include_directories(<wbr>otherlib PRIVATE<br>
> >   dirPrivate<br>
> > )<br>
> ><br>
> > target_include_directories(<wbr>otherlib PUBLIC<br>
> >   dirPublic<br>
> > )<br>
> ><br>
> > add_library(mylib SHARED<br>
> >   bar.c<br>
> > )<br>
> ><br>
> > target_link_libraries(mylib PRIVATE<br>
><br>
> Is this a typo ?<br>
> For the example to work I would have done: target_link_libraries(mylib PUBLIC<br>
> otherLib), no ? (mylib needs only PUBLIC stuff's from otherLib but not<br>
> PRIVATE one's). Correct ?<br>
><br>
><br>
> >   otherlib<br>
> > )<br>
> ><br>
> > In this case, mylib will use all PUBLIC or INTERFACE properties of<br>
> > otherlib for its build. Thus, dirPublic will be added to the include<br>
> > directory search path for the compilation of bar.c of mylib. PRIVATE<br>
> > properties will not be propagated. In the above mentioned example,<br>
> > dirPrivate will NOT be added to the include directory search path for<br>
> > the compilation of bar.c of mylib.<br>
> ><br>
><br>
> The example is illustrative (transitivity - PRIVATE is not propagated)<br>
><br>
> > This is a very short summary, but I hope it is of help to you. There<br>
> > are other ressources on the Internet. E. g.<br>
> >   *<br>
> >   <a href="https://stackoverflow.com/questions/26037954/cmake-target-link-libraries-interface-dependencies" rel="noreferrer" target="_blank">https://stackoverflow.com/<wbr>questions/26037954/cmake-<wbr>target-link-libraries-<wbr>interface-dependencies</a><br>
> >   * <a href="https://rix0r.nl/blog/2015/08/13/cmake-guide/" rel="noreferrer" target="_blank">https://rix0r.nl/blog/2015/08/<wbr>13/cmake-guide/</a><br>
> ><br>
> > Regards,<br>
> >   Rainer<br>
> ><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:<br>
> <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<br>
> 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<br>
> <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="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank">https://cmake.org/mailman/<wbr>listinfo/cmake</a><br>
><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="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank">https://cmake.org/mailman/<wbr>listinfo/cmake</a><br>
</div></div></blockquote></div><br></div></div>