Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are CMake vs qmake pros and cons?

Tags:

cmake

qt

qmake

I would like to know reasons for use CMake for particular project over qmake and vice versa.

Simply what are the pros and cons of both build systems?

like image 840
Hareen Laks Avatar asked Dec 19 '15 11:12

Hareen Laks


People also ask

Is CMake better than qmake?

Both are build systems, but they're not very similar at all. If your project uses Qt, you're probably best off using qmake. CMake is more generic, and fits pretty much any type of project. Both qmake and CMake generate a Makefile, which is read by make to build the project.

What is CMake and qmake in Qt?

CMake is an alternative to qmake for automating the generation of build configurations. Setting Up Qbs. Qbs is an all-in-one build tool that generates a build graph from a high-level project description (like qmake or CMake do) and executes the commands in the low-level build graph (like make does).

Is qmake deprecated?

In recent months Qbs for Qt 6 began looking less certain and now The Qt Company has announced they are going to deprecate Qbs. From talking with their customers, they decided to focus on QMake and CMake. Qbs will continue to be supported until the end of 2019 while the last release will come out in April.

What is qmake used for?

The qmake tool helps simplify the build process for development projects across different platforms. It automates the generation of Makefiles so that only a few lines of information are needed to create each Makefile. You can use qmake for any software project, whether it is written with Qt or not.


1 Answers

Both are build systems, but they're not very similar at all. If your project uses Qt, you're probably best off using qmake. CMake is more generic, and fits pretty much any type of project.

Both qmake and CMake generate a Makefile, which is read by make to build the project. Not all build systems generate a Makefile, but many do. Even a Makefile is a type of build system; it tells the compiler and linker what to do, in order to create an executable (or a dynamic or static library).


If your project uses Qt, but you don't want to use qmake, you'll have to do a few more things yourself:

  • running the Meta Object Compiler (MOC)
  • include paths (tell the compiler where to look for Qt headers)
  • linking (tell the linker where to look for Qt libraries)

So, you'll have to do a bit more work to build a Qt project without qmake, but it is possible and it will teach you a lot about how Qt and qmake do things.

On a personal note (take this only as a recommendation, do further research yourself): I'm not a big fan of qmake. It helps you with the Qt stuff, but apart from that, I've found it to be pretty limited.


In any case, I would recommend learning to build a small project (~10 source files) without using any type of build system. Not using CMake, not with a Makefile, just using the compiler and linker directly. You shouldn't actually build any real project in this way, but you should learn how to do it, just to learn what build systems actually do. Knowing what they do will make them a lot easier to use.


A few months ago, we switched a project from qmake to Premake, which is also worth a look. It's highly scriptable (with Lua), which is great when you need to customize your build process.

That said, it is a bit more "manual", so prepare yourself to learn how compiling and linking works at a more basic level, without the use of a build system. It's also in beta (Premake 5), so there are some bits and pieces still missing.

You can also take a look at qbs, which is supposed to be a better qmake. It's still in a beta stage, so I'd wait while it matures and becomes easier to use.

like image 72
Kankaristo Avatar answered Sep 19 '22 05:09

Kankaristo