Skip to content

Commit

Permalink
Fix Qt SDK version for cross-compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
Doekin committed Jan 19, 2025
1 parent 1b2bebe commit 92ff817
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion xmake/modules/detect/sdks/find_qt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,23 @@ function _get_qtenvs(qmake, sdkdir)
end
end

-- check and correct SDK version for cross-compiling
function _tryfix_sdkver_for_cross(sdkdir, sdkver)
local qconfig_path = path.join(sdkdir, "mkspecs", "qconfig.pri")
if not sdkver or not os.isfile(qconfig_path) then
return sdkver
end
-- Extract the actual SDK version from qconfig.pri
local actual_sdkver = io.readfile(qconfig_path):match("QT_VERSION%s*=%s*(%S*)") -- Expected format: QT_VERSION = x.y.z
if not actual_sdkver then
return sdkver
end
if sdkver ~= actual_sdkver then
wprint("Host Qt SDK version (%s) differs from Target Qt SDK version (%s). To prevent build issues, please ensure both use the same version.", sdkver, actual_sdkver);
end
return actual_sdkver
end

-- find qt sdk toolchains
function _find_qt(sdkdir, sdkver)

Expand All @@ -237,7 +254,7 @@ function _find_qt(sdkdir, sdkver)

-- get qt toolchains
sdkdir = qtenvs.QT_INSTALL_PREFIX
local sdkver = qtenvs.QT_VERSION
local sdkver = _tryfix_sdkver_for_cross(sdkdir, qtenvs.QT_VERSION)
local bindir = qtenvs.QT_INSTALL_BINS
local libexecdir = qtenvs.QT_INSTALL_LIBEXECS
local qmldir = qtenvs.QT_INSTALL_QML
Expand Down

0 comments on commit 92ff817

Please sign in to comment.