PDA

View Full Version : How to add a dependency to a windres-ressource (rc) file w/ mingw



franku
7th January 2011, 15:38
Hi, I am developing a windows application where I have the need of having a Program version included:


As Infowidget in the program itself (About..)
As Version information in the .exe binary when looking from the file explorer's view


At this point everthing is solved using a version.rc file that is compiled by the windres compiler. In this file included I have a version.h file that defines every version for my program. The advantage of this solution is to have only one file (the version.h) to be changed in my source code.



// version.h

#define STRFILEVER "0.1.0.6\0"
#define FILEVER 0,1,0,6




// version.rc

#include "version.h"
#include "icon.rc"

...

BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "FileDescription", "My Application\0"
VALUE "FileVersion", STRFILEVER
VALUE "LegalCopyright", "Copyright (c) 2010\0"
VALUE "OriginalFilename", "App.exe\0"
VALUE "ProductName", "MyApp\0"
END
END
...



Now to the question. qmake will not automatically set the version.h file as a dependency in the makefiles for the version.rc file so I will always have to tag version.rc manually.

Is there a way to tell qmake to reflect version.h in the dependencies of version.rc ? How can I add custom dependencies to a certain file that is no library but (in my case) a ressource file.

Any comments ?

sr2020
13th April 2015, 18:49
I know it's been a while, but I got almost the same problem. Did you find any solution or you just redesigned your code?
To clarify, I have version.h file that is being generated with

PRE_TARGETDEPS += version.h
and rc file that has version.h included in it

RC_FILE += resource.rc
The problem is when I am building the project using several cores it executes resource generation and version.h at the same time and sometimes the version file is not generated yet when winres tries to include it. I need to set up some kind of dependency so version.h would be generated before resource file.
Thanks.

franku
14th April 2015, 13:03
The following works with (and most likely with former versions as well):
QMake version 3.0
Using Qt version 5.1.1


#call the ressource compiler
win32:mkver_rc.target = version_res.o
win32:mkver_rc.depends = version.h
win32:mkver_rc.commands = windres -i version.rc -o version_res.o --include-dir=. -DVERSION_H_INTERN $(DEFINES)
win32:QMAKE_EXTRA_TARGETS += mkver_rc
win32:PRE_TARGETDEPS += version_res.o

LIBS += version_res.o

Please check if you should remove the two lines you mentioned above from your project file.