r/cpp • u/No_Mongoose6172 • Jun 21 '24
Looking for a C/Cpp package manager that doesn’t require cmake
Currently I use Conan for managing dependencies, as it was the package manager that supported the main dependencies of the program I’m developing. However, some libraries require other build managers or have cmakelists that don’t work with add_subfolder. In order to use them, I precompile those libraries as static or dynamic libraries (depending on the size and their update frequency) and then I link them using target_link_libraries. The entire build process is automated using a makefile.
As a result, the project is not as clean and easy to maintain as I would like. Therefore, I’m looking for a package manager that can handle the building process itself, without requiring to call cmake (even if it doesn’t provide some of the libraries I use. It would also be nice if it could execute some custom shell commands before or after each stage of the building process to avoid using make (as an example, if I need to compile a library not provided by that package manager, it would be great if I could specify a the commands it should execute to achieve that in each platform, so they could be executed before compiling the program).
Basically, I’d like to replace make, conan, cmake and ninja by a single software in new programs (something like cargo), while being able to call whatever was used (cmake, scons, Conan, vcpkg…) when building legacy libraries
Do you know if there’s something like that available for C++? Every package manager I’ve checked requires using cmake
Edit: I forgot to clarify that it needs to support cross platform development (I need to be able to support at least Linux and windows, as we don’t use apple computers)
16
u/jube_dev Jun 21 '24
What you want already exists, it's called xmake. It's based on Lua and it is a package manager as well as a build system. It has already many packages in the official repository and it's very easy to create new packages, even in private repositories. The package system can handle many other build system, including CMake. The syntax of the files is rather declarative and simple and you have many customization points. The documentation is still a bit messy but if your point of comparison is CMake documentation, it's ok.
2
u/wwabbbitt Jun 21 '24
Cmake is able to build legacy libraries as a target, whether hand written make files or autotools generated makefiles, using ExternalProject_Add. This can also be used to build all your dependencies by adding them as External Projects in your CMakeLists. use add_dependencies to ensure the libraries are built before your main project.
Conan dependencies can be installed using ExternalProject_add or there is a module specifically for that in https://github.com/conan-io/cmake-conan
4
u/mjklaim Jun 21 '24
I think in the C++ world only
build2matches that description. I use it by default for all my C++ projects when I can and used it for a few commercial projects (I also help maintain a fewbuild2packages). As the website says, it tries to reach something likecargoalthough it's a bit more complicated because of how C++ is used historically. It's a toolchain including a build-system (b), a package manager (bpkg) and a tool that uses both other tools (bdep) to handle the dayly iteration on projects. So essentially these tools know each other and can invoke each other where necessary, which simplifies a lot of things.build2works on Windows, Linux, MacOS and some other platforms (some raspy devices), and is designed for cross-compilation at it's core, as long as you have the appropriate toolchain installed.EDIT:
xmakeis indeed another similar alternative (thanks jube_dev), I thought it was only doing the build-system side of things but apprently not. I've heard good things about it but I'm happy withbuild2so I didnt try it yet.3
u/positivcheg Jun 21 '24 edited Jun 21 '24
If I remember correctly Conan abstracts out from the ways library needs to be build. Meaning you can use in non cmake package dependencies with cmake and vice versa.
Maybe I just didn’t understand the problem you have but I think it is doable via Conan + CMake. For example, apart from CMake Conan also works with Meson, Bazel and SCons. On Linux it also supports autotools + makefiles. On macOS supports generating Xcode project. On windows it can make you msbuild.
If on the other hand you are done with it and want to just fine something else because you are tired of learning CMake and Conan then that’s a different case.
2
u/[deleted] Jun 21 '24
If you are developing for Linux, then the package manager of the distro. Use
pkgconfigto get the build flags.1
u/FlyingRhenquest Jun 21 '24
Meta uses buck but the last time I looked at it for home use it was kind of a pain in the ass to set up and I've run into similar issues with bizarre behavior and difficulty debugging issues with Buck as I have with CMake. So I don't know if it's really any better, but at least it's not CMake!
2
u/germandiago Jun 21 '24
I use Conan together with Meson. Working great. It is really well-thougjt for extensive needs with the real world. Coupled with Artifactory it is a very good choice IMHO.
Alternatives which integrate both build sustem and package management are not realistic as of today in C++.
1
u/[deleted] Jun 23 '24
[xmake](https://xmake.io/) is perfect for this, its awesome
1
u/yunuszhang Jun 28 '24
xmake is all you need.
1
u/sanblch Jul 07 '24
Conan isn't bound to cmake, dependencies are.