<div dir="ltr"><div><div><div><div>Ok, great.<br></div><br></div>Can you tell me a bit more about "implicit compile flags [...] for imported tagets"?<br><br></div>On the library I'm currently working on, with Visual Studio, I have to declare some compile definition in order to get the proper "__declspec(dllimport)" or "__declspec(dllexport)" defined (or not defined when compiling/using a static version of this library).<br>
<br>Does "implicit compile flags" means that those compile definition could be automatically declared by the imported target?<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/10/30 Matthew Woehlke <span dir="ltr"><<a href="mailto:matthew.woehlke@kitware.com" target="_blank">matthew.woehlke@kitware.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 2013-10-30 13:56, Cyrille Faucheux wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'm trying to learn how to properly import/export librairies with CMake.<br>
<br>
I think I've read somewhere that the proper way to export libraries is<br>
through the module mode (as described in [1]), but:<br>
a) I can't find back where I've read that,<br>
b) Lots of libraries are still using the module mode (Find*.cmake).<br>
<br>
Can you confirm me which mode I should choose?<br>
</blockquote>
<br></div>
It's definitely preferred these days to work with exported/imported targets where possible. Unlike find modules, imported targets let you link to target names in consuming projects. Also, now that target usage requirements have arrived, you can have implicit compile flags, include directories, and interface link libraries for imported targets. All of this makes it much easier to use external libraries and lessens the distinction between an imported and local target.<br>
<br>
Additionally, this happens in one place. Find modules tend to end up copied about to different projects until/unless they wind up in CMake proper, and even then can linger on, resulting in multiple versions in varying states of bitrot. They can even be written multiple times by different people in unrelated projects. By providing a package config file (even one that just sets find module style variables) you prevent this proliferation and duplication of work.<br>
<br>
The flip side (and why you have a lot of find modules still) is that the onus to provide a package config file is on the upstream. This means that upstream must either build with CMake in the first place, and have the necessary logic in the CMake build instructions to generate a package config file (ideally with exported targets), or else be friendly enough to CMake to generate 'by hand' such a file despite using some other build system. It should go without saying that, especially in the latter case, politics can become involved here.<br>
<br>
-- <br>
Matthew<br>
<br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" 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" target="_blank">http://www.cmake.org/Wiki/<u></u>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" target="_blank">http://cmake.org/cmake/help/<u></u>support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/<u></u>consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" target="_blank">http://cmake.org/cmake/help/<u></u>training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/<u></u>opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/<u></u>listinfo/cmake</a><br>
</blockquote></div><br></div>