[cmake-developers] Optionally disabling static lib dependencies with COMPILE_DEPENDS

John Wordsworth john at johnwordsworth.com
Wed Jan 3 16:27:37 EST 2018


I have recently been reviewing ways to improve build times for our project, which is comprised of a number of static libraries. I stumbled across this post on the CMake tracker from 2012/13 (https://cmake.org/Bug/view.php?id=13799 <https://cmake.org/Bug/view.php?id=13799>). It suggests adding a COMPILE_DEPENDS target property to to explicitly set dependencies for STATIC libraries instead of always using all linked libraries as build-order dependencies.

Having done a draft implementation in a local CMake repository it has shaved off  20% of our 120s build time. I expect the savings to be much more dramatic when I test with Incredibuild (approximately 50% based on tests done previously from just deleting dependencies manually in Visual Studio).

I don’t really want to refactor our code to use “OBJECT” libraries as the inability to link with other targets means that propagating compile options / include directories etc down the chain of linked libs becomes painful. This method allows me to switch between static and shared libs using a config option and none of my CMake scripts need to change.

Anyway, I was wondering whether there was any interest in me pushing my solution back to Git / submitting a Pull request so that it might be merged in at some point. If there is - any advice on any gotchas I might watch for instead of just adding some fairly simple code to cmComputeTargetDepends.cxx would be gratefully received - especially as this is my first time poking around in CMake code.

// John Wordsworth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake-developers/attachments/20180103/d9210930/attachment.html>


More information about the cmake-developers mailing list