How to setup meson with Qt creator
Asked Answered
B

2

14

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"?

Burnsides answered 4/5, 2017 at 20:24 Comment(2)
It's worth a mention that there is plugin project for this: github.com/qtcreator-meson-plugin/qtcreator-meson-pluginLynellelynett
This list may be useful as well: mesonbuild.com/IDE-integration.html#existing-integrationsEpiscopal
S
10

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.

Sgraffito answered 6/5, 2017 at 17:10 Comment(1)
It seems like this is work in progress now: github.com/qtcreator-meson-plugin/qtcreator-meson-pluginLubalubba
D
6

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.

Deportation answered 20/2, 2018 at 11:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.