Implement support for unity builds

fixes #7034
fixes #7035