Modifications proposed for inclusion to upstream: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/10893