46

A few years ago I looked into using some build system that isnt Make, and tools like CMake and SCons seemed pretty primitive. I'd like to find out if the situation has improved. So, under the following criteria, what is currently the best build tool:

  • platform agnostic: should work on windows, linux, mac
  • language agnostic: should have built-in support for common things like building C/C++ and other static langs. I guess it doesn't need to support the full autotools suite.
  • extensible: I need to be able to write rules to generate files, like from restructuredText, latex, custom formats, etc. I dont really care what language I have to write the rules in, but I would prefer a real language rather than a DSL.
  • I would prefer to avoid writing any XML by hand, which I think for example ant requires.
  • Freely available (preferably open source)

The term "best" is slightly subjective, but I think answers can be rated objectively by the criteria above.

Paul Biggar
  • 27,579
  • 21
  • 99
  • 152
  • I'm confused. You say "it doesn't need to support the full autotools suite". Does this mean your question should be rephrased: "What is the next best build system after autoconf/automake?" – William Pursell Dec 18 '09 at 18:37
  • @William Pursell: No. I'm explicitly leaving out the requirement of supportinging autoconf and automake, since its so tightly coupled to Makefiles. – Paul Biggar Dec 18 '09 at 19:06
  • 1
    I do not see anything wrong with the original question or the resulting discussion. Given that this question is now the lead search engine hit for "best build system", this question should be reopened. I could understand closing it if the discussion had in fact been opinionated, or if it had actually attracted spam, but that is not the case. – user1110743 Aug 31 '15 at 22:06

8 Answers8

25

I'd definitively put my vote up for premake. Although it is not as powerful as it's older brothers, it's main advantage is absurd simplicity and ease of use. Makes writing multi-compiler, multi-platform code a breeze, and natively generates Visual Studio solutions, XCode projects, Makefiles, and others, without any additional work needed.

naught101
  • 18,687
  • 19
  • 90
  • 138
