如何通过 QMake .pro makefile 将标志添加到 RC.EXE

发布于 2024-08-30 19:21:47 字数 746 浏览 4 评论 0原文

我的 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

删除→记忆 2024-09-06 19:21:47

它有点 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 as rc /i<directory> <any-other-rc-flags>". It would be better if QMAKE supports something like QMAKE_RC_FLAGS but it doesn't.

脸赞 2024-09-06 19:21:47

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")

記柔刀 2024-09-06 19:21:47

我不知道你是否注意到,@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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文