Skip to content

Instantly share code, notes, and snippets.

@npodonnell
Last active September 12, 2021 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save npodonnell/a42ad385a3ddbdfb9dfa230a578ab567 to your computer and use it in GitHub Desktop.
Save npodonnell/a42ad385a3ddbdfb9dfa230a578ab567 to your computer and use it in GitHub Desktop.
Conan Cheatsheet

Conan Cheatsheet

N. P. O'Donnell, 2020, 2021

Online Resources

Installation

Install Conan:

pip install conan

Working with Packages

Remotes

To consume packages, you need to have one or more remote repositories (remotes) configured.

List remotes:

conan remote list

Add a new remote (conan-center in this example):

conan remote add conan-center https://center.conan.io

Search for a package in conan-center:

conan search nlohmann_json --remote=conan-center

Inspect the package (prints some metadata):

conan inspect nlohmann_json/3.9.1

Conan Cache

All conan packages, whether fetched from a remote, or built locally with conan create, are cached in the conan cache which is typically located in ~/.conan/data.

Conanfile

This file goes in the root directory and is divided into sections, each identified by a name enclosed in square brackets.

[requires] Section

Dependencies go here.

[generators] Section

The tool used to generate the makefiles (or whatever) which eventually build your software. For example CMake.

Example conanfile.txt with one dependency using cmake generator:

[requires]
nlohmann_json/3.9.1

[generators]
cmake

Installing

To install dependencies, change into the build directory: build, or cmake-build-debug for CLion users, and type:

conan install ..

Editable Packages

When developing several related packages at the same time, such as aa library and an app which uses the library, it's handy to make the library package editable.

List editable packages:

conan editable list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment