[CMake] automagically generated header hell

David Somers dsomers at omz13.com
Thu Jun 29 17:58:25 EDT 2006


In a project I'm workking on I use makeheaders 
(http://www.cvstrac.org/cvstrac/dir?d=cvstrac) to automagically generate the 
h files for my c files.

I'm using ADD_CUSTOM_TARGET to generate the headers, and some ADD_DEPENDENCIES 
magic to ensure they're generated before the code is compiled.

All works quite well.

However, as the cmake wiki says "Note that generated headers can often cause 
unnecessary rebuilds and should be avoided if possible." And I've run into 
this problem :-(

I have a library that depends on an application being done first (so that the 
library can pull in some of the headers that are generated when the app is 
made). Using ADD_DEPENDENCIES this is working automagically, but the problem 
I've hit is that the library has rebuild problems (i.e. it make will rebuilt 
it even when everything in it is up-to-date).

Is there some way to 'persuade' cmake that in my library when foo.c does 
#include <bar.h> that it shouldn't add <bar.h> into the dependencies (because 
I've manually taken care of that elsewhere)?

-- 
David Somers


More information about the CMake mailing list