Skip to content

Dependencies

Wu edited this page May 6, 2023 · 2 revisions

Cppship use conan2 as package manager. Currently, cppship won't maintain its own package registry to avoid further diverge c++ package manager community. It's highly recommended to contribute your packages to conan to be reusable.

Adding a dependency

If your cppship.toml doesn't already have a [dependencies] section, add that, then list the package name and version that you would like to use. This example adds a dependency of the fmt package:

[dependencies]
fmt = "9.1.0"

Dev dependencies

You can add dependencies only for tests/examples/benches via [dev-dependencies]

[dev-dependencies]
catch2 = "3.3.2"

Implicit dev-dependencies

There are some implicit dev-dependencies you can directly use in tests/examples/benches:

  • gtest/cci.20210126: for unittests
  • benchmark/1.7.1: for benchmarks

Git dependencies

For convenience, you can depend on non-conan packages if your project doesn't need to be reusable, eg. your project is a binary.

# git header-only libs
scope_guard = { git = "https://github.com/Neargye/scope_guard.git", commit = "fa60305b5805dcd872b3c60d0bc517c505f99502" }

# git cppship lib
simple_lib = { git = "https://github.com/cppship/demo_lib.git", commit = "25dbedf" }

Now cppship support packages on git with the following form:

  • Header-only libraries: such packages need not to be CMake based project, cppship will only search for include and use it
  • Cppship libraries

Warning: If you want your cppship packages to be reusable, please contribute to conan. If you put your cppship packages on git, they can be used by others, but easily suffer from name conflict with other cppship packages developed by other people.

Clone this wiki locally