This was added separately in `cmCTestMultiProcessHandler` and `cmQtAutoGenerator`. Factor out the duplicate code into a common header for re-use.