force configure_file() on variable change

Is there a way to force configure_file() to regenerate the output? I have a big config.h file generated from with #cmakedefine that “ccmake” users want to regenerate when they change a relevant variable.

Right now, they have to manually delete the build directory and reuse “ccmake”.

An alternative CMake development solution could be add an option in “ccmake” and/or “cmake-gui” to regenerate the cache akin to cmake --fresh.

Not sure I understand the scenario. If there is a CMake variable being changed, then CMake generation will already be re-occurring. That means configure_file() will be called again, so it should automatically be updating the output during that configure run. Note that if the output doesn’t change, the file will be left untouched (i.e. its time stamp will not be updated).

Okay, I will make a small test case to ensure I’m not just making a mistake or misunderstanding.

I updated configure_file() documentation to make the update criteria clear, thanks