conan-center-index

Build and Package

This document gathers all the relevant information regarding the general lines to follow while writing either the build() or the package() methods. Both methods often use build helpers to build binaries and install them into the package_folder.

Contents

Build Method

Package Method

Build System Examples

The Conan’s documentation is always a good place for technical details. General patterns about how they can be used for OSS in ConanCenterIndex can be found in the package templates sections. These are excellent to copy and start from.

Header Only

If you are looking for header-only projects, you can take a look on header-only template. Also, Conan Docs have a section about how to package header-only libraries.

CMake

For C/C++ projects which use CMake for building, you can take a look on cmake package template.

Another common use case for CMake based projects, both header only and compiled, is modeling components to match the find_package and export the correct targets from Conan’s generators. A basic examples of this is cpu_features, a moderate/intermediate example is cpprestsdk, and a very complex example is OpenCV.

Autotools

There is an autotools package template amiable to start from.

However, if you need to use autotools for building, you can take a look on libalsa, kmod, libcap.

Many projects offer pkg-config’s *.pc files which need to be modeled using components. A prime example of this is Wayland.

No Upstream Build Scripts

For cases where a project only offers source files, but not a build script, you can add CMake support, but first, contact the upstream and open a PR offering building support. If it’s rejected because the author doesn’t want any kind of build script, or the project is abandoned, CCI can accept your build script. Take a look at Bzip2 and DirectShowBaseClasses as examples.

System Packages

Note: For exceptional cases where only system packages can be used and a regular Conan package may result in an incompatible and fragile package, a separated system package may be created. See the FAQs for more.

The SystemPackageTool can easily manage a system package manager (e.g. apt, pacman, brew, choco) and install packages which are missing on Conan Center but available for most distributions. It is key to correctly fill in the cpp_info for the consumers of a system package to have access to whatever was installed.

As example there is xorg. Also, it will require an exception rule for conan-center hook, a pull request should be open to allow it over the KB-H032.