[CMake] autoheader

Hendrik Sattler post at hendrik-sattler.de
Mon Mar 30 10:26:45 EDT 2009


Zitat von Bill Hoffman <bill.hoffman at kitware.com>:

> I have seen several requests for an autoheader type function to be
> added to CMake.  I have never used autoheader, but I gather it takes a
> list of variables and generates a config.h.in file automatically.  Does
> anyone on the list have experience with autoheader?   If so, what would
> a nice CMake api for something like this look like?

Well, autoheader just takes the result of certain tests and prepares a  
file that is usable e.g. with configure_file( .... @ONLY ). Usually,  
that contains much more than anyone needs or wants.
It addresses the problem of not having to keep to distinct lists of  
variables to replace (avoiding typos) but limits itself to a strict  
format.

A cmake-equalvalent could be a configure_file()-like function that  
takes a list of variables or mark variables and use all of them. There  
is no point in emulating the actual autoheader behaviour as that has  
the same problem as the configure script itself: an automatically  
created (and thus non-source) file in the source tree.
You can even make it better than autoheader and emit a file with  
#define/#undef for C and something with const variables for C++ (type  
safety) and something else for other supported languages. That would  
make it more complex but definitely better.

HS




More information about the CMake mailing list