Creating packages

This section shows how to create Conan packages using a Conan recipe. We begin by creating a basic Conan recipe to package a simple C++ library that you can scaffold using the conan new command. Then, we will explain the different methods that you can define inside a Conan recipe and the things you can do inside them:

  • Using the source() method to retrieve sources from external repositories and apply patches to those sources.
  • Add requirements to your Conan packages inside the requirements() method.
  • Use the generate() method to prepare the package build, and customize the toolchain.
  • Configure settings and options in the configure() and config_options() methods and how they affect the packages’ binary compatibility.
  • Use the build() method to customize the build process and launch the tests for the library you are packaging.
  • Select which files will be included in the Conan package using the package() method.
  • Define the package information in the package_info() method so that consumers of this package can use it.

After this walkthrough around some Conan recipe methods, we will explain some peculiarities of different types of Conan packages like, for example, header-only libraries, packages for pre-built binaries, packaging tools for building other packages or packaging your own applications.