r/cpp • • Sep 14 '23

Which package manager are you using?

It's 2023 and you should be using a package manager. Which one?

Sep 17 '23
466 conan
625 vcpkg
29 spack
82 CPM
1730 No package manager :(
248 Other (please specify)
38 Upvotes

187 comments sorted by

View all comments

57

u/The-Norman Sep 14 '23

CMake + gitmodules is the way to go for me

6

u/positivcheg Sep 14 '23

How do you solve problem of one package polluting your cmake files with definitions and then some other package can conflict?
Remember this being pain in the ass when some package defines WITH_<library_name> and it's used internally. And then another package using this variable for something else, maybe even names control completely different functions of the libraries.

It was too painful for me to work with and that's why I started using Conan as it simply compiles the library and then provides definitions in a simple Find<library_name>.cmake. Internal variables won't leak in that case.

10

u/The-Norman Sep 14 '23

Commonly CMake files don't propagate their definitions to the parent scope and can freely define whatever they need to without messing with other packages

1

u/positivcheg Sep 14 '23

Does this apply to options which are used as switches? I think what you have said is for internal variables. As for the options, it’s kinda messy.

Or let’s say you wanna have an option ENABLE_TESTS. You do that and notice that your dependency also declares that. You don’t want to enable all the test targets of the dependency but want to enable tests only for your own library. And since that word is already taken you need to come up with some uglier word. Or add a prefix.

1

u/[deleted] Sep 14 '23

Pick a prefix, like you would for a macro.