From d83bd9c6f5abd936b853029bf7030ebb4792f9fb Mon Sep 17 00:00:00 2001 From: "M. Moellney" Date: Wed, 27 May 2015 22:31:21 +0200 Subject: Introduce qmake RC_DEFINES for RC preprocessor defines qmake win32 generators by default used values of DEFINES for RC preprocessor defines, too. For simple defines this works. For string literals this failed for the .vcxproj files: DEFINES += "FOO=\"BAR BAR\"" works for CL but fails for RC. DEFINES += "FOO=\\\"BAR BAR\\\"" works for RC but fails for CL. This patch introduces the qmake variable RC_DEFINES. The variable contains the preprocessor defines, that are used for RC. If the varible is not set, the DEFINES values are used for RC. Task-number: QTBUG-44184 Change-Id: I4202271759d29de8c1829347ae3ef117eda54b38 Reviewed-by: Oswald Buddenhagen --- qmake/generators/win32/winmakefile.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'qmake/generators/win32/winmakefile.cpp') diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index 6ea129f82c..ab4f48685b 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp @@ -752,10 +752,6 @@ void Win32MakefileGenerator::writeRcFilePart(QTextStream &t) if(!project->values("RC_FILE").isEmpty()) { const ProString res_file = project->first("RES_FILE"); const QString rc_file = fileFixify(project->first("RC_FILE").toQString()); - // The resource tool needs to have the same defines passed in as the compiler, since you may - // use these defines in the .rc file itself. Also, we need to add the _DEBUG define manually - // since the compiler defines this symbol by itself, and we use it in the automatically - // created rc file when VERSION is define the .pro file. const ProStringList rcIncPaths = project->values("RC_INCLUDEPATH"); QString incPathStr; @@ -767,9 +763,20 @@ void Win32MakefileGenerator::writeRcFilePart(QTextStream &t) incPathStr += escapeFilePath(path); } + // The resource tool may use defines. This might be the same defines passed in as the + // compiler, since you may use these defines in the .rc file itself. + // As the escape syntax for the command line defines for RC is different from that for CL, + // we might have to set specific defines for RC. + ProString defines = varGlue("RC_DEFINES", " -D", " -D", ""); + if (defines.isEmpty()) + defines = ProString(" $(DEFINES)"); + + // Also, we need to add the _DEBUG define manually since the compiler defines this symbol + // by itself, and we use it in the automatically created rc file when VERSION is defined + // in the .pro file. t << escapeDependencyPath(res_file) << ": " << escapeDependencyPath(rc_file) << "\n\t" << var("QMAKE_RC") << (project->isActiveConfig("debug") ? " -D_DEBUG" : "") - << " $(DEFINES)" << incPathStr << " -fo " << escapeFilePath(res_file) + << defines << incPathStr << " -fo " << escapeFilePath(res_file) << ' ' << escapeFilePath(rc_file); t << endl << endl; } -- cgit v1.2.3