You are not logged in.

#1 2017-09-24 09:06:02

snack
Member
From: Italy
Registered: 2009-01-13
Posts: 861

Why Meson?

Since some years I rely on CMake for my C++ projects. I never used Autotools and made the jump from hand-written makefiles to CMake with great satisfaction. I thought that CMake was going to be wildly adopted in the open source world but then Meson came and at present it seems it is gain a lot of traction. I really think that Meson must have some obvious advantages in order to be so popular and often chosen in place of CMake; I read some articles on the web but the only clear advantage of Meson seems to be that it produces fast builds thanks to Ninja (but CMake has a Ninja backend too). I'd like some people who have experience of both build systems to tell their opinion.  Thanks.

Offline

#2 2017-09-25 00:48:38

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: Why Meson?

Hi! I don't have too much experience with this, but it is a topic that fascinates me. big_smile

I've been using GNU Autotools for a few years now... after spending a few years learning how to use the stupid thing. tongue Every so often I'll look into other newer more modern options to evaluate them, but I end up sticking with Autotools, mainly because I know it, it works, and it is SOOOOOOOO "standard" in the world of open source software.

I can't remember why I didn't consider Meson... I think it boils down to me being frustrated with all of the "magic words" in Autotools, but then finding out that EVERY build system has their own set of "magic words", so what's the point of switching. Logically, I know there's more to it than that, but, oh well. smile

I'm curious to hear about what other build systems people use!

Offline

#3 2017-09-25 01:04:23

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Why Meson?

I dunno, seems like it would be worth switching if only because autotools is an unholy combination of shellscript, Make, and m4 macros in the same file whereas meson is just one thing. Though in all fairness, most things that aren't autotools share that advantage. big_smile


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#4 2017-09-25 13:36:00

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: Why Meson?

Yeah, I can't argue with your complaints about GNU Autotools... big_smile

But at the same time, when I look at Meson I see that I need Python 3 and Ninja, which needs C++ and Python 2, and that's to compile my little C application, whereas with Autotools, if I have GNU then I know I have everything I need.

Anyway, I think I just convinced myself to give Meson a try. I do love trying new software! big_smile

Offline

#5 2017-09-25 13:49:39

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,448
Website

Re: Why Meson?

drcouzelis wrote:

... whereas with Autotools, if I have GNU then I know I have everything I need.

Whereas with any even remotely-close-to-POSIX-compliant OS, if I have a properly written and extremely concise Makefile, I have everything.

But to be fair, this thread is talking about Meson as a replacement for cmake.  While I'm pretty sure cmake could be used for C code, it generally isn't: cmake is generally used for C++ projects.

Further, cmake isn't autotools ... so saying autotools is a mix of shell scripts, m4, whatever else isn't particularly relevant to considering meson as an alternative to cmake (unless this thread is morphing into meson as a replacement for autotools).

My biggest head-scratch after reading the OP was "What the hell is meson?".  I looked it up and now I know what it is - but so what?  It's the flashy new thing.  Flashy new things come and go all the time.  Meson might last, but the way the OP is presented it sounds like meson has displaced cmake as the primary means of building C++ projects.  Unless this all happened very rapidly and very recently, this simply isn't the case.  Look at the repos and/or AUR: how many packages have cmake as a builddep?  Quite a lot.  How many have meson as a build dep?  **crickets chirping**.

Asking whether Meson is a good alternative to cmake is a fine question.  But this seems to be posed as a post-hoc "why did meson displace cmake?" and the answer to that is quite simple: it hasn't (yet?).

Last edited by Trilby (2017-09-25 13:50:32)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Online

#6 2017-09-25 14:08:02

ayekat
Member
Registered: 2011-01-17
Posts: 1,589

Re: Why Meson?

I can't hide my amusement about discovering that this thread was started the very day after I switched from hand-written Makefiles to meson/ninja smile

