Build with GCC and flags -fprofile-arcs -ftest-coverage. Then run ctest normally to run all the tests. Then run ctest -T Coverage to collect coverage results. The two ctest calls can be combined as ctest -T Test -T Coverage.
I’ve opened CMake Issue 19942 to propose the addition of a guide to the documentation.