Search code examples
gitopenglcmakerepo

Is it good to attach graphic library to git repository or maybe download via cmake?


As in title, I am wondering about what is better, attach graphic libraries(e.g glew, glm, glfw, etc.) in my git repository, or make a special cmake modules that download it while building?

I heard that it is not proper to add libraries to repo explicitly, especially if they are large, but making cmake modules for each library can be very infernal...

What in your opinion is better way? Maybe you have some other idea? What is your experience with it?

P.S. I use in my project cmake.

Edit: You can assume that libraries has around 10-20MB, and another project files < 5MB.


Solution

  • We're talking two distinct problems here: Build configuration and distribution configuration.

    In general your project and build configuration should be as minimal as possible and rely on system wide installation of libraries where applicable. This is important to prepare – for example – for Linux distributions where a package manager keeps track of dependencies and builds should happen against the libraries installed through the package manager.

    Distribution configuration OTOH is concerned with the various ways in which your project gets distributed to end users. Such a distribution configuration should allow for the configuration of builds with system wide installed libraries (like you want it for Linux packaging), but as well as producing self-contained builds that also covers importing and building exact versions of required libraries (you don't want to automatically use the most recent version, because that might break your build).

    In that sense distribution configuration is responsible for specializing build configurations. A good approach for self contained builds (which is those which include 3rd party libraries) is to fetch and build the dependencies into the build tree (you're doing out of source tree builds, are you?).