如何在 QMake .pro 文件中指定不同的调试/发布输出目录 [英] How to specify different Debug/Release output directories in QMake .pro file
问题描述
我有一个 Qt 项目,我想在源代码树之外输出编译文件.
我目前的目录结构如下:
<预><代码>/|_/构建|_/mylib|_/包括|_/源|_/资源根据配置(调试/发布),我想在 build/debug 或 build/release 目录下的 build 目录中输出结果文件.
我如何使用 .pro 文件做到这一点?
简短的回答是:你没有.
您应该在要构建的任何构建目录中运行 qmake
后跟 make
.因此,在 debug
目录中运行一次, 一次在 release
目录中.
这就是任何构建您的项目的人都希望它能够工作的方式,这就是 Qt 本身的构建方式,这也是 Qt Creator 期望您的 .pro
文件的行为方式:它只是启动 qmake
然后 make
在目标选择的配置的构建文件夹中.
如果您希望创建这些文件夹并在其中执行两个(或多个)构建,您需要一个顶级 makefile,可能是通过 qmake 从顶级项目文件创建的.
拥有两个以上构建配置的情况并不少见,因此您不必要地承诺只区分构建和发布;您可能有不同优化级别的构建,等等.最好让调试/发布二分法保持平静.
I have a Qt project and I would like to output compilation files outside the source tree.
I currently have the following directory structure:
/
|_/build
|_/mylib
|_/include
|_/src
|_/resources
Depending on the configuration (debug/release), I will like to output the resulting files inside the build directory under build/debug or build/release directories.
How can I do that using a .pro file?
The short answer is: you don't.
You should run qmake
followed by make
in whatever build directory you want to build in. So, run it once in a debug
directory, once in a release
directory.
That's how anyone building your project would expect it to work, and that's how Qt itself is set up to build, that's also how Qt Creator expects your .pro
file to behave: it simply starts qmake
and then make
in the build folder for your target's chosen configuration.
If you wish to create these folders and perform the two (or more) builds in them, you'll need a top-level makefile, possibly created from a top-level project file via qmake.
It's not uncommon to have more than two build configurations, so you're unnecessarily committing yourself to only differentiating between a build and a release; you might have builds with different optimization levels, etc. The debug/release dichotomy is best left to rest in peace.
这篇关于如何在 QMake .pro 文件中指定不同的调试/发布输出目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!