--warn-uninitialized and -Werror=dev will do just that: https://cmake.org/cmake/help/latest/manual/cmake.1.html