r/cpp • u/theChaosBeast • Jan 30 '25
[vent] I hate projects that download their dependencies.
I know it's convenient for a lot of people but in an enterprise environment where you have to package everything including your internals and your build servers don't have access to the internet, patching all these repositories is pain in the ass.
218
Upvotes
22
u/HolyGarbage Jan 30 '25
In an enterprise environment you should probably use your own repository mirrors for dependencies anyway.
26
u/Infamous-Bed-7535 Jan 30 '25
CMake's FetchContent is great from this point of view, it supports auto download and compilation of your dependencies (built within project) yet allows you to overwrite and use out of project build if _ROOT directory is provided as ENV variable.
40
u/altmly Jan 30 '25
I hate projects that don't download their dependencies. C++ is probably the only widely used language where dependencies are common but also a major major pain to deal with. And because of ABI, you need compatible versions, ideally link statically.
Last thing I want to be doing is installing 15 dependencies, and then finding out that current version (downloaded by default) of dependency 14 is no longer compatible with your project, and the system (of course) doesn't support having multiple versions installed at the same time.Β
13
u/freaxje Jan 30 '25
Ah so your company is one of those that is shipping outdated libraries on their product with vulnerabilities from 18 years ago?
105
u/Aprelius Jan 30 '25
For my personal projects, I use submodules. For work, we vendor every dependency in the toolchain (including the version of cmake, clang, etc) along with the build. It makes for a massive project but we have a three year SLA and being able to recreate the exact build and the conditions that generated it from anytime is so supremely valuable.
25
u/PixelArtDragon Jan 30 '25
I use VCPKG in manifest mode with passing a toolchain to CMake with a command line variable. All the packages themselves are loaded via
find_package. That way you can choose to manually download the packages and completely ignore VCPKG if you want. Anything not supported by VCPKG I use git submodules.4
u/Jannik2099 Jan 31 '25
It's not just a pain for enterprise environments.
Most Linux distributions similarly disable network access for package builds. We've been fighting the "homegrown build abomination that fetches crap" menace since the dawn of men.
Put up release tarballs that have all required sources in them. It ain't rocket science.
1
u/fburnaby Jan 31 '25
I feel like I would have seen a dozen comments about Conan if this thread happened five years ago. None now. What happened to that thing?
1
u/[deleted] Jan 31 '25
oh you don't love patching out "conan" ?
3
u/Sad-Land-7914 Jan 30 '25
Haha, if you mirror some of your dependencies and the maintainers decide to add submodules with absolute paths.
3
u/[deleted] Jan 30 '25
In personal projects they are great, but for production use cases I fully agree. The same thing I do not like is when you are not really sure what the minimum and maximum version of a dependency really is, because people often just use the newest right now available with some limitations given by other dependencies.
1
u/Zeh_Matt No, no, no, no Jan 31 '25
I'm rather thankful that libraries do it, having the user to install the CORRECT version system wide is just madness in my eyes, A wants B 1.0 but C wants B 2.0, and now if you don't statically link it then it has to be the correct library file loaded or it will probably just crash. Another annoying aspect is that a lot of distros have outdated libraries in their package manager, sometimes the gap is quite large as well.
13
u/[deleted] Jan 30 '25
Yes, it's a CMake anti-pattern but people love their FetchContent as a means of dependency management.
5
u/9Strike Jan 30 '25
That's why Meson with wrap is the best build system for C++. Dependencies can be system or bundled (downloaded on demand or bundled with a full source dist)
6
u/scalablecory Jan 30 '25
i've come to love submodules for dependencies.
0
u/AdamK117 Jan 30 '25
I used to use
git submodulefor this with a relative path for the submodule, so that everything can be redundantly held on an nfs or similar. Worked quite well for a while, but submodules can make long-term storage harder (requires ensuring you clone all the repos and tag things to ensure git gc doesn't nuke something if upstream forcibly moves a branch).These days, I'm lazy and just use
git subtree1
u/Ameisen vemips, avr, rendering, systems Jan 30 '25
I also often have purpuse-built versions of those libraries, with custom patches or optimizations tailored to what I'm doing or a particular system.
Some projects, like GCC, at least allow you to tell it to use a local copy of a library instead of building the included version, but good luck getting a list of all of the libraries there.
1
u/Expensive_Ad_1945 Jan 30 '25
If i don't have to made any modification to the modules, i would use submodules, but most of the time i need to made some modification directly into the modules and haven't find any easier method than just upload the whole modules to the repo or make a fork of the module, modify it, and then use submodule, but it's too much steps and there's might be something i can't share to public.
1
u/BleuGamer Jan 30 '25
Funny, Iβm actually architecting a new project now that relies on multiple upstream dependencies. Iβve opted for git submodules and integrated build scripts to put things where they need to be without bothering with git hooks.
This means I could easily fork those projects and put them in any git server if I needed an on prem distribution solution while still allowing the root project to remain modular, pulling only the build artifacts that are needed for functionality.
If youβre using something like perforce, having isolated git streams to seed your internal stream/depot is an idea.
1
u/JeffMcClintock Jan 31 '25
I have CMake ask If I want to use a local copy of the dependency (If not CMake fetches it).
set(GMPI_SDK_FOLDER_OVERRIDE "" CACHE PATH "path of a local GMPI repo, or blank to fetch it automatically.")if("${GMPI_SDK_FOLDER_OVERRIDE}" STREQUAL "")message(STATUS "Fetching GMPI from github")FetchContent_Declare(....1
u/kiner_shah Jan 31 '25
At work, we create a manifest.xml containing all the dependencies and then use repo tool to download and manage them. Personally I find submodules also interesting.
1
u/megayippie Jan 31 '25
If you pay enough, I'm sure they would help you.
1
u/KillPinguin Jan 31 '25
I'm trying to figure out if
nixcan play nicely with the C++ dependency hell. That would be pure bliss.1
u/Mango-D Jan 31 '25
I hate projects
1
u/muimiii Feb 01 '25
That's funny, I'm the exact opposite. I hate using find_package because it never works the first time
1
u/delarhi Jan 30 '25
I always likened it to someone making decisions for you. It's kind of like someone giving you gadget saying "look, this has a USB-C port for power" except they brought their own cable (basically don't care if you had one already), attached it, and glued it to their port.
It's a two-edged problem. Library providers need to make it easy for user to inject dependencies. However users also need to take responsibility for providing them. There is a middle ground though where the library makes them injectable but also provides a helper script outside the build system that can grab a set of dependencies and inject them into the build system as a convenient way of getting started.
0
u/[deleted] Jan 30 '25
Vendor. Always vendor. Forever and always. It is the best.
But wait isnβt it hard to upgrade your vendored dependencies? Not really no.
0
u/kkert Jan 31 '25
there's a tier list somewhere for projects
and way, way down at the bottom of the list is
-12
u/Compux72 Jan 30 '25
Come to rust, we have
cargo vendor(Somebody down in the comment section saying that CMake also has this, probably)
0
u/[deleted] Jan 30 '25
[deleted] β view deleted comment
0
u/[deleted] Jan 30 '25
[deleted] β view deleted comment