Reputation: 15863
What are the differences between Autotools, Cmake and Scons?
Upvotes: 297
Views: 121711
Reputation: 475
CMake while generally referred to as a build system is really a different beast entirely. It is technically a build generator, meaning it can generate build systems. Makefiles, Ninja, VS project files, XCode project files. CMake can generate these platform-agnostically. You can generate a visual studio solution from a linux machine, for example. One advantage of this is that it gives developers flexibility with respect to what platforms they can code on. No need to bring a MinGW ecosystem or ssh back/forth if you wanna go from a linux dev machine to a windows one or vice versa. It also simplifies CI/CD a bit.
CMake has changed A LOT over the years. It's no longer comparable to autotools in my opinion. And using it as if it were like autotools is a bit like using C++ as if it were C with classes. In fact, standard procedure for modern CMake is to bring in external libraries remotely using FetchContent which automatically includes that library's CMake targets for you to link against. So if a project uses CMake correctly, other projects will be able to fetch it in an almost plug-and-play fashion.
One of the weird things about CMake is that most people using it are a few years behind on feature cognizance, because of the abundance of 10+ year old stackoverflow posts and various articles on the internet explaining how to do something the antiquated way and not the modern CMake way.
For example I see a lot of CMake projects still using ExternalProject and building up the targets manually when they don't need to. I see some projects where people have hardcoded compilers, paths, environment variables, and generally just treating CMake like a fancy makefile. If you're using it that way, might as well just use autotools since you just nerfed all the features that make CMake different.
It just doesn't CMake any sense.
Upvotes: 0
Reputation: 4576
While from a developers point of view, cmake is currently the most easy to use, from a user perspective autotools have one big advantage
autotools generate a single file configure script and all files to generate it are shipped with the distribution. it is easy to understand and fix with help of grep/sed/awk/vi. Compare this to Cmake where a lot of files are found in /usr/share/cmak*/Modules, which can't be fixed by the user unless he has admin access.
So, if something does not quite work, it can usually easily be "fixed" by using Standard Unix tools (grep/sed/awk/vi etc.) in a sledgehammer way without having to understand the buildsystem.
Have you ever digged through your cmake build directory to find out what is wrong? Compared to the simple shellscript which can be read from top to bottom, following the generated Cmake files to find out what is going on is quite difficult. ALso, with CMake, adapting the FindFoo.cmake files requires not only knowledge of the CMake language, but also might require superuser privileges.
Upvotes: 10
Reputation: 2596
In truth, Autotools' only real 'saving grace' is that it is what all the GNU projects are largely using.
Issues with Autotools:
It works...most of the time...is all you can say about Autotools. It's a system that solves several problems that only really concerns the GNU project...for their base, core toolchain code. (Edit (05/24/2014): It should be noted that this type of concern is a potentially BAD thing to be worrying about- Heartbleed partially stemmed from this thinking and with correct, modern systems, you really don't have any business dealing with much of what Autotools corrects for. GNU probably needs to do a cruft removal of the codebase, in light of what happened with Heartbleed) You can use it to do your project and it might work nicely for a smallish project that you don't expect to work anywhere except Linux or where the GNU toolchain is clearly working correctly on. The statement that it "integrates nicely with Linux" is quite the bold statement and quite incorrect. It integrates with the GNU toolsuite reasonably well and solves problems that IT has with it's goals.
This is not to say that there's no problems with the other options discussed in the thread here.
SCons is more of a replacement for Make/GMake/etc. and looks pretty nice, all things considered However...
The examples given for CMake in this thread are a bit bogus.
However...
In truth, your goals should dictate what you choose here.
There is a reason many, many projects are ditching qmake, Autotools, etc. and moving over to CMake. So far, I can cleanly expect a CMake based project to either drop into a cross-compile situation or onto a VisualStudio setup or only need a small amount of clean up because the project didn't account for Windows-only or OSX-only parts to the codebase. I can't really expect that out of an SCons based project- and I fully expect 1/3rd or more Autotools projects to have gotten SOMETHING wrong that precludes it building right on any context except the host building one or a Scratchbox2 one.
Upvotes: 230
Reputation: 212248
An important distinction must be made between who uses the tools. Cmake is a tool that must be used by the user when building the software. The autotools are used to generate a distribution tarball that can be used to build the software using only the standard tools available on any SuS compliant system. In other words, if you are installing software from a tarball that was built using the autotools, you are not using the autotools. On the other hand, if you are installing software that uses Cmake, then you are using Cmake and must have it installed to build the software.
The great majority of users do not need to have the autotools installed on their box. Historically, much confusion has been caused because many developers distribute malformed tarballs that force the user to run autoconf to regenerate the configure script, and this is a packaging error. More confusion has been caused by the fact that most major linux distributions install multiple versions of the autotools, when they should not be installing any of them by default. Even more confusion is caused by developers attempting to use a version control system (eg cvs, git, svn) to distribute their software rather than building tarballs.
Upvotes: 86
Reputation: 4444
It's not about GNU coding standards.
The current benefits of autotools — specifically when used with automake — is that they integrate very well with building Linux distribution.
With cmake for example, it's always "was it -DCMAKE_CFLAGS or -DCMAKE_C_FLAGS that I need?" No, it's neither, it's "-DCMAKE_C_FLAGS_RELEASE". Or -DCMAKE_C_FLAGS_DEBUG. It's confusing - in autoconf, it's just ./configure CFLAGS="-O0 -ggdb3" and you have it.
In integration with build infrastructures, scons has the problem that you cannot use make %{?_smp_mflags}
, _smp_mflags
in this case being an RPM macro that roughly expands to (admin may set it) system power. People put things like -jNCPUS here through their environment. With scons that's not working, so the packages using scons may only get serialed built in distros.
Upvotes: 30
Reputation: 57870
What is important to know about the Autotools is that they are not a general build system - they implement the GNU coding standards and nothing else. If you want to make a package that follows all the GNU standards, then Autotools are an excellent tool for the job. If you don't, then you should use Scons or CMake. (For example, see this question.) This common misunderstanding is where most of the frustration with Autotools comes from.
Upvotes: 18