Meson¶
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 conan.tools.meson import Meson
class PkgConan(ConanFile):
    def build(self):
        meson = Meson(self)
        meson.configure()
        meson.build()
    def package(self):
        meson = Meson(self)
        meson.install()
Reference¶
- class Meson(conanfile)¶
- This class calls Meson commands when a package is being built. Notice that this one should be used together with the - MesonToolchaingenerator.- Parameters:
- conanfile – - < ConanFile object >The current recipe object. Always use- self.
 - configure(reconfigure=False)¶
- Runs - meson setup [FILE] "BUILD_FOLDER" "SOURCE_FOLDER" [-Dprefix=/]command, where- FILEcould be- --native-file conan_meson_native.ini(if native builds) or- --cross-file conan_meson_cross.ini(if cross builds).- Parameters:
- reconfigure – - boolvalue that adds- --reconfigureparam to the final command.
 
 - build(target=None)¶
- Runs - meson compile -C . -j[N_JOBS] [TARGET]in the build folder. You can specify- N_JOBSthrough the configuration line- tools.build:jobs=N_JOBSin your profile- [conf]section.- Parameters:
- target – - strSpecifies the target to be executed.
 
 - install()¶
- Runs - meson install -C "." --destdirin the build folder.
 - test()¶
- Runs - meson test -v -C "."in the build folder.
 
conf¶
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.
- tools.compilation:verbositywhich accepts one of- quietor- verboseand sets the- --verboseflag in- Meson.build()
- tools.build:verbositywhich accepts one of- quietor- verboseand sets the- --quietflag in- Meson.install()