QMake

QMake

QMake is a build system that generates Makefiles for GNU Make or project build files for Microsoft Visual Studio. It is part of the Qt software framework by Trolltech. While it is commonly used to construct Qt-based software, any project can benefit from it.

Try it now

What is Qmake?

QMake is a build system that generates Makefiles for GNU Make or project build files for Microsoft Visual Studio. It is part of the Qt software framework by Trolltech. While it is commonly used to construct Qt-based software, any project can benefit from it. 

 

QMake, and the Qt framework, follow a dual-licensing system, enabling open-source projects like the KDE Desktop for Linux and the Kdenlive video editor to use the GPL (GNU Public License). Commercial developers can purchase the Qt license, which provides QtCreator (click here for what is Qt Creator), a powerful development system, along with technical support and the option to release a project as a closed-source application.

How Does it Work?

QMake can either use an existing project file to generate a Makefile or can use manually specified parameters and lists of files on the command line to create a project file. If QMake generates a project file, then that project file can then be used by QMake to generate a Makefile for use with make.

History of QMake

QMake is part of the Qt software framework, and given the framework’s long history, it’s difficult to tell when QMake first appeared as a utility as part of the software. However, QMake documentation appears in 2005 in the Qt 3.3 documentation. 

 

The current stable version of QMake is released as part of Qt 6.1.

Try it now

Get Free License

Features and Advantages

QMake is an incredibly useful tool for generating Makefiles or Microsoft Visual Studio project files and provides a wealth of features to the developer. QMake supports variables, custom build logic, and multiple compilers. It also includes support for precompiled headers to speed build times. 

 

Perhaps QMake’s most remarkable feature is its extensive cross-platform support. The Qt framework supports Windows, Linux, macOS, Android, iOS, UWP (Universal Windows Platform), and WebAssembly.

What is the Difference Between CMake and QMake?

QMake is probably the best choice for developers writing applications that use the Qt software framework. The deep integration that QMake includes with the rest of the system is difficult to beat. QMake works well with QtCreator, so it’s an easy solution for Qt projects. 

 

CMake is a powerful build system that includes features that go beyond the scope of QMake and Qt. While it has a steeper learning curve, its advanced features, like support for building third-party libraries, allow you to go beyond QMake’s capabilities. You can use CMake to build Qt projects, so either works if you’re a Qt developer. 

 

If you’re looking for a simple build experience with QtCreator, you can’t go wrong with QMake. For more complex building tasks, CMake may be a better choice.

How to Download and Install QMake?

If you use Linux, QMake is likely part of your distribution’s packages. Since the versions can vary, use the following commands to search for the most recent version: 

 

Debian / Ubuntu: apt search qmake

RedHat Enterprise Linux / CentOS / Fedora: yum provides */bin/qmake* 

 

Install the version specified by the search results via apt or yum, depending on your system. 

 

For macOS, run: 

brew install qt

 

On Windows, you can download Qt from https://www.qt.io/download.

 

No matter your platform, it’s important to keep in mind that you can only use the open-source version unless you have purchased Qt.

 

You can also check out the Qt source from GitHub @ https://github.com/qt/qtbase.

QMake Examples

QMake is simple to use. You can either invoke it via QtCreator or via the command line. It uses project files (.pro) featuring a straightforward syntax. 

 

Here’s the simplest project file we can construct using a source file and header: 

HEADERS += example.h

SOURCES += example.cpp

TARGET = example 

 

If we name this file example.pro, we now have a project file we can use with QMake. To convert this (or any) project file to a Makefile compatible with GNU Make, run this command: 

qmake -o Makefile example.pro 

 

To generate Visual Studio project files, run this: 

qmake -tp vc example.pro 

 

Now run the make command on the generated file, and it should build your source.

QMake and Incredibuild

QMake is a powerful and flexible build system, but performance is not its primary focus. That’s where Incredibuild comes into your development workflow. Incredibuild virtually reproduces your build environment on remote machines, allowing you to compile your project with incredible speed. Incredibuild lets you utilize computing resources on your local network or in the cloud to reduce build times for your application drastically.

icon

Bottom Line

QMake, especially when paired with the excellent QtCreator IDE, provides a well-rounded set of functionality and a simple, user-editable project file syntax that lets you quickly wrap your head around the entire build process of your application.    Incredibuild expands on QMake’s features by dramatically increasing the performance of your build times. With Incredibuild, you can massively parallelize your software build process, giving your development workflow a turbocharged boost of productivity.

Start Free Trial

More Build systems