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
.
For the build()
method, the general scope used to build artifacts. Please, read
the official reference to the build() method and the
Build packages: the build() method.
The package()
method is used to copy the artifacts to the package_folder
. Please, read the official reference to the
package() method and the
Package files: the package() method.
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.
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.
For C/C++ projects which use CMake for building, you can take a look on cmake package template.
There is an autotools package template amiable to start from.
For cases where a project only offers source files but does not provide a build script, you can add CMake support. However, it is essential to first contact the upstream maintainers and open a pull request (PR) offering building support. If your PR is rejected because the author does not want any kind of build script, or if the project is abandoned, Conan Center Index (CCI) will consider accepting your build script based on the effort required to maintain it, as we aim to avoid adding scripts that may require significant ongoing maintenance. Take a look at Bzip2 as example.
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 package_manager 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.