3

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.

Hernán
  • 4,527
  • 2
  • 32
  • 47

3 Answers3

2

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.

pobedim
  • 491
  • 2
  • 5
1

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.

Kyle Strand
  • 15,941
  • 8
  • 72
  • 167
  • RC_INCLUDEPATH indeed exists and [documented](http://doc.qt.io/qt-5/qmake-variable-reference.html#rc-includepath) but it produces space beetween `/i` and `c:\source\stuff` and results in `RC2135: file not found: my_icon.ico` error. Do you know if this bug is reported somewhere? The `QMAKE_RC` hack works – mvidelgauz Nov 21 '16 at 17:30
  • @mvidelgauz Sorry, all my knowledge about QMake files comes from a project several years ago to auto-generate them that was abandoned pretty quickly. I do not know if that bug is reported. – Kyle Strand Nov 21 '16 at 18:07
1

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
  • 7,094
  • 1
  • 25
  • 42