I have never used CMake nor GNU autotools, so it's hard to compare. I went for ninja over Make because I felt that hand-written Makefiles become a pain once the projects gets slightly larger than small scale, e.g. for managing different build variants (release, debug, asan, ...) or multiple, slightly decoupled components. Also, I felt that if I am to generate my build files, I might as well not need all the scriptability of Make (ninja is deliberately simple there). I don't care that much about speed (although it's a nice side-effect), but I do care about features I don't need.

I did not choose meson over CMake for any particular reason, but I think there I simply fell for the "new-and-shiny"-ness smile (also, some people I respect on #archlinux were advocating for it). But I was pleased to see that systemd and GTK+ had switched to meson recently, so at least I've got some reference code for my own meson build files.

EDIT Also, I was told that the CMake syntax is less readable than meson syntax—but that's purely subjective (and as I haven't used CMake before, I can't really confirm that either).

Last edited by ayekat (2017-09-25 14:10:49)


pkgshackscfgblag

Offline

#7 2017-09-25 16:04:42

snack
Member
From: Italy
Registered: 2009-01-13
Posts: 861

Re: Why Meson?

Trilby wrote:

But to be fair, this thread is talking about Meson as a replacement for cmake.  While I'm pretty sure cmake could be used for C code, it generally isn't: cmake is generally used for C++ projects.

Further, cmake isn't autotools ... so saying autotools is a mix of shell scripts, m4, whatever else isn't particularly relevant to considering meson as an alternative to cmake (unless this thread is morphing into meson as a replacement for autotools).

Thanks for bringing the discussion back on topic smile

Trilby wrote:

Meson might last, but the way the OP is presented it sounds like meson has displaced cmake as the primary means of building C++ projects.  Unless this all happened very rapidly and very recently, this simply isn't the case.  Look at the repos and/or AUR: how many packages have cmake as a builddep?  Quite a lot.  How many have meson as a build dep?  **crickets chirping**.

What I meant with my initial message was a slightly different thing: I assumed that CMake would be the choice for any project getting rid of Makefiles/Autotools; that happened in my working environment (high energy physics), but in other areas the choice was Meson. And it seems to me that the rate of adoption of Meson is increasing, so my question was: has Meson some killer feature that makes people prefer it over CMake when looking for a Makefile/Autotools replacement?

Offline

#8 2017-09-25 16:10:14

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: Why Meson?

Trilby wrote:

My biggest head-scratch after reading the OP was "What the hell is meson?".  I looked it up and now I know what it is - but so what?  It's the flashy new thing.  Flashy new things come and go all the time.  Meson might last, but the way the OP is presented it sounds like meson has displaced cmake as the primary means of building C++ projects.  Unless this all happened very rapidly and very recently, this simply isn't the case.  Look at the repos and/or AUR: how many packages have cmake as a builddep?  Quite a lot.  How many have meson as a build dep?  **crickets chirping**.

It's nothing like a mass exodus, but several high-profile projects have recently added meson support.
GTK/Gnome, systemd, mesa, X, libinput to name just a few.

Last edited by Slithery (2017-09-25 16:24:51)


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#9 2017-09-25 16:34:52

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,448
Website

Re: Why Meson?

I stand corrected, it seems meson usage may have taken off very rapidly and recently.

Snack, thanks for clarifying the question.  From my perspective, simplicitly seems to be a selling point.  I hadn't even heard of meson at the start of this thread, but I just now looked at a quick tutorial and feel like I could use meson for my code if I wanted.  I have - several times - tried to learn how to use autotools (from the coder side) and I end up rage-quitting every time.  Autotools is (relatively) easy for the end user to build the project, but every tutorial I find on using autotools for new code just ends up in an infinite regress of every autotools step relying on a pre-existing autotools product (how do I create a configure script, I need tools x, y, and z and a configure.in and a makefile.in and the makefile.in is created from a makefile.am which is the product of an m4 script that I have to write and from some other mysterious file, etc [note this is all probably wrong, but this the extent of understanding I've been able to get from reading autotools docs and tutorials: a total mess]).

I've also tried a bit to learn to use cmake, and while not the mess that autotools is, it seemed involved enough to not be worth it to me especially given it seems targetted at C++ code which I don't write.

So the killer feature of Meson may just be simplicity and/or ease of implementation.  Of course to me a Makefile is at least as simple, and doesn't require a handful of dependencies (any `make` implementation will do especially now that I'm ensuring my new Makefiles have no gnu-isms).

(edit: typos, 1 found, more remain)

Last edited by Trilby (2017-09-25 16:35:15)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Online

#10 2017-09-25 17:43:35

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Why Meson?

Raw Makefiles definitely win for simplicity and ease of use (albeit frequently rather ugly if you need to support Windows). big_smile

As for CMake...

http://blog.nirbheek.in/2016/05/gstream … 8738944056
https://www.murrayc.com/permalink/2016/ … ake-again/

