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 <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
parent
e1b366a89c
commit
d83bd9c6f5
@ -987,3 +987,8 @@ QMAKE_SONAME_PREFIX = /Library/Frameworks
|
||||
#! [185]
|
||||
VERSION_PE_HEADER = 1.2
|
||||
#! [185]
|
||||
|
||||
#! [186]
|
||||
RC_DEFINES += USE_MY_STUFF
|
||||
#! [186]
|
||||
|
||||
|
@ -2314,6 +2314,14 @@
|
||||
.rc file. This is only utilized if the \l{VERSION} or \l{RC_ICONS} variable
|
||||
is set and the \l{RC_FILE} and \l{RES_FILE} variables are not set.
|
||||
|
||||
\target RC_DEFINES
|
||||
\section1 RC_DEFINES
|
||||
|
||||
Windows only. qmake adds the values of this variable as RC preprocessor macros
|
||||
(/d option). If this variable is not set, the \l{DEFINES} variable is used instead.
|
||||
|
||||
\snippet code/doc_src_qmake-manual.pro 186
|
||||
|
||||
\target RC_ICONS
|
||||
\section1 RC_ICONS
|
||||
|
||||
|
@ -405,9 +405,14 @@ void MingwMakefileGenerator::writeRcFilePart(QTextStream &t)
|
||||
}
|
||||
|
||||
if (!rc_file.isEmpty()) {
|
||||
|
||||
ProString defines = varGlue("RC_DEFINES", " -D", " -D", "");
|
||||
if (defines.isEmpty())
|
||||
defines = ProString(" $(DEFINES)");
|
||||
|
||||
t << escapeDependencyPath(var("RES_FILE")) << ": " << escapeDependencyPath(rc_file) << "\n\t"
|
||||
<< var("QMAKE_RC") << " -i " << escapeFilePath(rc_file) << " -o " << fileVar("RES_FILE")
|
||||
<< incPathStr << " $(DEFINES)\n\n";
|
||||
<< incPathStr << defines << "\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1213,7 +1213,12 @@ void VcprojGenerator::initLinkerTool()
|
||||
void VcprojGenerator::initResourceTool()
|
||||
{
|
||||
VCConfiguration &conf = vcProject.Configuration;
|
||||
conf.resource.PreprocessorDefinitions = conf.compiler.PreprocessorDefinitions;
|
||||
|
||||
ProStringList rcDefines = project->values("RC_DEFINES");
|
||||
if (rcDefines.size() > 0)
|
||||
conf.resource.PreprocessorDefinitions = rcDefines.toQStringList();
|
||||
else
|
||||
conf.resource.PreprocessorDefinitions = conf.compiler.PreprocessorDefinitions;
|
||||
|
||||
foreach (const ProString &path, project->values("RC_INCLUDEPATH")) {
|
||||
QString fixedPath = fileFixify(path.toQString());
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user