Check out CMAKE_CONFIGURE_DEPENDS, I think it should do what you want:
https://cmake.org/cmake/help/latest/prop_dir/CMAKE_CONFIGURE_DEPENDS.html
On Saturday, 20 August 2016, Daniel Levin wrote:
> CMake can automatically invoke configuration at build time when any
>
CMake can automatically invoke configuration at build time when any
dependency has been modified. For instance, after you edited
CMakeLists.txt. Of when you used add_subdirectory() and edited nested
CMakeLists.txt. Or if you have include("myscript.cmake") and modified
myscript.cmake.
I am curious