介绍qmake2cmake

Introducing qmake2cmake

介绍qmake2cmake

Wednesday April 13, 2022 by Jörg Bornemann | Comments

​2022年4月13日星期三 Jörg Bornemann | 评论

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.

​Qt自己的QMake项目文件已经用一个名为pro2cmake的Python脚本进行了转换,该脚本位于qtbase中。这个脚本是专门为转换Qt存储库中的项目而定制的,对于转换用户项目几乎没有用处。

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

​我们已经将这个脚本分叉,并将其转化为项目的转换器:向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.

qmake2cmake工具创建一个CmakeList.txt,它涵盖了已转换文件的最常见.pro文件属性。生成的CMake项目可以用作基线,很可能需要手动调整。

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

无法转换的QMake构造最终作为注释出现在CMake项目中。这些注释在手动转换这些位时很有用。

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.

许多项目不止一个.pro文件。对于QMake SUBDIRS层次结构,有qmake2cmake_all,它在项目的根目录上运行,并转换它下面的所有内容。

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

对于Qt本身来说,转换速度是一个不容忽视的方面。这就是为什么qmake2cmake_all会并行子项目的转换。

What it does not

它做不了什么

There are some QMake constructs that are not converted:

有些QMake构造未转换:

  • 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

qmake2cmake的安装非常简单

python -m pip install qmake2cmake

If you want the source code, clone the repository:

如果需要源代码,请克隆存储库:

git clone git://code.qt.io/qt/qmake2cmake.git

Refer to README.md for requirements and further installation details.

请参阅README.md了解要求和进一步的安装细节。

How to use it?

如何使用它?

To convert a whole project tree, pass the project directory to qmake2cmake_all:

要转换整个项目树,请将项目目录传递给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.

有必要指定项目将基于的最低Qt版本。这将为Qt版本选择正确的CMake API。

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

为了避免将此参数传递给每个调用,可以设置QMAKE2CMAKE_MIN_QT_VERSION环境变量。

The following call converts a single QMake project file to CMake:

以下调用将单个QMake项目文件转换为CMake:

qmake2cmake ~/projects/myapp/myapp.pro

By default, a CMakeLists.txt is placed next to the .pro file.

默认情况下,CMakeLists.txt放在.pro文件的目录。
To generate CMakeLists.txt in a different location, use the -o option:

默认情况下,CMakeLists.txt放在其他位置,可以使用-o 选项。

qmake2cmake ~/projects/myapp/myapp.pro -o ~/projects/myapp-converted/CMakeLists.txt

Contributing

贡献

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

​qmake2cmake工具托管在Qt项目中,通常的贡献规则适用。

Please report bugs at System Dashboard - Qt Bug Tracker using the project "Qt (QTBUG)" and the component "Build Tools: other".

​请使用项目“Qt(QTBUG)”和组件“Build Tools:other”在System Dashboard-Qt Bug Tracker报告Bug。

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值