Search code examples
c++gitdependenciescmakecross-platform

How to handle dependencies in cross platform C++ projects?


This are the ways I see for dealing with external libraries in a cross-platform project in an automated way. (Why are there no cross platform package managers?)

  • Add compiled binaries to the repository. (This doesn't work, since platform and build configuration vary and new environments may come up.)
  • Write download scripts to fetch source code from the internet. I could think of cloning the libraries from Github or from the projects' websites via HTTP. (This breaks when download links change. Moreover, I don't know a way to automate the build of all libraries.)
  • Include source code of all dependencies into the repository, alternatively as sub repositories. (The problem still is to find an automated way of compiling them. Also it requires a lot of space.)

What is the workflow for handling external libraries in cross-platform C++ projects? With many big projects out there, I guess there must have emerged one. If not, based on which criteria can I decide between reasonable ways?


Solution

  • Try CMAKE

    CMake, is a cross-platform, open-source build system. CMake is a family of tools designed to build, test and package software. CMake is used to control the software compilation process using simple platform and compiler independent configuration files. CMake generates native makefiles and workspaces that can be used in the compiler environment of your choice.