Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 meson, I like however to still use Qt creators shortcuts for building (ctrl + B) or running (ctrl + R). How can I configure Qt creator to build a meson project, when I'm using a "generic project"?

like image 431
dani Avatar asked May 04 '17 20:05

dani


2 Answers

Meson is currently not directly supported by Qt Creator. There is a bug report requesting that: https://bugreports.qt.io/browse/QTCREATORBUG-18117 and I am considering to actually implement that.

For the time being I use meson via the "Generic Project". Go to "New File or Project", "Import Project" and there "Import Existing Project". That gets you a dialog where you can select the files that your project consists of.

After that is done you will need to edit "projectname.includes" and add the include directories (one per line) into that file. Then you need to edit "projectname.config" and add defines (one per line) there.

Finally you will need to edit the build configuration and call ninja instead of make there.

With that it works reasonably well for my small project.

like image 155
Tobias Hunger Avatar answered Oct 06 '22 08:10

Tobias Hunger


Until the QtCreator supports directly meson.build project files, I find this python2 script useful to create QtCreator generic project files: https://github.com/mbitsnbites/meson2ide

with meson and ninja in your PATH, this should work: $ meson builddir $ python2 meson2ide.py builddir

this generates a .creator project file in builddir (if you get an error about "mesonintrospect" not found, try this PR: https://github.com/mbitsnbites/meson2ide/pull/1)

To make CTRL+B work properly, In QtCreator build settings, remove the make build step and add a custom build step with the path to the ninja executable, and add the command line arguments

3>&1 1>&2 2>&3

Those redirect allow QtCreator to capture build errors in the "issue" panel.

like image 44
user3572526 Avatar answered Oct 06 '22 09:10

user3572526