I was also getting the same error. I updated my opencv to version 4.5.4 and tried again and it was built successfully.