Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven-like dependency management for C++? [closed]

Say I have a C++ project that is split in several subprojects. The subproject all produce a DLL and different teams of developers work on each of the subproject. Now if I want to build the main project, is there a way to avoid having to build all the subprojects by myself?

In short, I'm looking for something that does the dependency management (i.e. for binary files and headers) in a similar way as Maven does for Java.

In fact, I tried to use Maven for this but this is rather cumbersome because I have to create the packages manually and quite frequently, Maven misses to pick up the most recent changes. Also, running the compilation is a bit of a hack as I have to call NAnt from within Maven (I use NAnt's feature to build Visual Studio solutions directly).

Any hints and ideas of how to do this?

like image 597
weberste Avatar asked Jul 16 '09 07:07

weberste


People also ask

What is alternative to Maven?

The best alternative is GNU Make, which is both free and Open Source. Other great apps like Maven are CMake, Gradle, SCons and Meson. Apache Maven is a Java-based tool for build automation and project management (in software development).

Can Maven be used for C++?

I'm quite happy with the result, the usual maven commands can be used to grab dependencies, compile, clean, and deploy. I would definitely use Maven for dependency management for C and C++ projects, or really any other situation where you need it, and it isn't already provided for whatever reason.

What is Dependencymanagement?

The dependency management section is a mechanism for centralizing dependency information. When you have a set of projects that inherit from a common parent, it's possible to put all information about the dependency in the common POM and have simpler references to the artifacts in the child POMs.

How do you exclude a dependency from POM?

Open the dependency POM and find the transitive dependency you want to exclude. Copy groupId and artifactId . In your project POM, underneath your active dependency, enter exclusions and using code completion paste the copied info of the dependency you want to exclude.


3 Answers

Initial Answer: I would suggest using CMake. It is a multi-platform make file generator (generates Visual Studio or Eclipse CDT projects as well).

http://www.cmake.org/

I did really good experience with it. The best thing I like about it was the ability to produce generic project structure. So you can generically include sub-projects look-up for unit tests etc. without changing the script every time.

They have also lots of modules on how to find pre-installed build libraries, required for the project (like Boost, QT etc.)


Update: In the mean time there was some effort to introduce package management for C++. Some projects worth looking at:

  • conan.io integrates with major build tools:
    • CMake
    • Visual Studio
    • Makefile
    • XCode
    • ...
  • cpm based on CMake (Note CPM is not being actively maintained.)
  • Buckaroo

Note as pointed out by @RAM in the comments cpm is no longer actively maintained.

like image 120
ovanes Avatar answered Oct 20 '22 02:10

ovanes


For the dependency management, it exists a new project (it is a startup company) which is implementing this type of tool: https://github.com/biicode (a C++ dependency manager). You could add your dependencies and it should work.

Currently, the project's name is conan.io, they were acquired by JFrog.

UPDATE: The project is dead... Unfortunately, it seems the startup couldn't get enough premium paying customers, but the server seems is working fine...

UPDATE2: It seems there is a substitute project: conan.io (thanks @mucaho)

like image 39
carlos.baez Avatar answered Oct 20 '22 03:10

carlos.baez


I recommend the following high-level build systems:

  • Maven Nar Plugin: Using Maven for C/C++ projects
  • Gradle cpp plugin: It is an easier way, but it is currently incubating, here the main features and a roadmap.
  • Conan is more C++ approach, it is multi-platform and it supports most common C++ build systems.
like image 26
carlosvin Avatar answered Oct 20 '22 02:10

carlosvin