Generalize test CMake magic and add coverage report generation to it