Questions tagged [meson-build]

Meson is a build configuration system used to build C/C++, Java, Rust, Objective-C/C++, and Fortran projects. It uses a DSL to describe project targets. This tag is for questions about the meson build system and DSL syntax or usage.

meson-build
Filter by
Sorted by
Tagged with
21 votes
2 answers
17k views

MesonBuild: How to define dependency to a library that cannot be found by `pkg-config`?

My project (in C) has a third party dependency at build time. But the third party library is, by default, installed to /opt/ instead of /lib, and I cannot find it in pkg-config. From mesonbuild's ...
Chong's user avatar
  • 953
14 votes
1 answer
15k views

How do I set basic options with meson?

I'm trying to configure a project with meson. Specifically, I'm trying to set some of the options. meson config tells me, among other things: Core options: Option Current Value Possible ...
einpoklum's user avatar
  • 124k
14 votes
2 answers
4k views

How to setup meson with Qt creator

I normally use Qt creator with cmake to program C++ projects. Lately I read quite a bit about meson and it's simplicity and I like to test it. This example explains how to setup meson. When using ...
dani's user avatar
  • 3,727
12 votes
3 answers
10k views

Meson: how to make find_library() works with an unusual path?

For my Meson project I have a dependency that is in an "unusual" place: /opt/MyDependence/lib/libmyLib.so /opt/MyDependence/include/myLib.hpp My meson file is: project('Test', ['cpp']) cpp = meson....
Picaud Vincent's user avatar
12 votes
3 answers
18k views

How can I specify library path when using Meson?

I'm trying to build a c++ project with Meson. The thing is, I have some libraries under /opt/conda but can't figure out how to link the project when running meson build. It seems to be only searching ...
Jinu's user avatar
  • 566
12 votes
4 answers
7k views

Can you glob source code with meson?

Is it possible to glob source code files in a meson build?
oz10's user avatar
  • 156k
10 votes
1 answer
6k views

'cmake rebuild_cache' for *just* a subdirectory?

I have an issue with the generation of makefiles stage of CMake being slow which is similar to this unanswered question: CMake is slow to generate makefiles My project is made up of a top level ...
Bruce Adams's user avatar
  • 5,301
9 votes
3 answers
6k views

Meson targets that depend on subdir siblings

Here is my project structure: . ├── include ├── src │   ├── abc │   │   ├── include │   │   └── src │   ├── def │   │   ├── include │   │   └── src │   └── ghi │   ├── include │   └── src └──...
sdgfsdh's user avatar
  • 35.4k
9 votes
2 answers
7k views

Does meson has a general function to print out any type variables's value?

I've encountered some projects which uses meson to organize their building system. But when I want to debug their building system, I found it's difficult. The most important task is observing the ...
Clock ZHONG's user avatar
9 votes
1 answer
9k views

Handling Meson build options with multiple buildtypes

Having read the Meson site pages (which are generally high quality), I'm still unsure about the intended best practice to handle different options for different buildtypes. So to specify a debug ...
Jetski S-type's user avatar
8 votes
2 answers
5k views

How to set up googletest wtih meson?

I have a git repository with some test code in C++ and I want to use Googletest to write some tests. I used git submodule to get it as part of the above repository. I want to use meson as the build ...
Sardathrion - against SE abuse's user avatar
7 votes
1 answer
8k views

Is `meson.source_root()` the project root directory?

Is the directory return by meson.source_root() the project root directory (with the root level meson.build file) or is it the path of the current meson.build file being processed?
oz10's user avatar
  • 156k
7 votes
1 answer
734 views

Is there a tool for meson similar/equivalent to CPack for CMake?

I have recently started learning meson and I am testing switching to it (from CMake) in one of my projects. The problem is that I usually use cpack to build the project's packages/installers, and ...
Object object's user avatar
7 votes
1 answer
1k views

How do I speed up Meson build when many targets use the same C++ sources

I have a new meson project with 58 targets. Many of them use the same *.cc files, and meson builds each *.cc file once for each target, which is much slower than autotools. Also, the compile flags ...
Benjamin Redelings's user avatar
7 votes
1 answer
688 views

Meson cannot find pykeepass module, I am certain it is installed

I am attempting to build an application using meson, Gnome PasswordSafe. I have successfully built it on Arch, but have since moved to PureOS (Debian). When running: $ meson . _build --prefix=/usr ...
dc3p's user avatar
  • 79
6 votes
3 answers
2k views

Can Meson read the contents of a file

Is it possible for Meson to read the contents of a file into an array or a string? From here a string can be split into an array, and an array can be looped over with foreach, but I haven't been able ...
Pentarctagon's user avatar
6 votes
1 answer
10k views

Meson and NInja build system: specify where binaries are stored

I have a project that needs to be built like this: ./meson.py build ./ninja -C build install This works well. The only thing is: the binaries are stored in (on Linux): /usr/local/bin. This would ...
mle0312's user avatar
  • 415
