How to add a `DEPENDS` onto `execute_process`

I have a build setup that involves doing something like:

    COMMAND python --output moar_build.cmake
    OUTPUT_FILE moar_build.cmake)

Basically, I have this complicated python script that sets up logic that generates a CMake file to then be included into the build.

I can’t make this an add_custom_command because I can’t then add moar_build.cmake into the build itself, since that doesn’t get run until the build stage, so this is too late.

But it appears that execute_process doesn’t have a DEPENDS like add_custom_command does, so if changes, then it doesn’t get rerun (I would have to manually reconfigure).

Is there any other way to get something like this to work? That is, I need to run a program during the configuration phase of cmake in order to then include the generated cmake file as part of the build, but actually have changes to that program cause reconfiguration?

Have a look at the CMAKE_CONFIGURE_DEPENDS directory property.

Yeah that works. It’d be great if that link actually explained how to use the property, but ideally it’d be even better if execute_process just had this as a parameter (since I don’t want to rerun the whole configuration, I know I just need to rerun this one execute_process, so it’s a bit wasteful to do more work).

CMake is not able to build up the state pre-include, do the include, then continue from there other than by executing from the top.