support include paths for the Windows resource compiler
authorJoerg Bornemann <joerg.bornemann@digia.com>
Thu, 6 Dec 2012 15:29:30 +0000 (16:29 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 10 Dec 2012 09:17:25 +0000 (10:17 +0100)
In RC_INCLUDEPATH one can add include paths for the Windows resource
compiler.

Task-number: QTBUG-13776

Change-Id: If1d9ed44097adb7789df03e4ccd4e3b7df9e8d08
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
qmake/generators/win32/mingw_make.cpp
qmake/generators/win32/msvc_vcproj.cpp
qmake/generators/win32/winmakefile.cpp

index 234817b..1665e23 100644 (file)
@@ -416,14 +416,23 @@ void MingwMakefileGenerator::writeRcFilePart(QTextStream &t)
 {
     const QString rc_file = fileFixify(project->first("RC_FILE").toQString());
 
-    QString incPathStr = fileInfo(rc_file).path();
-    if (incPathStr != "." && QDir::isRelativePath(incPathStr))
-        incPathStr.prepend("./");
+    ProStringList rcIncPaths = project->values("RC_INCLUDEPATH");
+    rcIncPaths.prepend(fileInfo(rc_file).path());
+    QString incPathStr;
+    for (int i = 0; i < rcIncPaths.count(); ++i) {
+        const ProString &path = rcIncPaths.at(i);
+        if (path.isEmpty())
+            continue;
+        incPathStr += QStringLiteral(" --include-dir=");
+        if (path != "." && QDir::isRelativePath(path.toQString()))
+            incPathStr += "./";
+        incPathStr += escapeFilePath(path);
+    }
 
     if (!rc_file.isEmpty()) {
         t << escapeDependencyPath(var("RES_FILE")) << ": " << rc_file << "\n\t"
           << var("QMAKE_RC") << " -i " << rc_file << " -o " << var("RES_FILE") 
-          << " --include-dir=" << incPathStr << " $(DEFINES)" << endl << endl;
+          << incPathStr << " $(DEFINES)" << endl << endl;
     }
 }
 
index 1e3f66a..9f14b61 100644 (file)
@@ -1072,6 +1072,17 @@ void VcprojGenerator::initResourceTool()
     VCConfiguration &conf = vcProject.Configuration;
     conf.resource.PreprocessorDefinitions = conf.compiler.PreprocessorDefinitions;
 
+    foreach (const ProString &path, project->values("RC_INCLUDEPATH")) {
+        QString fixedPath = fileFixify(path.toQString());
+        if (fileInfo(fixedPath).isRelative()) {
+            if (fixedPath == QStringLiteral("."))
+                fixedPath = QStringLiteral("$(ProjectDir)");
+            else
+                fixedPath.prepend(QStringLiteral("$(ProjectDir)\\"));
+        }
+        conf.resource.AdditionalIncludeDirectories << escapeFilePath(fixedPath);
+    }
+
     // We need to add _DEBUG for the debug version of the project, since the normal compiler defines
     // do not contain it. (The compiler defines this symbol automatically, which is wy we don't need
     // to add it for the compiler) However, the resource tool does not do this.
index fcc9ceb..fc98c3d 100644 (file)
@@ -783,8 +783,20 @@ void Win32MakefileGenerator::writeRcFilePart(QTextStream &t)
         // 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;
+        for (int i = 0; i < rcIncPaths.count(); ++i) {
+            const ProString &path = rcIncPaths.at(i);
+            if (path.isEmpty())
+                continue;
+            incPathStr += QStringLiteral(" /i ");
+            incPathStr += escapeFilePath(path);
+        }
+
         t << res_file << ": " << rc_file << "\n\t"
-          << var("QMAKE_RC") << (project->isActiveConfig("debug") ? " -D_DEBUG" : "") << " $(DEFINES) -fo " << res_file << " " << rc_file;
+          << var("QMAKE_RC") << (project->isActiveConfig("debug") ? " -D_DEBUG" : "")
+          << " $(DEFINES)" << incPathStr << " -fo " << res_file << " " << rc_file;
         t << endl << endl;
     }
 }