6 votes
2 answers
3k views

How to copy a file in Meson to a subdirectory

My application uses a Glade file and also cached data in a JSON file. When I do the following, everything works okay as long as the user installs the application with ninja install #Install ...
g_l's user avatar
  • 641
6 votes
2 answers
3k views

Can the meson project version be assigned dynamically?

I am new to Meson so please forgive me if this is a stupid question. Simple Version of the Question: I want to be able to assign a dynamic version number to the meson project version at build time. ...
Señor CMasMas's user avatar
6 votes
2 answers
7k views

Set PKG_CONFIG_PATH inside meson.build

I am using meson in a couple of C projects (projectA and projectB), where projectB links to a library from projectA. In projectA/meson.build, I have written a pkg-config projectA.pc file using meson, ...
zeehio's user avatar
  • 4,098
6 votes
1 answer
7k views

ERROR: Could not detect Ninja v1.8.2 or newer - Meson

When I try to run Meson, It complains that it can't find Ninja v1.8.2 or newer. I ran this: meson build-debug This resulted in the error explained above. I have the latest tools: Ninja v1.10.2 Meson ...
GitSD's user avatar
  • 76
6 votes
1 answer
8k views

how to set debug and optimization flag with meson

I use meson 0.53.2 on ubuntu 20.04. I would like to have a maximally optimized executable (-Ofast) but contain all debug symbols (-g3) If I use --buildtype=release it optimizes -O2 and the executable ...
mastupristi's user avatar
  • 1,286
6 votes
0 answers
2k views

How to print all dependencies in meson?

I checked out a gtk project inside a docker and during meson build found many dependencies are missing eg. libwayland-dev, libxrandr-dev... Because meson fails at the first missing dependency, I had ...
ryanafrish7's user avatar
  • 3,302
6 votes
1 answer
2k views

How to get the include directories from a dependency in meson build system

