A general compactness theorem in $G(S)BD$