[CMake] Why does dependency scanning in version 2.6 seem so slow?

Daniel Nelson torham at connect2.com
Sat Dec 6 17:47:40 EST 2008


Senanu Pearson wrote:
> Is there a way to speed up the dependency scan in version 2.6?

As my cmake projects became larger I noticed that dependency scanning 
became a much larger percentage of my build time.  My project used a 
pre-compiled header, which included parts of boost, Qt, and stl.  This 
caused cmake's dependency scanning to consider every object file to 
include everything in the PCH.  My depends.make grew to be about 10 MB 
each for all ten or so sub-projects in my greater project.

The fix was to use INCLUDE_REGULAR_EXPRESSION to block headers that are 
not going to change from dependency scanning.  Unfortunately you need to 
come up with a regex that matches only files you want to do dependency 
scanning on.  I could never think of one that would work, so instead I 
made some changes to my copy of cmake.  I decided that what I really 
wanted to do is exclude everything from dependency scanning that is 
included using angle brackets, and I added an additional argument to 
INCLUDE_REGULAR_EXPRESSION that would do this.

Once I stopped following <> includes, my build times on a full rebuild 
decreased from about 10 minutes to 8 and the build time of building on 
an unmodified source tree dropped from 1m20s to about 20s.  This is 
something I have meaning to put in as a feature request for along time, 
but just haven't had time.

I should mention that I did this all when using 2.4 and I haven't 
noticed any speed difference with 2.6




More information about the CMake mailing list