介绍qmake2cmake
Introducing qmake2cmake介绍qmake2cmakeWednesday April 13, 2022 byJörg Bornemann|Comments2022年4月13日星期三 Jörg Bornemann | 评论Qt's own QMake project files have been converted with a Python script namedpro2c
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。

GitCode 天启AI是一款由 GitCode 团队打造的智能助手,基于先进的LLM(大语言模型)与多智能体 Agent 技术构建,致力于为用户提供高效、智能、多模态的创作与开发支持。它不仅支持自然语言对话,还具备处理文件、生成 PPT、撰写分析报告、开发 Web 应用等多项能力,真正做到“一句话,让 Al帮你完成复杂任务”。
更多推荐
所有评论(0)