Best approach for using 3rd party code in my github project

For my github project, I want to use several 3rd party libraries that are also on github (such as: GitHub - lz4/lz4: Extremely Fast Compression algorithm). I want to know the best way to pull 3rd party code into my project. Looking at other projects that use lz4, I see several approaches:

  1. Some people copy the entire contents of lz4 (or other 3rd party code) and commit into a subdirectory of their project.
  2. Others create a fork of lz4.
  3. Stackoverflow answers have suggested using git submodule add.
  4. I assume some people just git clone lz4 when needed, but don’t commit lz4 into their own git repo.
  5. Are there other approaches I’m missing?

What are the pros and cons of those approaches and why do people choose different approaches? In most cases, I do not want to change the 3rd party library at all, but in a few cases, I might want to make minor changes.

The first one is almost always a bad idea. It makes update unnecessarily hard, and loses history.

Other than that there is a lot of “it depends”, in particularly on what you’re using and how. Submodules are good if you need the sources, and a specific version of them.

The fourth option is common for C projects: List the dependencies in your documentation, and leave it up to the user to make sure they’re available. For CI downloading and building the repository (or a release tarball) is an option if you can’t use a packaged version (see below).

Package managers. This one depends on language ecosystem (C doesn’t have a generic one) and platform. If I was using lz4 on Linux, I wouldn’t bother with the source repository at all and install the version packaged by my distribution (including the development headers package), unless I specifically need the latest development version.