Make dependencies on highgui and ts mandatory only necessary