[CMake] custom_command from cmake macros?

Alexander Neundorf a.neundorf-work at gmx.net
Wed Jul 9 17:46:17 EDT 2008


On Wednesday 09 July 2008, cOre dUmPeR wrote:
> Hello All.
>
> I wrote some cmake macros to generate some header files. The macros read
> text files and generate different headers based on an option the user
> determines.
>
> Now since these are macros, the headers are generated at cmake time. I
> think what I really want, is for these header files to be generated at
> compile time, with a dependency on the text files, so that if I modify the
> text files in between compiles, the build system will know it has to
> regenerate the header files.
>
> So, my question then is, can I somehow make my cmake macro as the COMMAND
> in add_custom_command?

Not directly, but you can write the cmake code into an extra file and have 
that executed by cmake at build time using "cmake -P <filename>"
You can get information into that script by adding 
some -DSOME_VARIABLE=some_value before the -P.

Alex


More information about the CMake mailing list