Ahmed Adel
Ahmed Adel

Reputation: 331

What are the major differences between makefile and CMakeList

I've searched for the major differences between makefile and CMakeLists, but found weak differences such as CMake automates dependency resolution whereas Make is manual.

I'm seeking major differences, what are some pros and cons of me migrating to CMake?

Upvotes: 5

Views: 6717

Answers (1)

Cristian Bidea
Cristian Bidea

Reputation: 709

You can compare CMake with Autotools. It makes more sense! If you do this then you can find out the shortcomings of make that form the reason for the creation of Autotools and the obvious advantages of CMake over make.

Autoconf solves an important problem—reliable discovery of system-specific build and runtime information—but this is only one piece of the puzzle for the development of portable software. To this end, the GNU project has developed a suite of integrated utilities to finish the job Autoconf started: the GNU build system, whose most important components are Autoconf, Automake, and Libtool.

Make can't do that. Not out of the box anyway. You can make it do it but it would take a lot of time maintaining it across platforms.

CMake solves the same problem (and more) but has a few advantages over GNU Build System.

  1. The language used to write CMakeLists.txt files is readable and easier to understand.
  2. It doesn't only rely on make to build the project. It supports multiple generators like Visual Studio, Xcode, Eclipse etc.

When comparing CMake with make there are several more advantages of using CMake:

  1. Cross platform discovery of system libraries.
  2. Automatic discovery and configuration of the toolchain.
  3. Easier to compile your files into a shared library in a platform agnostic way, and in general easier to use than make.

Overall CMake is clearly the choice when compared to make but you should be aware of a few things.

  • CMake does more than just make so it can be more complex. In the long run it pays to learn how to use it but if you have just a small project on only one platform, then maybe make can do a better job.
  • The documentation of CMake can seem terse at first. There are tutorials out there but there are a lot of aspects to cover and they don't do a really good job at covering it all. So you'll find only introductory stuff mostly. You'll have to figure out the rest from the documentation and real life examples: there are a lot of open source projects using CMake, so you can study them.

Upvotes: 12

Related Questions