@@ -298,15 +298,19 @@ namespace
298298 return true ;
299299 }
300300
301- unsigned int getQtVersion (const QStringList& includePaths )
301+ unsigned int getQtVersion (const QStringList& paths )
302302 {
303303 QRegularExpression re (" #define\\ s+QTCORE_VERSION\\ s+0x([0-9a-f]+)" , QRegularExpression::CaseInsensitiveOption);
304- for (const QString &includeDir: includePaths )
304+ for (const QString &path: paths )
305305 {
306- QFileInfo fi (QDir (includeDir), " qtcoreversion.h" );
307- if (fi.exists ())
306+ #ifdef Q_OS_MACOS
307+ QString qtCoreVersionHeader = joinPath (path, " Versions/A/Headers/qtcoreversion.h" );
308+ #else
309+ QString qtCoreVersionHeader = joinPath (path, " qtcoreversion.h" );
310+ #endif
311+ if (QFile::exists (qtCoreVersionHeader))
308312 {
309- QString filePath = fi .absoluteFilePath ();
313+ QString filePath = QFileInfo (qtCoreVersionHeader) .absoluteFilePath ();
310314 QFile f (filePath);
311315 if (f.open (QIODevice::ReadOnly))
312316 {
@@ -330,7 +334,7 @@ namespace
330334 }
331335 }
332336 printf (" Error: Could not find Qt version (looked for qtcoreversion.h in %s)\n " ,
333- qPrintable (includePaths .join (QDir::listSeparator ())));
337+ qPrintable (paths .join (QDir::listSeparator ())));
334338 return 0 ;
335339 }
336340};
@@ -435,17 +439,28 @@ int main(int argc, char *argv[])
435439 printf (" Please wait while source files are being generated...\n " );
436440
437441 QStringList includePaths = getIncludeDirectories (args.value (" include-paths" ));
438- if (!qtVersion) {
439- printf (" Trying to determine Qt version...\n " );
440- qtVersion = getQtVersion (includePaths);
441- if (!qtVersion)
442- {
443- fprintf (stderr, " Aborting\n " ); // the error message was printed by getQtVersion
444- return 1 ;
445- }
446- printf (" Determined Qt version is %d.%d.%d\n " , qtVersion >> 16 , (qtVersion >> 8 ) & 0xFF , qtVersion & 0xFF );
442+ if (!qtVersion && !includePaths.empty ()) {
443+ printf (" Trying to determine Qt version...\n " );
444+ qtVersion = getQtVersion (includePaths);
447445 }
446+ #ifdef Q_OS_MACOS
448447 QStringList frameworkPaths = getFrameworkDirectories (args.value (" framework-paths" ));
448+ if (!qtVersion && !frameworkPaths.empty ()) {
449+ printf (" Trying to determine Qt version...\n " );
450+ qtVersion = getQtVersion (frameworkPaths);
451+ }
452+ if (!qtVersion) {
453+ fprintf (stderr, " Aborting. Could not determine Qt version from include or framework paths.\n " );
454+ return 1 ;
455+ }
456+ #else
457+ QStringList frameworkPaths;
458+ if (!qtVersion) {
459+ fprintf (stderr, " Aborting. Could not determine Qt version from include paths.\n " );
460+ return 1 ;
461+ }
462+ #endif
463+ printf (" Determined Qt version is %d.%d.%d\n " , qtVersion >> 16 , (qtVersion >> 8 ) & 0xFF , qtVersion & 0xFF );
449464
450465 printf (" Parsing typesystem file [%s]\n " , qPrintable (typesystemFileName));
451466 fflush (stdout);
0 commit comments