The Meson() build helper is intended to be used in the build() and package() methods, to call Meson commands automatically.

from conan import ConanFile
from import Meson

class PkgConan(ConanFile):

    def build(self):
        meson = Meson(self)

    def package(self):
        meson = Meson(self)


class Meson(conanfile)

This class calls Meson commands when a package is being built. Notice that this one should be used together with the MesonToolchain generator.

Parameters:conanfile< ConanFile object > The current recipe object. Always use self.

Runs meson setup [FILE] "BUILD_FOLDER" "SOURCE_FOLDER" [-Dprefix=PACKAGE_FOLDER] command, where FILE could be --native-file conan_meson_native.ini (if native builds) or --cross-file conan_meson_cross.ini (if cross builds).

Parameters:reconfigurebool value that adds --reconfigure param to the final command.

Runs meson compile -C . -j[N_JOBS] [TARGET] in the build folder. You can specify N_JOBS through the configuration line in your profile [conf] section.

Parameters:targetstr Specifies the target to be executed.

Runs meson install -C "." in the build folder. Notice that it will execute self.configure(reconfigure=True) at first.


Runs meson test -v -C "." in the build folder.


The Meson build helper is affected by these [conf] variables:

  • tools.meson.mesontoolchain:extra_machine_files=[<FILENAME>] configuration to add your machine files at the end of the command using the correct parameter depending on native or cross builds. See this Meson reference for more information.