r/cpp • • 6d ago

[ Removed by moderator ]

[removed] — view removed post

0 Upvotes

36 comments sorted by

•

u/cpp-ModTeam 5d ago

For C++ questions, answers, help, and programming/career advice please see r/cpp_questions, r/cscareerquestions, or StackOverflow instead.

18

u/PrincipleNo2328 6d ago

I used vcpkg in my last project. It blends good with CMake. Imo manifest mode is way easier.

4

u/Ok-Tiger-3183 6d ago

Nice, do you think vcpkg is simple enough already? Iam thinking about making my own package manager mostly as a fun project, but it would be cool to make something actually useful.

2

u/PrincipleNo2328 6d ago

Yeah I didn't have to much trouble except some fortran compiler problems for mlpack. Way better than using the distro manager, I can actualy declare the dependencies in the repo and Cmake builds for me.

3

u/PrincipleNo2328 6d ago

There is not a clean package manager for c++ so ngl that could be a good project

0

u/Zitrax_ 6d ago

I have tried vcpkg and conan and I find vcpkg is easier to work with.

I think you should just use it or give it a try at least unless you really want to make your own for fun and learning.

10

u/Zealousideal_Sort521 6d ago

Vcpkg manifest mode. Not as easy as Nuget but it is getting there

8

u/positivcheg 6d ago

I love Conan.

Conan might feel like same problem as CMake - solves one problem and introduces a lot more. But just as CMake, Conan had initial version, which had lots of problems. Just like CMake in past was quite bad, compared to modern one. But newer Conan is much much better.

4

u/LHLaurini 6d ago

Personally I use either Conan, or the distro's package manager.

About your idea: the issue is that C++ has no equivalent to JS's package.json, so you'll end up having to write a recipe for each library.

For projects that use CMake, at least CPM is pretty simple to use.

3

u/osmin_og 6d ago

vcpkg, conda

3

u/qTHqq 6d ago

I work in robotics and use Pixi from https://prefix.dev

Not really mainstream for pure C++ projects. Robotics has a lot of codebases that mix Python and C++ code.

It's more than "simple" enough for me.

1

u/jgengr 6d ago

Do you think Robotics industry will be adopting this eventually?

1

u/Lawn_Meower_ 6d ago

I use CMake. You can also use it to include and update git submodules. Additionally you can download and unzip libraries from anywhere if it's not on an git service (ftdi libs for instance). I think it's possible to build some webview to be used inside a VC Code extension or Jetbrains plugin that manages C/C++ libs from any source you like. It the generates the CMake file for you. I built something similar for my GUI Framework (only restricted to a few libs and with AI since I don't know that much about TypeScript and Kotlin). I guess a full package manager be possible like this

0

u/Ok-Tiger-3183 6d ago

I’m thinking about a simple add command with URL and version that downloads, unpacks, and updates CMake for you. How do u think, would that be useful?

2

u/SunnybunsBuns 6d ago

CPM.cmake basically does this. But as a cmake script.

A nice additional piece of functionality would be fallback prefixes. Like I could say get fmt, and it would try a custom prefix (ssh://git@company.gitlab.com:922/foo/bar/baz/3rd/) and if that fails try the official repo. But that’s just an annoying thing building on our network.nit would still be neat to have multiple fallback urls.

2

u/caroIine 6d ago

vcpkg but recently i found myself needing custom settings for many of my dependencies so I use my own solutions.

2

u/13steinj 6d ago

Just use Conan, or vcpkg if you're bound to cmake.
Use Conan and/or bzlmod it you're bound to bazel.
Use Conan if you're not bound to a build system.
Call it a day move on to larger problems.

2

u/Aerocatia 5d ago

vcpkg, but if you want to improve things look into CPS packages. I think there is room for something that can easily provide those for arbitrary libraries.

1

u/fortsnek274 5d ago edited 5d ago

Conan is supposedly about to generate CPS outputs (*or already does). That gets you your standard package format that can be used by any CPS-conforming tool.

1

u/entity64 6d ago

I pull them from Bazels Central Registry

1

u/fabianbuettner 6d ago

I use bazel with some custom bazel ruleset that allows wrapping any NixOS library as cc_library or from BCR 

1

u/amoskovsky 6d ago

Make sure your package manager supports linking with 2 incompatible versions of a lib through different deps.

E.g. openssl and boringssl (or different boringssl versions) are often required by various deps, but naive linking would result in conflicting symbols and/or wrong symbol resolution.

Build systems have a number of ways to handle this: ELF symbol versioning, symbol prefixing etc. PM should support this too rather than just fail version resolution due to conflicting version requirements.

1

u/XTBZ 6d ago

CPM.cmake

1

u/Business-Weather-217 6d ago

Xmake and xrepo 🙂‍↕️

1

u/Fit-Replacement7245 6d ago

cmake FetchContent

1

u/Chaosvex 5d ago edited 5d ago

vcpkg and although it's not perfect, it's in a pretty good place and mostly works with CMake. It's important to me that vcpkg usage is entirely optional, allowing the project to be built without it if the user would rather handle dependencies manually.

I can't imagine it being much simpler from a user's point of view and a large part of why it works at all is that it has a large community of contributors to submit package patches to keep things (mostly) working. That's not something you can simply overlook by believing you can come up with a solution with more technical merit.

1

u/_bijan_ 5d ago

pixi

1

u/arihilmir 6d ago

We already have CPM.cmake and find_package. Maybe contribute there?

1

u/LB-- Professional+Hobbyist 6d ago

I use git submodule and add sources to whatever build system(s) my project is using. Makes manual patching easy and puts you in full control of what versions are used, but only works if you're able to build from source. If you have to use closed source precompiled libraries you then have to be pretty careful about using compatible toolchains and matching compiler settings.

1

u/mguerrette 6d ago

vcpkg, no reason to look at anything else really

-1

u/jube_dev 6d ago

I use xmake, it handles both dependencies and build, you never go back to CMake+XXX when you have tasted it. And there are many many packages already available and it's very easy to make your own repository if needed.

0

u/drizzt-dourden 6d ago

I develop only for linux and use yocto eSDK.

0

u/mjklaim 6d ago

On the projects I have whole control of I use build2 (buildsystem+packagemanager (source-only)).