<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Mar 24, 2019 at 1:43 PM Jason Beach <<a href="mailto:jason.m.beach@gmail.com">jason.m.beach@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<div>  As I've been learning CMake, it seems the best practice for a library is for it to export the targets it creates. There is also the relatively new command FetchContent. It seems that at least in part the FetchContent command obviates the need for exporting targets. </div><div><br></div><div>I can see that for larger more permanent libraries exporting targets is still preferred so the library can be installed once and used by multiple projects on a developers workstation without having to install it on each project. </div><div><br></div><div>At work we're a bunch of research engineers that happen to write a lot of software-- exporting targets still seems cumbersome and it seems not exporting targets and then just have users use FetchContent to pull in a library is not a bad idea. </div><div><br></div><div>Are there other reasons /advantages of exporting targets?</div></div></blockquote><div><br></div><div>Exporting targets is a way to allow other projects to easily consume yours via find_package(). If you are 100% confident that no-one is ever going to use your project that way and will only ever build it from source directly (whether that be through FetchContent or some other method), then there's no benefit to exporting targets. As soon as there's a possibility that someone might want to build against an installed version of your project though, having the exported targets available makes for a significantly more convenient and more robust experience. It really comes down to whether in your case you can truly say no-one will ever want to use find_package() to bring your projects into theirs.</div><div><br></div><div> </div></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com" target="_blank">https://crascit.com</a><br></div><div><br></div><div>Get the hand-book for every CMake user: <a href="https://crascit.com/professional-cmake/" target="_blank">Professional CMake: A Practical Guide</a><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div>