<div dir="ltr"><div>Franck,</div><div><br></div>Yes I understand and I mostly do the same.<div><br><div>However, anyone who already faced similar issue should be able to point you to the "right" place in the doc.<div>Since this kind of discussion is popping up again I guess  the doc still miss some bits.<br><div><br><div>I think the right place would be "usage requirements" :</div><div><a href="https://cmake.org/cmake/help/v3.9/manual/cmake-buildsystem.7.html#target-usage-requirements">https://cmake.org/cmake/help/v3.9/manual/cmake-buildsystem.7.html#target-usage-requirements</a></div><div><br></div><div>It could be improved for better understanding the impact of PUBLIC/PRIVATE/INTERFACE</div></div><div>may be with some examples.</div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">2018-01-08 11:07 GMT+01:00 Franck Houssen <span dir="ltr"><<a href="mailto:franck.houssen@inria.fr" target="_blank">franck.houssen@inria.fr</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><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="m_-4489940448166375645zwchr"><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"><b>De: </b>"Eric Noulard" <<a href="mailto:eric.noulard@gmail.com" target="_blank">eric.noulard@gmail.com</a>><br><b>À: </b>"J Decker" <<a href="mailto:d3ck0r@gmail.com" target="_blank">d3ck0r@gmail.com</a>><br><b>Cc: </b>"Franck Houssen" <<a href="mailto:franck.houssen@inria.fr" target="_blank">franck.houssen@inria.fr</a>>, "CMake Mail List" <<a href="mailto:cmake@cmake.org" target="_blank">cmake@cmake.org</a>><br><b>Envoyé: </b>Lundi 8 Janvier 2018 10:53:51<div><div class="h5"><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">https://cmake.org/pipermail/<wbr>cmake/2017-April/065340.html</a><br></div><div><a href="https://cmake.org/pipermail/cmake/2016-May/063400.html" target="_blank">https://cmake.org/pipermail/<wbr>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">d3ck0r@gmail.com</a>></span>:<br><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"><br><div class="gmail_quote"><div><div class="m_-4489940448166375645h5">On Mon, Jan 8, 2018 at 1:41 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: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">rainer.poisel@gmail.com</a>><br> > À: "Franck Houssen" <<a href="mailto:franck.houssen@inria.fr" target="_blank">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">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">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 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="m_-4489940448166375645h5"><div> </div><blockquote class="gmail_quote" 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">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><div class="m_-4489940448166375645m_-2718037682871208763HOEnZb"><div class="m_-4489940448166375645m_-2718037682871208763h5">><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></div></div><br></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="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank">https://cmake.org/mailman/<wbr>listinfo/cmake</a><br> <br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="m_-4489940448166375645gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Eric<br></div></div></div></div></div></div></div></div></div></blockquote><div><br></div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Eric<br></div></div></div></div></div>
</div></div></div></div></div>