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
499
questions
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 ...
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 ...
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 ...
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....
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 ...
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?
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 ...
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
└──...
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 ...
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 ...
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 ...
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?
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 ...
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 ...
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
...
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 ...
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 ...
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 ...
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. ...
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, ...
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 ...
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 ...
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 ...
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('...
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 ...
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'...
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 ...
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 (...
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 ...
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 ...
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 (...
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('...
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 ...
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:
...
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 ...
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() + '/...
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 (...
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(
...
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 ...
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 ...
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 -...
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',...
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-...
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 ...
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) ...
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 ...
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 ...
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:...
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 ...
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'...