[CMake] autoheader

Alexander Neundorf a.neundorf-work at gmx.net
Tue Mar 31 16:05:13 EDT 2009


On Tuesday 31 March 2009, James Bigler wrote:
...
> Why not something similar to what you proposed, but without the
> intermediate configure.h.in step and being able to specify comments and
> perhaps custom strings.  You could also specify things multiple kinds and
> they all just get inserted one after the other.  CMake could generate the
> .in file and use configure_file in the background.  The point is that you
> don't have to maintain two files.
>
> set(VARS HAS_A HAS_B HAS_C)
> set(STRING_VARS STRING_A STRING_B)
> cmake_autoheader(
>   CMAKEDEFINE_VARS ${VARS}
>   STRING_VARS ${STRING_VARS}
>   CUSTOM_VAR "#define \"I like @MY_VAR@\"
>   COMMENT "Here's a comment"
>   CMAKEDEFINE_VARS "SOME_OTHER_VAR;AND_ANOTHER;"
>   HEADER ${CMAKE_BINARY_DIR}/include/config.h
>   )

I like that, it's quite straightforward and easy to understand, no tricks 
involved. And I think this should be doable with a cmake macro or function, 
probably even a C and a C++ specific version.

Alex


More information about the CMake mailing list