In meson build system, I want to get the include directories from a dependency: Simple example meson.build, using wxWidgets dependecy as example: project('project1', ['cpp']) wxdep = dependency('...
foolo's user avatar
  • 878
5 votes
1 answer
2k views

How to give releative path for dirs option in meson build to find the thrid party library?

I am trying to build custom gst-plugin which has third party library dependency. With cc.find_library and dirs option (takes absolute path) I am able to build the setup. But I want to include the ...
saleem's user avatar
  • 53
5 votes
2 answers
2k views

How can i define DEBUG when the build type is debug?

I want to pass "-DDEBUG" to the C++ compiler when the build type starts with "debug", something like this: if meson.build_type().starts_with('debug') add_global_arguments('-DDEBUG', language : 'cpp'...
Jens Mühlenhoff's user avatar
5 votes
3 answers
4k views

Prefix all sources with src/ in Meson

Relative to my project root where meson.build is located, all of my source files are under src/. Is it possible to specify these source files in meson.build in a way that wouldn't force me to prefix ...
sssilver's user avatar
  • 2,659
5 votes
1 answer
10k views

Meson picks the wrong compiler (GCC instead on clang)

I am trying to configure my project to build with LLVM/clang++, however GCC is always picked: $ /opt/llvm/clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-18.04/bin/clang++ --version clang version 7.0.1 (...
Pietro's user avatar
  • 12.5k
5 votes
2 answers
3k views

Flatpak Meson Not Finding Vala Libraries From Gnome Builder

From Linux, I'm using Meson (0.44.0) within Gnome Builder (3.26.4) for a console program that will use Gee and GXml. My intent is to write this in Genie. When I use Meson within Gnome Builder it ...
AsymLabs's user avatar
  • 953
5 votes
1 answer
2k views

In meson build, can you set the working directory for unit tests?

In a meson build, is it possible to set the working directory before executing unit tests? It uses ninja by default to run the tests, so perhaps there's an option you can pass to ninja to set the ...
oz10's user avatar
  • 156k
5 votes
2 answers
6k views

Unable to install Scipy with MKL using Meson

I am attempting to install scipy 1.9.1 with the MKL implementation of BLAS, using pip as my package manager. For numpy, I can do this with: pip install numpy --no-binary numpy. Doing this with Scipy (...
Evan Gaertner's user avatar
5 votes
1 answer
3k views

Cannot use the C++ `std::filesystem` library with Meson build

I am trying to build a piece of C++ code that uses the new C++17 Filesystem library, using the Meson build system. This is the piece of meson.build file involved: if not compiler.has_header('...
Pietro's user avatar
  • 12.5k
5 votes
2 answers
3k views

is there any way to use conan package in meson?

We can use meson build system in conan. But I cannot find any document about how to add conan package as dependency in meson.build. It is very simple in cmake, we can simply use conan_cmake_run. How ...
Wang's user avatar
  • 7,717
4 votes
2 answers
3k views

In meson can you test for presence of a directory in your project?

Using meson build, is it possible to test for the existence of a directory in my project? For example, I typically put acceptance tests next to my unit tests in a folder structure like this: ...
oz10's user avatar
  • 156k
4 votes
2 answers
13k views

Link static library to shared library or to a binary

I have a static library from the project A (let's call it liba.so) and I want to compile a shared library in my project B (let's call it libb.so) and embed liba.so in it. Also, I have a binary in ...
alexandernst's user avatar
  • 14.8k
4 votes
1 answer
2k views

Cannot run Doxygen from Meson on a C++ project

I cannot run Doxygen through Meson's configuration. This is the related code in meson.build: doxygen = find_program('doxygen') ... run_target('docs', command : 'doxygen ' + meson.source_root() + '/...
Pietro's user avatar
  • 12.5k
4 votes
2 answers
3k views

How to run post build commands in meson?

How can I do in meson to run a command after building a target? Eg. I have an executable: executable('target.elf', 'source1.c', 'source2.c') And after target.elf built I want to execute a command (...
LGabci's user avatar
  • 115
4 votes
1 answer
4k views

Meson absolute path from include_directories

In Meson, is it possible to get a string absolute path from an object created by a call to include_directories? My use case: include_dirs = include_directories('include') lib = library( ...
Aart Stuurman's user avatar
4 votes
2 answers
2k views

How can I run a custom command at build time in meson?

in my projects I adopt a semantic versioning scheme following the standard described by semver. I obtain something like this: product_v1.2.3-alpha-dirty.elf . I work with embedded system and with make ...
LeonFibuck's user avatar
4 votes
1 answer
4k views

How to perform code coverage in C++ using meson?

I'm using meson and ninja as build system in my C++ project and I've configured catch2 as testing framework. I was wondering how to perform code coverage with the tests that I've written. I read ...
Antonio La Marra's user avatar
4 votes
2 answers
1k views

How can I tell meson in which directories to look for dependencies?

I am coming from CMake to meson. I like to work in isolated environments using conda. This way I can control which packages are installed for each project. Now, In cmake I would pass -...
Avi Shukron's user avatar
  • 6,098
4 votes
1 answer
3k views

When defining external dependencies in meson, can you add search paths?

When defining a target in meson, you can declare dependencies on external projects using the following syntax: zdep = dependency('zlib', version : '>=1.2.8') exe = executable('zlibprog', 'prog.c',...
oz10's user avatar
  • 156k
4 votes
1 answer
808 views

How to build/cross-compile an existing meson or cmake project under Android AOSP?

I am trying to understand how to build executable and libraries using Android.mk and Android.bp under AOSP. And I am able to compile simple c programs. I was wondering if there is a way to cross-...
masterajay's user avatar
4 votes
1 answer
422 views

How to compile Node.js native api extension via meson build system

I want compile Node.js C/C++ extension without using node-gyp package. I have experience with meson and would use it to compile Node.js module. Can u suggest example with how to compile Node.js ...
Vitold S.'s user avatar
  • 422
4 votes
0 answers
97 views

How to add vala language into some existing c/c++ project?

Vala has c# like syntax and compiles to c code for performance, I would like to try it with some of my existing projects. But my existing projects are all c/c++ (mainly c++ with cmake build system) ...
user avatar
4 votes
0 answers
1k views

How to cross-compile with Meson and a Python dependency?

I'm trying to cross-compile an application using Meson. The application has a Python dependency. I'm building on a Linux system (the build machine) and I'm building a Windows executable (the host ...
EvR's user avatar
  • 105
4 votes
0 answers
369 views

Can you execute unit tests as a post build event in meson?

It appears to be trivial to define unit test executables in meson and to execute them with ninja test. Is it possible to execute unit tests as a post build event in solutions generated with meson ...
oz10's user avatar
  • 156k
3 votes
4 answers
15k views

How to run meson build system on windows?

I would like to use meson build system on windows. I am python noob. It looks like I installed it, but I do not know how to run it. I have installed python 3.6. I have installed meson from 'cmd': C:...
urkon's user avatar
  • 243
3 votes
2 answers
3k views

how to set meson link dependency for buildin lib as "-lm -lrt"

on meson build, dependencies are resolved by pkg-config/cmake ... but for system libs, no docs. I only find 2 of them: zlib stands for -lz threads stands for -lpthread then how can I link -lm -lrt ...
fanlix's user avatar
  • 1,308
3 votes
2 answers
4k views

How to run a shell command from a Meson script?

How can I run a shell command (e.g. cp, i.e. copy) from a Meson build script? I tried with this code: r = run_command('cp', 'test.txt', 'test2.txt') if r.returncode() != 0 warning('Command failed'...
Pietro's user avatar
  • 12.5k

1
2 3 4 5
10