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
- Use the
generate()method to prepare the package build, and customize the toolchain.
- Configure settings and options in the
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
- Define the package information in the
package_info()method so that consumers of this package can use it.
- Use a test_package to test that the Conan package can be consumed correctly.
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.
- Create your first Conan package
- Handle sources in packages
- Add dependencies to packages
- Preparing the build
- Configure settings and options in recipes
- Build packages: the build() method
- Package files: the package() method
- Define information for consumers: the package_info() method
- Setting information in the package_info() method
- Define information for consumers depending on settings or options
- Properties model: setting information for specific generators
- Propagating environment or configuration information to consumers
- Define components for Conan packages that provide multiple libraries
- Read more
- Testing Conan packages
- Other types of packages