Is it possible to configure a file at build time?

Hi All,

Is it possible to configure a file at build time?

I want the functionality that configure_file provides but I need it to run after another set of files have been generated.

I already have a custom command that generates a set of files. I then need to create another set of files based off a .in file.

is it possible to do something like this?

# run the first add_custom_command
# set some variables based on the content of the generated files
# run add_custom_command again to create another file based of the source controlled

   OUTPUT    wrapper.h
   COMMAND  <cmake configure_file feature>  wrapper.h

This function I wrote years ago can do what you want. You do need to list all variables you want to be able to use as they’re not otherwise available.

You can run cmake scripts at build time with the -P command line argument.

If you need variables from cmake configure time in that cmake script, just make it a file and use configure_file() to prepare it, maybe with @ONLY parameter to not get confused with replaced variables and script-internal variables.