Automatic reconfiguration when CMakeLists.txt files change

We have a very large project built by gnu make at the top level.
One of the components in the project is a CMake-based application.

The rule to build the app from the top level makefile looks something like:

app: $(APP_MAKEFILE)
    # Build the app
    cmake --build $(APP_BUILD_DIR)

$(APP_MAKEFILE): <some external deps>
    # Generate a makefile
    cmake -S <source dir> -B $(APP_BUILD_DIR) <lots of args>

Now I noticed that sometimes I modify the CMakeLists.txt files in the app, and it fails to compile.
It generally happens when I promote a normal variable to a cache one, or vice versa.

For example we might have

if (NOT WITH_FOO)
    set(WITH_FOO 0)
endif()
target_compile_definitions(target PRIVATE WITH_FOO=${WITH_FOO})

Which I then promote to:

option(WITH_FOO "Use foo module" 0)
target_compile_definitions(target PRIVATE WITH_FOO=$<BOOL:${WITH_FOO}>)

It seems that when making such changes and then invoking make, only the app target will be built by invoking cmake --build <build dir>, but it will not trigger a reconfiguration even though CMakeLists.txt files have changed.

So I guess my question is - how can trigger a reconfiguration only when one is required?

If you modify a CMakeLists.txt file that was used in the previous cmake run, then if you do a build it should automatically re-run cmake first. Are you saying you are not seeing that happen? If you’re instead saying that the build doesn’t rebuild anything, that would be because the final set of commands written to the Makefile aren’t changing, so whatever was built last time is still up-to-date.