CMake is okay, but it can be kind of clunky, e.g. the FindBlah.cmake concept is kind of scary IMHO -- because CMake dislikes pkg-config even if modern versions of CMake actually support it properly (not that that helps when you need to support e.g. Debian's CMake version, which is a common need).


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#11 2017-09-25 18:29:29

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: Why Meson?

drcouzelis wrote:

Yeah, I can't argue with your complaints about GNU Autotools... big_smile

But at the same time, when I look at Meson I see that I need Python 3 and Ninja, which needs C++ and Python 2, and that's to compile my little C application, whereas with Autotools, if I have GNU then I know I have everything I need.

AFAIK, ninja can be built with python3, too, so you only really need one python version.

Edit: Yes, you can even skip python if you do bootstrapping and configuration of the build some other way...

Last edited by progandy (2017-09-25 19:37:15)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#12 2017-09-25 18:53:17

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Why Meson?

AFAICT you don't need any python version at all... although ninja does fork and run the configured-with python executable together with a python script file, if you use `ninja -t browse` to ask it to launch a python server showing the dependency graph in a web browser.

And it defaults to the sys.executable of the python process used to bootstrap and/or build the ninja executable itself. Which should support python3, yes.

Last edited by eschwartz (2017-09-25 19:04:54)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#13 2017-09-25 19:39:57

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: Why Meson?

I did some more browsing... Here's the problem I always run into when looking at new build systems. sad

They always give these cute examples about how nice and simple and easy it is to use, but then when I find a real-world example, I see things like this:

https://github.com/baedert/gtkimageview … eson.build
https://github.com/lainsce/quilter/blob … eson.build
https://github.com/libratbag/piper/blob … eson.build
https://github.com/winksaville/baremeta … eson.build
https://github.com/GrokStreaming/gst-pl … eson.build
https://github.com/budgie-desktop/budgi … eson.build

...and it really doesn't look that much simpler to me, compared to the two files I need to make to start using GNU Autotools:

https://github.com/drcouzelis/colorwand … nfigure.ac
https://github.com/drcouzelis/colorwand … akefile.am

I understand that one file is simpler than two, and that Meson is way, way faster than Autotools, and that I'm only more comfortable with Autotools because I'm used to it, but it seems that ANY build system is going to be complicated because building software is complicated.

Offline

#14 2017-09-25 20:42:43

dmerej
Member
From: Paris
Registered: 2016-04-09
Posts: 101
Website

Re: Why Meson?

A few things to add:

One of CMake's nicest feature is integration with IDEs. It's really nice to use with QtCreator, and with the implementation of the 'cmake server', it' s going to be really great.
See this presentation for details.

Also, CMake is the only way to go if you have cross-platform software that must be built with Microsoft Visual Studio.

A common practice for some projects is to build dependencies before building the main project. Meson support for this is really nice, see Wrap dependency system manual for meson
CMake has ExternalProject_Add but it's more painful to use.

On the other hand, conan is the first C++ package manager I found that has all the features I need, and let you use pre-compiled dependencies, which is really, really great.

conan works very well with CMake, I'm not sure if it would work well with meson files, I did not try ...

Cheers, and may the Build be with you.


Responsible Coder, Python Fan, Rust enthusiast

Offline

#15 2017-09-26 01:56:14

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,354

Re: Why Meson?

drcouzelis wrote:

but it seems that ANY build system is going to be complicated because building software is complicated.

Which is also why new methods to doing it will always emerge. There's unlikely to ever be a fixed 'solution'.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#16 2017-10-06 10:37:28

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: Why Meson?

On a related note, systemd v235 released today has dropped automake and now only supports meson.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#17 2017-10-06 16:38:54

FSMaxB
Member
Registered: 2012-11-11
Posts: 17

Re: Why Meson?

I have used CMake in the past but have switched to meson for my biggest project. I didn't regret it so far.

The biggest advantage that Meson brought me is that I got to keep my sanity. CMake has some nice ideas, but the programming language that CMake uses is absolutely horrible. I have sometimes spent an entire weekend debugging my CMakeLists.txt for something that would have taken me 30 Minutes at most in Meson. Meson uses an object based (but non turing complete) configuration language that is easy to understand and doesn't have any strange rules. CMake on the other hand only has one data type: Strings. And then they have different kinds of variables with different scoping. I still haven't figured out exactly what variable is visible from where, it's just horrible. And there aren't any arrays or other higher level data types in CMake, they are just strings internally, and you can theoretically screw it up.

TL;DR: If you want to keep your sanity, use Meson.

What CMake has that Meson doesn't at the moment is good cross platform support. Meson has XCode and Visual Studio backend support, but CMake has much better support for more backends and provides cross platform commands like copy etc., also it is easier to install on Windows in my opinion. But that isn't enough to choose CMake from my point of view. I'd rather write cross platform python scripts to make up for the few thinks that Meson is lacking than using CMake. Also Meson has saner defaults and builtin support for e.g. AddressSanitizer and UndefinedBehaviorSanitizer as well as LTO, Code Coverage and Valgrind. Some of them are quite painful to set up with CMake.

Additionally Meson has the wrap dependency system and builtin support for subprojects.

Last edited by FSMaxB (2017-10-06 16:40:56)

Offline

Board footer

Powered by FluxBB