@@ -303,15 +303,19 @@ namespace
303303 return true ;
304304 }
305305
306- unsigned int getQtVersion (const QStringList& includePaths )
306+ unsigned int getQtVersion (const QStringList& paths )
307307 {
308308 QRegularExpression re (" #define\\ s+QTCORE_VERSION\\ s+0x([0-9a-f]+)" , QRegularExpression::CaseInsensitiveOption);
309- for (const QString &includeDir: includePaths )
309+ for (const QString &path: paths )
310310 {
311- QFileInfo fi (QDir (includeDir), " qtcoreversion.h" );
312- if (fi.exists ())
311+ #ifdef Q_OS_MACOS
312+ QString qtCoreVersionHeader = joinPath (path, " Versions/A/Headers/qtcoreversion.h" );
313+ #else
314+ QString qtCoreVersionHeader = joinPath (path, " qtcoreversion.h" );
315+ #endif
316+ if (QFile::exists (qtCoreVersionHeader))
313317 {
314- QString filePath = fi .absoluteFilePath ();
318+ QString filePath = QFileInfo (qtCoreVersionHeader) .absoluteFilePath ();
315319 QFile f (filePath);
316320 if (f.open (QIODevice::ReadOnly))
317321 {
@@ -335,7 +339,7 @@ namespace
335339 }
336340 }
337341 printf (" Error: Could not find Qt version (looked for qtcoreversion.h in %s)\n " ,
338- qPrintable (includePaths .join (QDir::listSeparator ())));
342+ qPrintable (paths .join (QDir::listSeparator ())));
339343 return 0 ;
340344 }
341345};
@@ -440,17 +444,29 @@ int main(int argc, char *argv[])
440444 printf (" Please wait while source files are being generated...\n " );
441445
442446 QStringList includePaths = getIncludeDirectories (args.value (" include-paths" ));
443- if (!qtVersion) {
444- printf (" Trying to determine Qt version...\n " );
445- qtVersion = getQtVersion (includePaths);
446- if (!qtVersion)
447- {
448- fprintf (stderr, " Aborting\n " ); // the error message was printed by getQtVersion
449- return 1 ;
450- }
451- printf (" Determined Qt version is %d.%d.%d\n " , qtVersion >> 16 , (qtVersion >> 8 ) & 0xFF , qtVersion & 0xFF );
447+ if (!qtVersion && !includePaths.empty ()) {
448+ printf (" Trying to determine Qt version...\n " );
449+ qtVersion = getQtVersion (includePaths);
452450 }
451+ #ifdef Q_OS_MACOS
453452 QStringList frameworkPaths = getFrameworkDirectories (args.value (" framework-paths" ));
453+ if (!qtVersion && !frameworkPaths.empty ()) {
454+ printf (" Trying to determine Qt version...\n " );
455+ qtVersion = getQtVersion (frameworkPaths);
456+ }
457+ if (!qtVersion) {
458+ fprintf (stderr, " Aborting. Could not determine Qt version from include or framework paths.\n " );
459+ return 1 ;
460+ }
461+ #else
462+ Q_UNUSED (getFrameworkDirectories);
463+ QStringList frameworkPaths;
464+ if (!qtVersion) {
465+ fprintf (stderr, " Aborting. Could not determine Qt version from include paths.\n " );
466+ return 1 ;
467+ }
468+ #endif
469+ printf (" Determined Qt version is %d.%d.%d\n " , qtVersion >> 16 , (qtVersion >> 8 ) & 0xFF , qtVersion & 0xFF );
454470
455471 printf (" Parsing typesystem file [%s]\n " , qPrintable (typesystemFileName));
456472 fflush (stdout);
0 commit comments