QMake2CMake
qmake2cmake helper script to move qmake Qt5 based project to modern cmake > 3.0
Install / Use
/learn @davidtazy/QMake2CMakeREADME
QMakeToCMake

Helper script to move qmake (Qt5) based subdirs/project to cmake
Warning: its not bullet proof, main goal is too speed up manual operation
will be usefull if lots of pro file to convert
Features:
-
TEMPLATE=subdirs, you may need to re-order add_subdirectoies lines
-
TEMPLATE=app
-
TEMPLATE=lib
-
TARGET will name the target
-
QT, will add find-packages, target_link_libraries for defined modules
-
CMAKE_AUTO_RCC if qrc file defined
-
CMAKE_AUTO_uic if .ui files defined
-
CMAKE_AUTO_MOC if depends on Qt5Core
-
if CONFIG contains c++11, wil add magic lines to enable it on CMakeLists.txt
-
CONFIG-=qt , no Qt dependencies
-
DEFINES
-
INCLUDEPATH
-
CONFIG values and custom variable can define new lines on cmakelist.txt with a json config file (see example/config.json)
Examples
libToto.pro:
TEMPLATE=lib
QT += core gui
CONFIG+=c++11
TARGET=Toto
SOURCES=aaa.cpp\
bbb.cpp\
ccc.cpp
HEADERS=aaa.h\
bbb.h\
ccc.h
FORMS=a.ui
RESOURCES=r.qrc
CMakeLists.txt
make_minimum_required(VERSION 3.0.0 )
project(libToto)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
find_package(Qt5Core)
find_package(Qt5Gui)
set(src a.cpp
b.cpp
c.cpp)
set(headers a.h
b.h
c.h)
set(resources r.qrc)
set(forms a.ui)
add_library(Toto ${src} ${headers} ${resources} ${forms})
target_link_libraries(Toto PRIVATE Qt5::Core Qt5::Gui)
set_target_properties(Toto PROPERTIES DEBUG_POSTFIX "d")
install(TARGETS Toto DESTINATION Libs)
Limitations
q2c does not read correctly conditionnal blocks:
CONTAINS(CONFIG,featureXXX): QT+= printsupport
will be omited during parse
CONTAINS(CONFIG,featureXXX){
blockIf
}else{
blockElse
}
blockIf AND blockElse will be parsed
Usage:
download or clone
cd to QMakeToCMake
pip install .
# will install commandline app named 'q2c'
usage: q2c [-h] [-n] [-r] [-s] [-c] path
positional arguments:
path directory or file
optional arguments:
-h, --help show this help message and exit
-n, --dry-run print conversion on the console
-r, --recursive all .pro in directory tree
-s, --show show result file(s) , use it with recursive option to survey operations
-s, --config json file defining dictionnary between CONFIG values in .pro file and cmake function
Related Skills
node-connect
343.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
90.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
