Skip to content

Commit dd42ec8

Browse files
committed
fix(generator): Support additional qtcoreversion.h header paths
This improves header file detection on macOS by introducing support for additional common paths where `qtcoreversion.h` might be located. This change enhances compatibility with different Qt installations.
1 parent 4d93e7a commit dd42ec8

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

generator/main.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,30 @@ namespace
306306
unsigned int getQtVersion(const QStringList& paths)
307307
{
308308
QRegularExpression re("#define\\s+QTCORE_VERSION\\s+0x([0-9a-f]+)", QRegularExpression::CaseInsensitiveOption);
309+
310+
// Iterate through provided paths to find the qtcoreversion.h header file
309311
for (const QString &path: paths)
310312
{
311313
#ifdef Q_OS_MACOS
312-
QString qtCoreVersionHeader = joinPath(path, "Versions/A/Headers/qtcoreversion.h");
314+
// Define potential locations for the header file on macOS
315+
const QStringList candidates = {
316+
joinPath(path, "Versions/A/Headers/qtcoreversion.h"),
317+
joinPath(path, "Versions/5/Headers/qtcoreversion.h"),
318+
joinPath(path, "Headers/qtcoreversion.h"), // top-level Headers (often a symlink into Versions)
319+
};
313320
#else
314-
QString qtCoreVersionHeader = joinPath(path, "qtcoreversion.h");
321+
// Define the location for other platforms
322+
const QStringList candidates = { joinPath(path, "qtcoreversion.h") };
315323
#endif
324+
// Pick the first existing candidate
325+
QString qtCoreVersionHeader;
326+
for (const QString& candidate : candidates) {
327+
if (QFile::exists(candidate)) {
328+
qtCoreVersionHeader = candidate;
329+
break;
330+
}
331+
}
332+
316333
if (QFile::exists(qtCoreVersionHeader))
317334
{
318335
QString filePath = QFileInfo(qtCoreVersionHeader).absoluteFilePath();

0 commit comments

Comments
 (0)