CMakePresets.json and ZERO_CHECK

I am using CMake presets defined in CMakePresets.json to build my application. I have noticed, however, that changing a value in CMakePresets.json does not cause cmake to automatically re-run the way any modification to, e.g., a CMakeLists.txt that is part of my project does.

Even after I added CMakePresets.json as a source to my application’s CMake target, the ZERO_CHECK target does not consider changes to CMakePresets.json important enough to re-run cmake.

Is there a way to make ZERO_CHECK take into account changes to CMakePresets.json?

Adding the file to the directory property CMAKE_CONFIGURE_DEPENDS should help.

1 Like

The ZERO_CHECK target is for automatically rerunning cmake when the build command is invoked. When CMake is rerun in this manner, it’s rerun as if by cmake -S <src> -B <build>, and not via cmake --preset <foo>, even if that’s how the build tree was originally created. In order to re-run CMake with the options from a configure preset, you always must manually run cmake --preset foo, even if you add the CMakePresets.json to the CONFIGURE_DEPENDS.

1 Like