Kornel Kisielewicz
  • 55,802
  • 15
  • 111
  • 149
  • Looks really nice. That said, it doesn't look like it supports much "out of the box"? – Paul Biggar Dec 18 '09 at 19:10
  • 2
    And Premake embeds a Lua interpreter, which is a more powerful scripting language than CMake's one, in my opinion. – Splo Dec 19 '09 at 13:36
  • 1
    And it doesn't need to download a Python interpreter for Windows like Scons or Waf. – Splo Dec 19 '09 at 13:38
  • I've switched all my projects to premake4, it's more than suitable for C/C++, and much easier than CMake. – Matt Joiner Jan 08 '10 at 06:31
  • Great info! I really haven't heard of this before. – kizzx2 Sep 01 '10 at 15:22
  • +1 for premake. @paul it supports quite a few build systems out of the box and more can be added/extended to suit your needs since the basic building blocks are all there. I'm currently working on adding borland toolset to it and looking into adding netbeans project generation support into it. – greatwolf Dec 04 '10 at 09:40
  • @Kornel Kisielewicz Premake is NOT language agnostic (it only supports C, C++, and C#). – Demi Jun 06 '14 at 23:58
  • @Demi I would imagine adding support for other languages wouldn't be much harder than it would be for GNU Make or similar. – yyny Dec 01 '16 at 17:44
15

Of course that depends on what your priorities are. If you are looking primarily for ease of use, there are at least two new build systems that hook into the filesystem to automatically track dependencies in a language agnostic fashion.

One is tup:

http://gittup.org/tup/

and the other is fabricate:

http://code.google.com/p/fabricate/

The one that seems to be the best performing, portable, and mature (and the one I have actually used) is tup. The guy who wrote it even maintains a toy linux distro where everything is a git submodule, and everything (including the kernel) is build with tup. From what I've read about the kernel's build system, this is quite an accomplishment.

Also, Tup cleans up old targets and other cruft, and can automatically maintain your .gitignore files. The result is that it becomes trivial to experiment with the layout and names of your targets, and you can confidently jump between git revisions without rebuilding everything. It's written in C.

If you know haskell and are looking for something for very advanced use cases, check out shake:

http://community.haskell.org/~ndm/shake/

Update: I haven't tried it, but this new "buildsome" tool also hooks into the filesystem, and was inspired by tup, so is relevant:

https://github.com/ElastiLotem/buildsome

Andrew Wagner
  • 22,677
  • 21
  • 86
  • 100
15

So, judging purely by the criteria set forth in the question, the build system that seems like the best fit is probably waf - pure Python, provides support for C++ and other languages, general, powerful, not a DSL.


However, from my personal experience, I prefer CMake for C++ projects. (I tried CMake, SCons, and waf, and liked them in roughly that order). CMake is a general solution, but it has built-in support for C++ that makes it nicer than a more generic solution when you're actually doing C++.

CMake's build model for C++ is more declarative and less imperative, and thus, to me, easier to use. The CMake language syntax isn't great, but a declarative build with odd syntax beats an imperative build in Python. Of the three, CMake also seems to have the best support for "advanced" things like precompiled headers. Setting up precompiled headers reduced my rebuild time by about 70%.

Other pluses for CMake include decent documentation and a sizable community. Many open source libraries have CMake build files either in-tree or provided by the CMake community. There are major projects that already use CMake (OGRE comes to mind), and other major projects, like Boost and LLVM, are in the process of moving to CMake.

Part of the issue I found when experimenting with build systems is that I was trying to build a NPAPI plugin on OS X, and it turns out that very few build systems are set up to give XCode the exact combination of flags required to do so. CMake, recognizing that XCode is a complex and moving target, provides a hook for manually setting commands in generated XCode projects (and Visual Studio, I think). This is Very Smart as far as I'm concerned.

Whether you're building a library or an application may also determine which build system is best. Boost still uses a jam-based system, in part because it provides the most comprehensive support for managing build types that are more complex than "Debug" and "Release." Most boost libraries have five or six different versions, especially on Windows, anticipating people needing compatible libraries that link against different versions of the CRT.

I didn't have any problems with CMake on Windows, but of course your mileage may vary. There's a decent GUI for setting up build dependencies, though it's clunky to use for rebuilds. Luckily there's also a command-line client. What I've settled on so far is to have a thin wrapper Makefile that invokes CMake from an objdir; CMake then generates Makefiles in the objdir, and the original Makefile uses them to do the build. This ensures that people don't accidentally invoke CMake from the source directory and clutter up their repository. Combined with MinGW, this "CMake sandwich" provides a remarkably consistent cross-platform build experience!

Ben Karel
  • 4,591
  • 2
  • 26
  • 25
  • I have to second this. MacOSX and CMake is just not a solution if you have quality in mind (using tools like the internationalization support). I will migrate our build system one day, it's currently working acceptable for a simpler english only app – Lothar Jun 16 '16 at 01:22
  • WAF is abysmal low quality code. Impossible to extend or even to read (I was wondering if it was obfuscated on purpose, but whatever it is, appears to be the only version there is). Impossible to debug or to predict what is it going to do. It's a joke of a program wrt software design, outright lame Python coding mixed with grotesque runtime code generation where it was absolutely unnecessary. Aaaand... it has a book written about it *facepalm*. – wvxvw Sep 07 '16 at 10:46
6

CMake

CMake is an extensible, open-source system that manages the build process in an operating system and in a compiler-independent manner.

Ben S
  • 68,394
  • 30
  • 171
  • 212
  • I gather it had windows problems a few years ago. Are they fixed? – Paul Biggar Dec 18 '09 at 18:25
  • I've only started using it recently and I haven't had an issue. Considering that MySQL uses it for its Windows builds, I can't see it having major issues. – Ben S Dec 18 '09 at 18:27
  • 2
    CMake is much better than autotools but it still use his own DSL and I see this as an impediment: You have to invest in learning new language. For this reason I would go for solutions like Waf (Python) or Rake (Ruby). – sorin Dec 22 '09 at 17:26
1

Gradle seems to match all the criteria mentioned above.

It's a build system which took the best of Maven and Ant combined. To me, that's the best.

Vincent Cantin
  • 16,192
  • 2
  • 35
  • 57
1

The Selenium project is moving over to Rake, not because its the best but because it handles multiple languages slightly better than all the other build tools and is cross platform (developed in Ruby).

All build tools have their issues and people learn to live with them. Something that runs on the JVM tends to be really good for building apps so Ant, Maven (i know its hideous), Ivy, Rake

AutomatedTester
  • 22,188
  • 7
  • 49
  • 62
0

Final Builder is well known in Windows world

Hugues Van Landeghem
  • 6,755
  • 3
  • 34
  • 59
  • 4
    I didnt think to mention that it should be free (preferably as in speech). I've fixed the question. – Paul Biggar Dec 18 '09 at 18:21
  • Wow. Even though it looks like a download-only program, they use icons reminding me of the Vista box that's impossible to figure out. – Ken Dec 18 '09 at 18:24
  • it is neither free, nor open. I have mixed feelings about final builder. it had some good features, such as a "debugger" but did not play well with ci servers. – Apeiron Aug 13 '19 at 23:07
-1

smooth build matches most of your requirements.

  • platform agnostic: yes, it's written in java
  • language agnostic: it doesn't support c/c++t yet, only java but it is extensible via plugins written in java so adding more compilers support is not a problem
  • extensible: yes, you can implement smooth function via java plugin, you can also create smooth function via defining it as expression built of other smooth functions.
  • I would prefer to avoid writing any XML: you won't see a single line of it in smooth build
  • Freely available: yes, Apache 2 license

disclosure: I'm the author of smooth build.

Marcin Mikosik
  • 788
  • 8
  • 21