q2c is a command-line converter between Qt qmake projects and CMake projects.
It can convert common .pro / .pri projects to CMakeLists.txt, and it can
convert common Qt CMake projects back to qmake .pro files.
The project is still under active development. q2c prefers readable generated build files and explicit warnings over pretending every qmake or CMake scripting feature can be converted perfectly.
- Qt 5 or Qt 6 development tools
- A C++17 compiler
- Either CMake 3.16+ or qmake
Using CMake:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build buildIf Qt is not in CMake's default search path, pass its prefix:
cmake -S . -B build -DCMAKE_PREFIX_PATH=/path/to/Qt/6.x/gcc_64Using qmake:
mkdir -p release
cd release
qmake ../q2c/q2c.pro
makeUsing CMake:
cmake -S . -B build -DQ2C_BUILD_TESTS=ON
cmake --build build
ctest --test-dir build --output-on-failureUsing qmake:
mkdir -p tests/build
cd tests/build
qmake ../tests.pro
make
./q2c_testsCLI smoke tests:
tests/run_cli_tests.sh build/q2cInstall from a CMake build:
cmake --install buildCreate release archives:
scripts/make_release.shThe CMake build uses CPack to create .tar.gz and .zip archives on every
platform, and DEB/RPM packages on Linux where the tools are available.
q2c detects the conversion direction from the input file name:
.proand.prifiles are treated as qmake input and converted to CMake.CMakeLists.txtand.cmakefiles are treated as CMake input and converted to qmake.
Examples:
q2c -i app.pro -o CMakeLists.txt
q2c --qmake-to-cmake --qt6 -i app.pro -o CMakeLists.txt
q2c --cmake-to-qmake -i CMakeLists.txt -o app.pro
q2c --check -i app.pro
q2c --check --strict -i app.pro
q2c --dry-run -i app.pro
q2c --backup --force -i app.pro -o CMakeLists.txt
q2c --output-dir converted -i app.proExisting output files are not overwritten unless -f or --force is used.
Useful options:
--qmake-to-cmake Force qmake input to CMake output
--cmake-to-qmake Force CMake input to qmake output
--qt4, --qt5, --qt6 Select Qt generation style for qmake-to-CMake
--check Parse and validate only
--dry-run Print generated output to stdout
--force Overwrite an existing output file
--backup Back up an existing output file before overwriting
--output-dir DIR Write generated output into DIR
--strict Fail when conversion warnings are emitted
--warnings FORMAT Warning output format: text or json
--version Print the q2c version
q2c supports a practical static subset of qmake and CMake. It handles typical Qt applications, libraries, resources, forms, translations, include paths, defines, libraries, compiler/linker flags, subdirs, and simple platform scopes.
It does not execute arbitrary CMake or qmake scripts. Unsupported constructs are reported as warnings when possible so the generated file can be reviewed.