Could be a bug in cmake. Needs investigation.
Indeed it's a bug in cmake: https://gitlab.kitware.com/cmake/cmake/issues/15419