如何通过 QMake .pro makefile 将标志添加到 RC.EXE
我的 .pro 文件中有以下定义:
RC_FILE = app.rc
该 RC 文件顶部包含一个全局包含:
#include "version_info.h"
version_info.h 标头位于公共头文件目录中。
由于 RC.EXE 考虑了 INCLUDE 环境变量,根据 MS 文档,我的构建过程批处理相应地进行了设置:
SET INCLUDE=%PROJECTDIR%\version;%INCLUDE%
...
QMAKE project.pro -spec win32-msvc2008 -r CONFIG += release
这非常有效,因为 RC 似乎读取了 INCLUDE var,因此“version_info.h”文件包含在每个 RC 文件中适当地。
问题是当我生成 VS 解决方案(或通过 VS Addin 导入它)时。 RC 调用不包含任何 /I 标志(如我所料),但不读取任何 INCLUDE 变量,即使我通过 XP 中的系统“环境变量”对话框进行设置也是如此。
所以我陷入了这个问题,有两种选择我无法开始工作:
- 使 VS RC.exe 调用尊重 INCLUDE 变量(不能作为用户或系统变量工作)。
- 强制 QMAKE 将 /I 标志传递给 RC 调用,并将 /I 标志导入到项目设置(资源编译器属性)中。
提前致谢。
I've the following definition in my .pro file:
RC_FILE = app.rc
This RC file contains a global include at the top:
#include "version_info.h"
The version_info.h header is on a common header files directory.
Since RC.EXE takes INCLUDE environment variable in consideration, according to MS documentation, my build process batch sets up that accordingly:
SET INCLUDE=%PROJECTDIR%\version;%INCLUDE%
...
QMAKE project.pro -spec win32-msvc2008 -r CONFIG += release
This works perfect as RC seems to read that INCLUDE var so the "version_info.h" file is including on every RC file properly.
The problem is when I generate a VS solution (or Import it through the VS Addin). The RC invocation does not contain any /I flag (as I expect) but does not read any INCLUDE variable, even when I've setup through system 'environment variables' dialog in XP.
So I'm stuck with this problem, with two alternatives I could not get to work:
- Make VS RC.exe invocation honour the INCLUDE variable (didn't work either as user or system variable).
- Force QMAKE to pass /I flag to RC invocation, and get that /I flag imported into the project settings (Resource Compiler properties).
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它有点 hacky,但工作正常:在 .pro 文件中使用 QMAKE_RC qmake 变量(或通过 qmake 的参数)。默认情况下,它定义为
rc
但您可以将其设置为rc /i;”。如果 QMAKE 支持 QMAKE_RC_FLAGS 之类的东西那就更好了,但它不支持。
It is a bit hacky but works fine: use the QMAKE_RC qmake variable in your .pro file (or via arguments for qmake). By default it is defined as
rc
but you can set it asrc /i<directory> <any-other-rc-flags>
". It would be better if QMAKE supports something like QMAKE_RC_FLAGS but it doesn't.在 Qt bugtracker 中打开一个错误,
直到它解决为止,您有以下解决方案:
- 破解生成的解决方案文件(有关详细信息,请参阅错误报告)
- 显式包含带有路径的头文件,而不依赖于 INCLUDEPATH(例如#include "../../version.h")
A bug is opened in Qt bugtracker
Until it solves, you have the following solutions:
- hack the generated solution file (see the bug report for details)
- explictely include the header file with path, without relying on INCLUDEPATH (e.g. #include "../../version.h")
我不知道你是否注意到,@Bruce 提到的 bugtracker bug 已从 5.0.0 RC2 开始关闭: https://codereview.qt-project.org/#change,41984
您需要使用的变量是
RC_INCLUDEPATH
。I don't know if you noticed, but the bugtracker bug @Bruce mentioned has been closed as of 5.0.0 RC2: https://codereview.qt-project.org/#change,41984
The variable you need to use is
RC_INCLUDEPATH
.