Updated 16th of January 2019: Refined advice as tools evolve.
I have used autotools before for a considerable amount of time.
Currently I make intensive use of meson and cmake only when I need it.
Some personal advice:
for big teams, stick to CMake if you want to make use of the generators for XCode. If you do not need it, I would use Meson directly. Meson, as of version 0.49, also supports finding CMake configuration files (though I did not test yet how well this works). Also, Visual Studio seems to be sufficiently well-supported at this point in time, though, again, I did not try myself. The advantage of CMake is that it has Visual Studio integration.
Drop autotools. Meson covers well everything already. Their cross-compilation model is amazingly understandable. In CMake, last time I checked, everything was quite more difficult.
I have also tried scons, waf, and tup.
The most full-featured, cross-platform system, is CMake
, but the DSL from meson will be easier to use for people used to python and others. Meson is starting to support VS also (a VS2015 generator) and some projects already have experimental support for it, for example gstreamer. Gstreamer is compiled in windows as well with meson. Right now there is VS2015 generator and VS2017 but I did not try myself the generators lately. As of meson 0.37.1 needed some work, but they are improving them and current version is already 0.40.
Meson
Pros:
- The DSL does not get in the way at all. In fact, it is very nice and familiar, based in python.
- Well-thought cross compilation support.
- The objects are all strongly typed: you cannot make string substitution mistakes easily, since objects are entities such as 'depencency', 'include directory', etc.
- It is very obviuos how to add a module for one of your tools.
- Cross-compilation seems more straightforward to use.
- Really well-thought. The designer and main writer of Meson knows what
he talks about very well when designing a build system.
- Very, very fast, especially in incremental builds.
- The documentation is 10 times better that what you can find in cmake. Go visit http://mesonbuild.com and you will find tutorial, howtos and a good reference. It is not perfect but it is really discoverable.
Cons:
- Not as mature as CMake, though, I consider it already fully usable for C++.
- Not so many modules available, though, gnome, qt and the common ones are already there.
- Project generators: seems VS generator is not working that well as of now. CMake project generators are far more mature.
- Has a python3 + ninja dependency.
Cmake
Pros:
- Generates projects for many different IDEs. This is a very nice feature for teams.
- Plays well with windows tools, unlike autotools.
- Mature, almost de-facto standard.
- Microsoft is working on CMake integration for Visual Studio.
Cons:
- It does not follow any well known standard or guidelines.
- No uninstall target.
- The DSL is weird, when you start to do comparisons and such, and the strings vs list thing or escape chars, you will make many mistakes, I am pretty sure.
- Cross compilation sucks.
Autotools
Pros:
- Most powerful system for cross-compilation, IMHO.
- The generated scripts don't need anything else than make, a shell and, if you need it to build, a compiler.
- The command-line is really nice and consistent.
- A standard in unix world, lots of docs.
- Really powerful command-line: changing directories of installation, uninstall,
renaming binaries...
- If you target unix, packaging sources with this tool is really convenient.
Cons:
- It won't play well with microsoft tools. A real showstopper.
- The learning curve is... well... But actually I can say that CMake was not that easy either.
- The use of recursive make is pervasive in legacy projects. Automake supports non-recursive builds, but it's not a very widely used approach.
About the learning curve, there are two very good sources to learn from:
The first source will get you up and running faster. The book is a more in-depth discussion.
From Scons, waf and tup, Scons and tup are more like make. Waf is more like CMake and the autotools. I tried waf instead of cmake at first. I think it is overengineered in the sense that it has a full OOP API. The scripts didn't look short at all and it was really confusing for me the working directory stuff and related things. At the end, I found that autotools and CMake are a better choice. My favourite from these 3 build systems is tup.
Tup
Pros
- Really correct.
- Insanely fast. You should try it to believe it.
- The scripting language relies on a very easy idea that can be understood in 10 minutes.
Cons
- It does not have a full-featured config framework.
- I couldn't find the way to make targets such as
doc
, since
they generate files I don't know of and they must be listed in the output before being generated, or at least, that's my conclusion for now. This was a really annoying limitation, if it is, since I am not sure.
All in all, the only things I am considering right now for new projects is are Cmake and Meson. When I have a chance I will try tup also, but it lacks the config framework, which means that it makes things more complex when you need all of that stuff. On the other hand, it is really fast.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…