[CMake] automagically generated header hell

William A. Hoffman billlist at nycap.rr.com
Fri Jun 30 11:41:04 EDT 2006


At 05:58 PM 6/29/2006, David Somers wrote:
>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).

Why would make do that?  Are you changing the generated .h files each run?


>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)?

I am not sure I understand why you would want to do this.  If the .h file
has changed, you should rebuild any .c file that includes it.   You might
be able to use INCLUDE_REGULAR_EXPRESSION to make cmake skip some files.

>-- 
>David Somers
>_______________________________________________
>CMake mailing list
>CMake at cmake.org
>http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list