<html><body><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"><div>I usually read the doc in a step-by-step mode (going from "small things" to "the next") when a (new) need/question shows up. When I can I try to "push" some notions (this is an example of it !).<br></div><div>The doc is "vast" which is a good thing but not so easy when trying to read/understand all of it (personal opinion). To me, the doc misses simple illustrative examples like Rainer's one (here again, personal opinion).<br></div><div><br></div><div><br></div><hr id="zwchr"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;" data-mce-style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><b>De: </b>"Eric Noulard" <eric.noulard@gmail.com><br><b>À: </b>"J Decker" <d3ck0r@gmail.com><br><b>Cc: </b>"Franck Houssen" <franck.houssen@inria.fr>, "CMake Mail List" <cmake@cmake.org><br><b>Envoyé: </b>Lundi 8 Janvier 2018 10:53:51<br><b>Objet: </b>Re: [CMake] CMake: using dlopen<br><div><br></div><div dir="ltr">Explanations on PRIVATE, PUBLIC, INTERFACE has already been discussed in those ML threads:<div><a href="https://cmake.org/pipermail/cmake/2017-April/065340.html" target="_blank" data-mce-href="https://cmake.org/pipermail/cmake/2017-April/065340.html">https://cmake.org/pipermail/cmake/2017-April/065340.html</a><br></div><div><a href="https://cmake.org/pipermail/cmake/2016-May/063400.html" target="_blank" data-mce-href="https://cmake.org/pipermail/cmake/2016-May/063400.html">https://cmake.org/pipermail/cmake/2016-May/063400.html</a><br></div><div><br></div><div>I guess we need some doc update.</div><div>I did promess contribution and I didn't do it.</div><div>I'll try again.</div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">2018-01-08 10:45 GMT+01:00 J Decker <span dir="ltr"><<a href="mailto:d3ck0r@gmail.com" target="_blank" data-mce-href="mailto:d3ck0r@gmail.com">d3ck0r@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex" data-mce-style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Mon, Jan 8, 2018 at 1:41 AM, Franck Houssen <span dir="ltr"><<a href="mailto:franck.houssen@inria.fr" target="_blank" data-mce-href="mailto:franck.houssen@inria.fr">franck.houssen@inria.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex" data-mce-style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;"><br> <br> ----- Mail original -----<br> > De: "Rainer Poisel" <<a href="mailto:rainer.poisel@gmail.com" target="_blank" data-mce-href="mailto:rainer.poisel@gmail.com">rainer.poisel@gmail.com</a>><br> > À: "Franck Houssen" <<a href="mailto:franck.houssen@inria.fr" target="_blank" data-mce-href="mailto:franck.houssen@inria.fr">franck.houssen@inria.fr</a>><br> > Envoyé: Dimanche 7 Janvier 2018 19:34:21<br> <span>> Objet: Re: [CMake] CMake: using dlopen<br> ><br> </span>> Hi,<br> <span>><br> > On Sun, Jan 7, 2018 at 7:13 PM, Franck Houssen <<a href="mailto:franck.houssen@inria.fr" target="_blank" data-mce-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> </span>> 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" data-mce-href="https://cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html#transitive-usage-requirements">https://cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html#transitive-usage-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(otherlib PRIVATE<br> >   dirPrivate<br> > )<br> ><br> > target_include_directories(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 otherLib), no ? (mylib needs only PUBLIC stuff's from otherLib but not PRIVATE one's). Correct ?<br> <br></blockquote><div><br></div></div></div><div>Public is whether it propagates outside of the current target to things that then require 'mylib' </div><div>private keeps it within that target, has nothing to do with what it's pulling from any linked library.</div><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex" data-mce-style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;"><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" data-mce-href="https://stackoverflow.com/questions/26037954/cmake-target-link-libraries-interface-dependencies">https://stackoverflow.com/questions/26037954/cmake-target-link-libraries-interface-dependencies</a><br> >   * <a href="https://rix0r.nl/blog/2015/08/13/cmake-guide/" rel="noreferrer" target="_blank" data-mce-href="https://rix0r.nl/blog/2015/08/13/cmake-guide/">https://rix0r.nl/blog/2015/08/13/cmake-guide/</a><br> ><br> > Regards,<br> >   Rainer<br><div class="m_-2718037682871208763HOEnZb"><div class="m_-2718037682871208763h5">><br> --<br> <br> Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank" data-mce-href="http://www.kitware.com">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" data-mce-href="http://www.cmake.org/Wiki/CMake_FAQ">http://www.cmake.org/Wiki/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" data-mce-href="http://cmake.org/cmake/help/support.html">http://cmake.org/cmake/help/support.html</a><br> CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank" data-mce-href="http://cmake.org/cmake/help/consulting.html">http://cmake.org/cmake/help/consulting.html</a><br> CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank" data-mce-href="http://cmake.org/cmake/help/training.html">http://cmake.org/cmake/help/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" data-mce-href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/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" data-mce-href="https://cmake.org/mailman/listinfo/cmake">https://cmake.org/mailman/listinfo/cmake</a><br></div></div></blockquote></div></div></div><br></div></div><br>--<br> <br> Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank" data-mce-href="http://www.kitware.com">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" data-mce-href="http://www.cmake.org/Wiki/CMake_FAQ">http://www.cmake.org/Wiki/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" data-mce-href="http://cmake.org/cmake/help/support.html">http://cmake.org/cmake/help/support.html</a><br> CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank" data-mce-href="http://cmake.org/cmake/help/consulting.html">http://cmake.org/cmake/help/consulting.html</a><br> CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank" data-mce-href="http://cmake.org/cmake/help/training.html">http://cmake.org/cmake/help/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" data-mce-href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/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" data-mce-href="https://cmake.org/mailman/listinfo/cmake">https://cmake.org/mailman/listinfo/cmake</a><br> <br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Eric<br></div></div></div></div></div></div></div></blockquote><div><br></div></div></body></html>