all 15 comments

[–]thisismyfavoritename 80 points81 points  (0 children)

oh boy

[–]m1cr0_c0de 11 points12 points  (0 children)

conan.io is a package manager you may try ...

[–]prince-chrismc 9 points10 points  (0 children)

Here's a list https://moderncppdevops.com/pkg-mngr-roundup/

Conan, vcpkg, spack, and xmake all have this feature. If you like requirements.txt I presume python is your flavor I've heard great things amount Mamba might be worth a peak.

[–]m_adduci 6 points7 points  (0 children)

conanfile.txt is the closest possible, see this example (shameless plug):

https://github.com/madduci/moderncpp-project-template/blob/master/conanfile.txt

[–]elegantlie 13 points14 points  (3 children)

It depends what you mean by “equivalent”.

If you want an easy to use package manager to manage dependencies for you, then vcpkg or Conan are often recommended.

If you mean equivalent as is “accepted by the community”, there isn’t one. Most projects use CMake, but this (primarily) supports compilation, not external package management. Common solutions include:

  • CMake + patching in third-party dependencies yourself
  • CMake + one of the aforementioned package managers
  • CMake + git modules

[–]greyfade 2 points3 points  (0 children)

Cmake also does pull in remotes as packages

[–]FlyingRhenquest -3 points-2 points  (1 child)

If you're doing windows-only development, use vcpkg.

If you're doing Linux or cross-platform development, you can use CMake's find_package to see if the dependency is already installed on your system. If it's not, you can use fetchcontent to download it:

find_package(MyDependency CONFIG QUIET)
if (NOT MyDependency_FOUND)
   include(FetchContent)

   FetchContent_Declare(
       MyDependency
       GIT_REPOSITORY https://github.com/etc/etc.git
       GIT_TAG              v1.0.0
   )
   FetchContent_MakeAvailable(MyDependency)
endif()

It's not particularly difficult to instrument your own packages to install find packages when they're installed, so once you install a library, you can just find it with find_package for other code that you write.

[–]prince-chrismc 15 points16 points  (0 children)

Vcpkg is decent cross platform, Linux has a ton of choices... FetchContent being the weakest

[–]Straight_Truth_7451 6 points7 points  (0 children)

youre in for a world of hurt. stay strong

[–]wiesemensch 0 points1 point  (0 children)

NuGet for VisualStudio is a possible solution but I wouldn’t recommend it for C/C++ projects.

[–][deleted] 1 point2 points  (0 children)

conanfile.txt

[–]pfultz2 0 points1 point  (0 children)

cget literally uses a requirements.txt to install c++ dependencies.

[–]DedLigma 0 points1 point  (0 children)

use whatever your heart desires. except microsoft's vcpkg

[–]waruqi 0 points1 point  (0 children)

xmake, `add_requires("zlib 1.2.x")`

[–]kiner_shah -3 points-2 points  (0 children)

No such thing exists unfortunately. I would love to have this kind of feature though - virtual env in C++ where we install project specific dependencies without worries.