rerunning configure_file when the input file changes.

When cmake runs the first time I am able to generate a file using the following:

configure_file( foo.cpp)

That works great. But if changes I would like foo.cpp to be regenerated. If I touch cmake will rerun but foo.cpp is not regenerated.

I was thinking that perhaps a custom command could be used but not sure what the command would be given I want to use configure_file.

Any pointers??? Thanks.

Touching the file is not enough to relaunch configuke_file() as described in the documentation:

The generated file is modified and its timestamp updated on subsequent cmake runs only if its content is changed.

Thanks for that pointer. I did not see that detail. I modified the file and the new files are generated.

In general to handle more advanced cases, like where file1 is read by CMake to configure_file() for file2, you can use directory property CONFIGURE_DEPENDS.