[3.0 backport] Fix building in a worktree or without git
Cherry pick commits from master allowing to build correctly from within a worktree.
Cherry pick commits from master allowing to build correctly from within a worktree.
VideoLAN code repository instance