We are pleased to announce that Conan 1.45 is
out and comes with some
significant new features and bug fixes. There is a new implementation to invoke system
package managers under
that replaces the current
Also, we have updated the markdown
generator to create
the information needed to consume packages with the new tools for
Pkg-config. We added
two new templates for the command
conan new, to generate examples of an application and
a library using the Meson build system. Also, this Conan
release comes with several improvements in
New conan.tools.system.package_manager tools
In Conan 1.45 we added new helpers to invoke system package managers in recipes to substitute the current SystemPackageTool implementation. These tools provide wrappers for the most known system package managers like: Apt, Yum, Dnf, Brew, Pkg, PkgUtil, Chocolatey, PacMan and Zypper. These should be used inside the system_requirements() method of your recipe.
You can support multiple system package managers in the same recipe, Conan will only execute
the one set with the
or, in case this value is not set, will decide which one to use based on the operating
For example, if we have a recipe with a
system_requirements() method like this:
from conan.tools.system.package_manager import Apt, Yum, PacMan, Zypper ... def system_requirements(self): Apt(self).install(["libgl-dev"]) Yum(self).install(["libglvnd-devel"]) PacMan(self).install(["libglvnd"]) Zypper(self).install(["Mesa-libGL-devel"])
If we run this example in Ubuntu Linux, Conan would execute only the
The signatures of these classes are very similar between them, there are three methods you can call to invoke these wrappers:
install(self, packages, update=False, check=False): install the list of packages passed as a parameter.
update(): update the system package manager database.
check(packages): check if the list of packages passed as a parameter are already installed.
Conan, by default, will never try to install any package using these wrappers unless you
set the configuration
tools.system.package_manager:mode to value
install. If that is
not set, it will work in
tools.system.package_manager:mode=check, meaning that
install operations will never be performed. Nevertheless, in case you are calling to
tools.system.package_manager:mode=check, Conan will check if
there’s any package missing and in case they are all installed it will continue without
There are some slight differences between the constructors and methods between these tools, please check the documentation for more details.
Updated markdown generator
The markdown generator (introduced in Conan 1.24) creates a markdown
(.md) file with
useful information about how to consume this package through different Conan generators.
Since this version, it’s updated and generates this information for the new tools for
Pkg-config. Using it
is as simple as adding it as an argument to the
conan install command.
conan install fmt/8.1.1@ --generator markdown
Then, you can check the generated
fmt.md file and see, for example, which target names
you have to use to consume this library using
CMake in your projects:
New meson templates for conan new
conan new command is practical to create a template for a C++ project using Conan.
Until Conan 1.45 there were two built-in templates in Conan for CMake projects:
cmake_exe. From this version, you can also use two new templates
to scaffold a project using the Meson build system:
If you have meson installed in your system, you can test it by running:
conan new hello/1.0 -m=meson_lib
That will create a project with the following structure:
. ├── conanfile.py ├── meson.build ├── src │ ├── hello.cpp │ └── hello.h └── test_package ├── conanfile.py ├── meson.build └── src └── example.cpp
To build the project, just run:
conan create .
If you would like to see more built-in templates in Conan, please do not hesitate to contribute them to the GitHub repository. Also, remember that you can always use your own defined templates. Please check the documentation for more information.
Several improvements in Meson, PkgConfig, CMake, Bazel and MSVC tools
Finally, there are a few improvements and fixes worth mentioning, like:
- Improve the MesonToolchain formatting of generated files and include some cross-building functionality.
- Document the
behaviour in the case that a component and the root
cpp_infohave the same name, the component
*.pcwill take preference and be generated instead of the root
conan.tools.microsoft.visualto identify when using msvc with static runtime and
is_msvc()to validate if
settings.compileris Visual Studio with msvc compiler.
- Several bug fixes for the Bazel generator.
Besides the items listed above, there were some minor bug fixes you may wish to read about. If so, please refer to the changelog for the complete list.
We hope you enjoy this release, and look forward to your feedback.