<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">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">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>
<span class="">> Objet: Re: [CMake] CMake: using dlopen<br>
><br>
</span>> Hi,<br>
<span class="">><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>
</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>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><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="HOEnZb"><div class="h5">><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>