Introducing qmake2cmake

Qt's own QMake project files have been converted with a Python script named pro2cmake that lives in qtbase. This script is specially tailored for converting the projects in Qt repositories and is little useful for converting user projects.

We have forked this script and turned it into a converter for your projects: Say hello to qmake2cmake!

What does it do?

The qmake2cmake tool creates a CMakeLists.txt that covers the most common attributes of the converted .pro file. The generated CMake project can be used as baseline and will most likely need manual adjustments.

QMake constructs that cannot be converted end up in the CMake project as comment. These comments are helpful when converting these bits manually.

Many projects have more than just one .pro file. For QMake SUBDIRS hierarchies, there's qmake2cmake_all which operates on a project's root directory and converts everything below it.

For Qt itself, conversion speed was a non-negligible aspect. That's why qmake2cmake_all parallelizes the conversion of subprojects.

What it does not

There are some QMake constructs that are not converted:

  • TEMPLATE = aux projects
  • custom .prf files
  • extra compilers
  • extra targets

All these will need to be manually converted.

Where do I get it?

Installation of qmake2cmake is as simple as

python -m pip install qmake2cmake

If you want the source code, clone the repository:

git clone git://

Refer to for requirements and further installation details.

How to use it?

To convert a whole project tree, pass the project directory to qmake2cmake_all:
qmake2cmake_all ~/projects/myapp --min-qt-version 6.3

It is necessary to specify the lowest Qt version the project will be built against. This selects the right CMake API for the Qt version.

To avoid passing this parameter to every call, you can set the QMAKE2CMAKE_MIN_QT_VERSION environment variable.

The following call converts a single QMake project file to CMake:
qmake2cmake ~/projects/myapp/

By default, a CMakeLists.txt is placed next to the .pro file.
To generate CMakeLists.txt in a different location, use the -o option:
qmake2cmake ~/projects/myapp/ -o ~/projects/myapp-converted/CMakeLists.txt

How does it look like?

The following code snippet shows the result of converting the gui/analogclock example to CMake with the minimum Qt version 6.3:

cmake_minimum_required(VERSION 3.16) 
project(analogclock VERSION 1.0 LANGUAGES CXX)




qt_add_executable(analogclock WIN32 MACOSX_BUNDLE
   ../rasterwindow/rasterwindow.cpp ../rasterwindow/rasterwindow.h
target_include_directories(analogclock PRIVATE

target_link_libraries(analogclock PRIVATE

install(TARGETS analogclock

   TARGET analogclock
   FILENAME_VARIABLE deploy_script
install(SCRIPT ${deploy_script}


The qmake2cmake tool is hosted at the Qt project, and the usual contribution rules apply.

Please report bugs at using the project "Qt (QTBUG)" and the component "Build Tools: other".


Blog Topics: