[CMake] Build only what you need in third party libs

Michael Wild themiwi at gmail.com
Tue Dec 22 08:58:28 EST 2009


On 22. Dec, 2009, at 14:13 , David Cole wrote:

> On Tue, Dec 22, 2009 at 7:58 AM, David Wolfe <dwolfe at fifthsally.com> wrote:
> 
>> On 12/22/2009 7:11 AM, David Wolfe wrote:
>> 
>>>                                           Most of our external
>>> dependencies aren't even built using CMake, so 'CMake-ifying' everything
>>> under one big über-build hardly seems worth it...
>>> 
>> 
>> On 12/22/2009 6:50 AM, David Cole wrote:
>> 
>>> One way to overcome these things, but still build projects from source
>>> code as needed is to use a new feature in CMake 2.8: the ExternalProject
>>> module...
>>> 
>> 
>> Wow. That could be *really* useful---especially the fact that it allows
>> you to download sources from the web, CVS, svn, etc.  It might be enough
>> to change my mind about maintaining a separate externals archive. :-)
> 
> 
> 
> If it's not enough to change your mind...... let me know what you think it's
> missing.
> 
> :-)

From my experience, what is missing are some serious examples, showing how to use this new, excellent feature. And, as I mentioned before, I'm missing MD5 checking and simplified patching (relying on an external patch command just does not work reliably).

I would also like it if external targets could be "pulled" into the caller project (instead of manually writing tedious and error-prone code for IMPORTED targets). Also, these libraries, if STATIC, should not show up in the LINK_INTERFACE_LIBRARIES when dependent SHARED libraries are exported, because a) their path refers to the build tree, b) they cannot be installed using INSTALL(TARGETS ...) and c) they are not required anyways.

Not sure how to do this if the dependent library is STATIC. One could install the external library using INSTALL(FILES ...), but problem a) will need to be managed manually which is again error prone and tedious. I solved a) by writing a custom TARGET_LINK_LIBRARIES wrapper which checks whether a library is IMPORTED and is located in the build tree, adjusts such paths to the install location (possibly using a custom target property) and explicitly setting LINK_INTERFACE_LIBRARIES.

Generally, ExternalProject so far doesn't play very nicely with install(EXPORT ...) and EXPORT(...) for me.

Michael




More information about the CMake mailing list