@@ -61,7 +61,7 @@ void displayHelp(GeneratorSet *generatorSet);
6161namespace
6262{
6363
64- QStringList getIncludeDirectories (const QString &commandLineIncludes)
64+ QStringList getIncludeDirectories (const QString &commandLineIncludes, const QString &qtIncludePrefix )
6565 {
6666 QStringList includes;
6767 includes << QString (" ." );
@@ -121,11 +121,20 @@ namespace
121121 includes << (qtdir + " /QtOpenGL" );
122122 includes << qtdir;
123123 }
124+ if (!qtIncludePrefix.isEmpty () && QFile::exists (qtIncludePrefix)) {
125+ std::cout << " qt include prefix: " << qtIncludePrefix.toLocal8Bit ().constData () << std::endl;
126+ includes << (qtIncludePrefix + " /QtXml" );
127+ includes << (qtIncludePrefix + " /QtNetwork" );
128+ includes << (qtIncludePrefix + " /QtCore" );
129+ includes << (qtIncludePrefix + " /QtGui" );
130+ includes << (qtIncludePrefix + " /QtOpenGL" );
131+ includes << qtIncludePrefix;
132+ }
124133 return includes;
125134 }
126135
127136 bool
128- preprocess (const QString &sourceFile, const QString &targetFile, const QString &commandLineIncludes = QString())
137+ preprocess (const QString &sourceFile, const QString &targetFile, const QString &commandLineIncludes = QString(), const QString &qtIncludPrefix = {} )
129138 {
130139 rpp::pp_environment env;
131140 rpp::pp preprocess (env);
@@ -146,7 +155,7 @@ namespace
146155 preprocess.operator ()(ba.constData (), ba.constData () + ba.size (), null_out);
147156
148157 foreach (QString
149- include, getIncludeDirectories (commandLineIncludes)) {
158+ include, getIncludeDirectories (commandLineIncludes, qtIncludPrefix )) {
150159 preprocess.push_include_path (QDir::toNativeSeparators (include).toStdString ());
151160 }
152161
@@ -177,10 +186,10 @@ namespace
177186 return true ;
178187 }
179188
180- unsigned int getQtVersion (const QString &commandLineIncludes)
189+ unsigned int getQtVersion (const QString &commandLineIncludes, const QString &qtIncludPrefix = {} )
181190 {
182191 QRegularExpression re (" #define\\ s+QTCORE_VERSION\\ s+0x([0-9a-f]+)" , QRegularExpression::CaseInsensitiveOption);
183- for (const QString &includeDir: getIncludeDirectories (commandLineIncludes))
192+ for (const QString &includeDir: getIncludeDirectories (commandLineIncludes, qtIncludPrefix ))
184193 {
185194 QFileInfo fi (QDir (includeDir), " qtcoreversion.h" );
186195 if (fi.exists ())
@@ -315,7 +324,7 @@ int main(int argc, char *argv[])
315324
316325 if (!qtVersion) {
317326 printf (" Trying to determine Qt version...\n " );
318- qtVersion = getQtVersion (args.value (" include-paths" ));
327+ qtVersion = getQtVersion (args.value (" include-paths" ), args. value ( " qt-include-prefix " ) );
319328 if (!qtVersion)
320329 {
321330 fprintf (stderr, " Aborting\n " ); // the error message was printed by getQtVersion
@@ -337,7 +346,7 @@ int main(int argc, char *argv[])
337346 printf (" PreProcessing - Generate [%s] using [%s] and include-paths [%s]\n " ,
338347 qPrintable (pp_file), qPrintable (fileName), qPrintable (args.value (" include-paths" )));
339348 ReportHandler::setContext (" Preprocess" );
340- if (!preprocess (fileName, pp_file, args.value (" include-paths" ))) {
349+ if (!preprocess (fileName, pp_file, args.value (" include-paths" ), args. value ( " qt-include-prefix " ) )) {
341350 fprintf (stderr, " Preprocessor failed on file: '%s'\n " , qPrintable (fileName));
342351 return 1 ;
343352 }
0 commit comments