<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">https://cmake.org/pipermail/cmake/2017-April/065340.html</a><br></div><div><a 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">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="h5">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-requir<wbr>ements</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(oth<wbr>erlib PRIVATE<br>
> dirPrivate<br>
> )<br>
><br>
> target_include_directories(oth<wbr>erlib 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">
<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/que<wbr>stions/26037954/cmake-target-<wbr>link-libraries-interface-<wbr>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_-2718037682871208763HOEnZb"><div class="m_-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/CMak<wbr>e_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/su<wbr>pport.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/co<wbr>nsulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/tr<wbr>aining.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/opensou<wbr>rce/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/list<wbr>info/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="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Eric<br></div></div></div></div></div>
</div></div>