Marco Zimmerman
Marco Zimmerman

Reputation: 251

Package Management for C++

I am working in a company that they build a project separated in components that are developed separately by different developer teams. Everything in C++.

They use a lot of libraries in common and to manage all of them, they created a tool to somehow relates the version of the project and versions of libraries.

The question is about the existence of some tool in the market that already does this:

I mean, If I go to this tool, I can download for example the version 4.0 of our project that has exactly the version 4.5 of the library 1 and 3.4 of library 2. If I click "Download", I will Download the source code (or binary) of this entire (project + libraries) project and the concrete version of each library.

For example if I want to Download another project of another developers in the company, using same libraries in different version or platforms, I only have to choose that and is gonna download the project 2 with library 1 version 5.0 and library 2 2.5, and so on.

Is there in the market any tool that aloud me to create some relations like that, and btw, connects with code repo (gitlab in our case)?

I checked Gradle, Conan, ... but they build, not manage "relations" between components.

Something like that:

enter image description here

Upvotes: 14

Views: 7382

Answers (3)

Paul Fultz II
Paul Fultz II

Reputation: 18200

I wrote cget that provides a way to install a dependency just by pointing to the source tarball, which hosting services like github and gitlab provide. You can also provide a requirements.txt to install all the dependencies transitively as well.

It is cmake-based, which it will install with very little changes, but it also supports other non-cmake packages. You can also create a distro of recipes for handling packages that don't follow the standard configure, build and install workflow. There is also a lot recipes already available for many C++ projects already here.

Upvotes: 2

v1bri
v1bri

Reputation: 1428

To follow up @norman-b-lancaster's answer, consider looking into the Hunter package manager. It is based on CMake's ExternalProject feature and heavily focused on reproducible builds. Each Hunter release provides the CMake script required to lock down the package versions of all dependencies.

Your question suggests that you're concerned with package management within your company (as opposed to publicly available packages from ex: GitHub). Hunter's maintainers are aware of this issue and seem open to supporting it if the demand is present.

Upvotes: 2

Norman B. Lancaster
Norman B. Lancaster

Reputation: 583

CMake provides enough functionality to create these kinds of relationships within your build system. Unfortunately you have to use CMake to manage the builds for all of your projects for this to work well. CMake does target Visual Studio as well as GCC, Clang, and ICC. If this interests you keep reading.

  1. Use CMake to construct build configurations for your dependent projects.
  2. Use ExternalProject commands to express the dependencies of the parent projects.
    • ExternalProject supports Git as well as Mecurial, CSV, SVN, and direct tarball downloads.
    • You can specify the exact commit, tag, or branch in Git.
    • Supports Git authentication via SSL or Basic HTTP.
  3. Run CMake against the parent project. All dependencies are downloaded and compiled automatically.

Example Dependency

ExternalProject_Add(
    Library1
    GIT_REPOSITORY https://[email protected]/repo/library_1.git
    GIT_TAG tag_S.33.91
    HTTP_USERNAME ciserv
    HTTP_PASSWORD Obfusc@t3M3
    CMAKE_ARGS
        -DBUILD_EXAMPLES:BOOL=OFF
        -DBUILD_TESTS:BOOL=OFF
        -DBUILD_DOCS:BOOL=OFF
)
target_link_libraries(MyTarget PRIVATE Library1)

There are several other commands within the ExternalProject module that can be used to further customize the dependency if required.

Upvotes: 7

Related Questions