diff --git a/xmake/modules/detect/sdks/find_qt.lua b/xmake/modules/detect/sdks/find_qt.lua index 1a9e79f7656..aa6195550cf 100644 --- a/xmake/modules/detect/sdks/find_qt.lua +++ b/xmake/modules/detect/sdks/find_qt.lua @@ -190,11 +190,21 @@ function _find_qmake(sdkdir, sdkver) end -- get qt environment -function _get_qtenvs(qmake) +function _get_qtenvs(qmake, sdkdir) local envs = {} + local run_args = {"-query"} + if sdkdir then + local conf_paths = {path.join(sdkdir, "bin", "target_qt.conf"), path.join(sdkdir, "bin", "qt.conf")} + for _, conf_path in ipairs(conf_paths) do + if os.isfile(conf_path) then + table.join2(run_args, {"-qtconf", conf_path}) + break + end + end + end local results = try { function () - return os.iorunv(qmake, {"-query"}) + return os.iorunv(qmake, run_args) end, catch { function (errors) @@ -215,24 +225,43 @@ function _get_qtenvs(qmake) end end +-- Verify and correct the Qt SDK version for cross-compiling. +-- qmake reports its own version (QT_VERSION), not the version specified in the SDK's configuration files. +function _tryfix_sdkver_for_cross(sdkdir, sdkver) + local qconfig_path = sdkdir and 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) +function _find_qt(sdkdir, sdkver, sdkdir_host) -- find qmake - local qmake = _find_qmake(sdkdir, sdkver) + local qmake = _find_qmake(sdkdir_host or sdkdir, sdkver) if not qmake then return end -- get qt environments - local qtenvs = _get_qtenvs(qmake) + local located_sdkdir = sdkdir and _find_sdkdir(sdkdir, sdkver) + local qtenvs = _get_qtenvs(qmake, located_sdkdir or sdkdir) if not qtenvs then return end -- 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 @@ -259,6 +288,16 @@ function _find_qt(sdkdir, sdkver) -- TODO end end + + if sdkdir_host then + local located_sdkdir_host = _find_sdkdir(sdkdir_host, sdkver) + local qtenvs_host = _get_qtenvs(qmake, located_sdkdir_host or sdkdir_host) + if qtenvs_host then + bindir_host = qtenvs_host.QT_HOST_BINS or qtenvs_host.QT_INSTALL_BINS or bindir_host + libexecdir_host = qtenvs_host.QT_HOST_LIBEXECS or qtenvs_host.QT_INSTALL_LIBEXECS or libexecdir_host + end + end + return {sdkdir = sdkdir, bindir = bindir, bindir_host = bindir_host, libexecdir = libexecdir, libexecdir_host = libexecdir_host, libdir = libdir, includedir = includedir, qmldir = qmldir, pluginsdir = pluginsdir, mkspecsdir = mkspecsdir, sdkver = sdkver} end @@ -282,13 +321,16 @@ function main(sdkdir, opt) -- attempt to load cache first local key = "detect.sdks.find_qt" - local cacheinfo = detectcache:get(key) or {} + local cacheinfo = (sdkdir and detectcache:get2(key, sdkdir)) or detectcache:get(key) or {} if not opt.force and cacheinfo.qt and cacheinfo.qt.sdkdir and os.isdir(cacheinfo.qt.sdkdir) then return cacheinfo.qt end -- find qt - local qt = _find_qt(sdkdir or config.get("qt") or global.get("qt") or config.get("sdk"), opt.version or config.get("qt_sdkver")) + local sdkdir = sdkdir or config.get("qt") or global.get("qt") or config.get("sdk") + local sdkver = opt.version or config.get("qt_sdkver") + local sdkdir_host = opt.sdkdir_host or config.get("qt_host") or global.get("qt_host") + local qt = _find_qt(sdkdir, sdkver, sdkdir_host) if qt then -- save to config @@ -314,7 +356,11 @@ function main(sdkdir, opt) -- save to cache cacheinfo.qt = qt or false - detectcache:set(key, cacheinfo) + if sdkdir then + detectcache:set2(key, sdkdir, cacheinfo) + else + detectcache:set(key, cacheinfo) + end detectcache:save() return qt end diff --git a/xmake/platforms/bsd/xmake.lua b/xmake/platforms/bsd/xmake.lua index 4b09fa68ded..26894146211 100644 --- a/xmake/platforms/bsd/xmake.lua +++ b/xmake/platforms/bsd/xmake.lua @@ -39,6 +39,7 @@ platform("bsd") , {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" } , {category = "Qt SDK Configuration" } , {nil, "qt", "kv", "auto", "The Qt SDK Directory" } + , {nil, "qt_host", "kv", "auto", "The Qt Host SDK Directory" } , {nil, "qt_sdkver", "kv", "auto", "The Qt SDK Version" } } @@ -48,6 +49,7 @@ platform("bsd") , {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" } , {category = "Qt SDK Configuration" } , {nil, "qt", "kv", "auto", "The Qt SDK Directory" } + , {nil, "qt_host", "kv", "auto", "The Qt Host SDK Directory" } } } diff --git a/xmake/platforms/haiku/xmake.lua b/xmake/platforms/haiku/xmake.lua index ba215545e81..aef1d9b711b 100644 --- a/xmake/platforms/haiku/xmake.lua +++ b/xmake/platforms/haiku/xmake.lua @@ -37,6 +37,7 @@ platform("haiku") , {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" } , {category = "Qt SDK Configuration" } , {nil, "qt", "kv", "auto", "The Qt SDK Directory" } + , {nil, "qt_host", "kv", "auto", "The Qt Host SDK Directory" } , {nil, "qt_sdkver", "kv", "auto", "The Qt SDK Version" } } @@ -46,6 +47,7 @@ platform("haiku") , {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" } , {category = "Qt SDK Configuration" } , {nil, "qt", "kv", "auto", "The Qt SDK Directory" } + , {nil, "qt_host", "kv", "auto", "The Qt Host SDK Directory" } } } diff --git a/xmake/platforms/linux/xmake.lua b/xmake/platforms/linux/xmake.lua index e4d57b533b1..ec2b6e74bf2 100644 --- a/xmake/platforms/linux/xmake.lua +++ b/xmake/platforms/linux/xmake.lua @@ -38,6 +38,7 @@ platform("linux") , {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" } , {category = "Qt SDK Configuration" } , {nil, "qt", "kv", "auto", "The Qt SDK Directory" } + , {nil, "qt_host", "kv", "auto", "The Qt Host SDK Directory" } , {nil, "qt_sdkver", "kv", "auto", "The Qt SDK Version" } , {category = "Vcpkg Configuration" } , {nil, "vcpkg", "kv", "auto", "The Vcpkg Directory" } @@ -49,6 +50,7 @@ platform("linux") , {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" } , {category = "Qt SDK Configuration" } , {nil, "qt", "kv", "auto", "The Qt SDK Directory" } + , {nil, "qt_host", "kv", "auto", "The Qt Host SDK Directory" } , {category = "Vcpkg Configuration" } , {nil, "vcpkg", "kv", "auto", "The Vcpkg Directory" } } diff --git a/xmake/platforms/macosx/xmake.lua b/xmake/platforms/macosx/xmake.lua index 74e50fb5032..6cd854ff865 100644 --- a/xmake/platforms/macosx/xmake.lua +++ b/xmake/platforms/macosx/xmake.lua @@ -47,6 +47,7 @@ platform("macosx") , {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" } , {category = "Qt SDK Configuration" } , {nil, "qt", "kv", "auto", "The Qt SDK Directory" } + , {nil, "qt_host", "kv", "auto", "The Qt Host SDK Directory" } , {nil, "qt_sdkver", "kv", "auto", "The Qt SDK Version" } , {category = "Vcpkg Configuration" } , {nil, "vcpkg", "kv", "auto", "The Vcpkg Directory" } @@ -63,6 +64,7 @@ platform("macosx") , {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" } , {category = "Qt SDK Configuration" } , {nil, "qt", "kv", "auto", "The Qt SDK Directory" } + , {nil, "qt_host", "kv", "auto", "The Qt Host SDK Directory" } , {category = "Vcpkg Configuration" } , {nil, "vcpkg", "kv", "auto", "The Vcpkg Directory" } } diff --git a/xmake/platforms/windows/xmake.lua b/xmake/platforms/windows/xmake.lua index 2b1bf40148c..d87d99fa87b 100644 --- a/xmake/platforms/windows/xmake.lua +++ b/xmake/platforms/windows/xmake.lua @@ -47,6 +47,7 @@ platform("windows") , {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" } , {category = "Qt SDK Configuration" } , {nil, "qt", "kv", "auto", "The Qt SDK Directory" } + , {nil, "qt_host", "kv", "auto", "The Qt Host SDK Directory" } , {nil, "qt_sdkver", "kv", "auto", "The Qt SDK Version" } , {category = "WDK Configuration" } , {nil, "wdk", "kv", "auto", "The WDK Directory" } @@ -71,6 +72,7 @@ platform("windows") , {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" } , {category = "Qt SDK Configuration" } , {nil, "qt", "kv", "auto", "The Qt SDK Directory" } + , {nil, "qt_host", "kv", "auto", "The Qt Host SDK Directory" } , {category = "WDK Configuration" } , {nil, "wdk", "kv", "auto", "The WDK Directory" } , {category = "Vcpkg Configuration" } diff --git a/xmake/rules/qt/deploy/android.lua b/xmake/rules/qt/deploy/android.lua index 9299c61e07e..052165b7779 100644 --- a/xmake/rules/qt/deploy/android.lua +++ b/xmake/rules/qt/deploy/android.lua @@ -71,9 +71,9 @@ function main(target, opt) end -- get androiddeployqt - local androiddeployqt = path.join(qt.bindir, "androiddeployqt" .. (is_host("windows") and ".exe" or "")) - if not os.isexec(androiddeployqt) and qt.bindir_host then - androiddeployqt = path.join(qt.bindir_host, "androiddeployqt" .. (is_host("windows") and ".exe" or "")) + local androiddeployqt = qt.bindir_host and path.join(qt.bindir_host, "androiddeployqt" .. (is_host("windows") and ".exe" or "")) + if (not androiddeployqt or not os.isexec(androiddeployqt)) and qt.bindir then + androiddeployqt = path.join(qt.bindir, "androiddeployqt" .. (is_host("windows") and ".exe" or "")) end assert(os.isexec(androiddeployqt), "androiddeployqt not found!") @@ -152,17 +152,17 @@ function main(target, opt) settings_file:print(' "target-architecture": "%s",', target_arch) settings_file:print(' "qml-root-path": "%s",', _escape_path(os.projectdir())) -- for 6.2.x - local qmlimportscanner = path.join(qt.libexecdir, "qmlimportscanner") - if not os.isexec(qmlimportscanner) and qt.libexecdir_host then - qmlimportscanner = path.join(qt.libexecdir_host, "qmlimportscanner") + local qmlimportscanner = qt.libexecdir_host and path.join(qt.libexecdir_host, "qmlimportscanner" .. (is_host("windows") and ".exe" or "")) + if (not qmlimportscanner or not os.isexec(qmlimportscanner)) and qt.libexecdir then + qmlimportscanner = path.join(qt.libexecdir, "qmlimportscanner" .. (is_host("windows") and ".exe" or "")) end if os.isexec(qmlimportscanner) then settings_file:print(' "qml-importscanner-binary": "%s",', _escape_path(qmlimportscanner)) end -- for 6.3.x - local rcc = path.join(qt.bindir, "rcc") - if not os.isexec(rcc) and qt.bindir_host then - rcc = path.join(qt.bindir_host, "rcc") + local rcc = qt.bindir_host and path.join(qt.bindir_host, "rcc" .. (is_host("windows") and ".exe" or "")) + if (not rcc or not os.isexec(rcc)) and qt.bindir then + rcc = path.join(qt.bindir, "rcc" .. (is_host("windows") and ".exe" or "")) end if os.isexec(rcc) then settings_file:print(' "rcc-binary": "%s",', _escape_path(rcc)) diff --git a/xmake/rules/qt/deploy/macosx.lua b/xmake/rules/qt/deploy/macosx.lua index 7cc05609939..eb4bdd94a15 100644 --- a/xmake/rules/qt/deploy/macosx.lua +++ b/xmake/rules/qt/deploy/macosx.lua @@ -91,7 +91,10 @@ function main(target, opt) local qt = assert(find_qt(), "Qt SDK not found!") -- get macdeployqt - local macdeployqt = path.join(qt.bindir, "macdeployqt") + local macdeployqt = qt.bindir_host and path.join(qt.bindir_host, "macdeployqt" .. (is_host("windows") and ".exe" or "")) + if (not macdeployqt or not os.isexec(macdeployqt)) and qt.bindir then + macdeployqt = path.join(qt.bindir, "macdeployqt" .. (is_host("windows") and ".exe" or "")) + end assert(os.isexec(macdeployqt), "macdeployqt not found!") -- generate target app diff --git a/xmake/rules/qt/env/xmake.lua b/xmake/rules/qt/env/xmake.lua index afaf62ae4d2..048da570d4a 100644 --- a/xmake/rules/qt/env/xmake.lua +++ b/xmake/rules/qt/env/xmake.lua @@ -33,7 +33,11 @@ rule("qt.env") local qmlimportpath = target:values("qt.env.qmlimportpath") or {} if target:is_plat("windows") or (target:is_plat("mingw") and is_host("windows")) then - target:add("runenvs", "PATH", qt.bindir) + for _, dir in ipairs({qt.bindir_host, qt.bindir}) do + if dir then + target:add("runenvs", "PATH", dir) + end + end table.insert(qmlimportpath, qt.qmldir) -- add targetdir in QML2_IMPORT_PATH in case of the user have qml plugins table.insert(qmlimportpath, target:targetdir()) diff --git a/xmake/rules/qt/install/mingw.lua b/xmake/rules/qt/install/mingw.lua index 9bf282c235f..e54eefbfe0f 100644 --- a/xmake/rules/qt/install/mingw.lua +++ b/xmake/rules/qt/install/mingw.lua @@ -42,7 +42,10 @@ function main(target, opt) local qt = assert(find_qt(), "Qt SDK not found!") -- get windeployqt - local windeployqt = path.join(qt.bindir, "windeployqt.exe") + local windeployqt = qt.bindir_host and path.join(qt.bindir_host, "windeployqt" .. (is_host("windows") and ".exe" or "")) + if (not windeployqt or not os.isexec(windeployqt)) and qt.bindir then + windeployqt = path.join(qt.bindir, "windeployqt" .. (is_host("windows") and ".exe" or "")) + end assert(os.isexec(windeployqt), "windeployqt.exe not found!") -- find qml directory diff --git a/xmake/rules/qt/install/windows.lua b/xmake/rules/qt/install/windows.lua index 7b8436e1bf5..32ce4217b7d 100644 --- a/xmake/rules/qt/install/windows.lua +++ b/xmake/rules/qt/install/windows.lua @@ -42,7 +42,10 @@ function main(target, opt) local qt = assert(find_qt(), "Qt SDK not found!") -- get windeployqt - local windeployqt = path.join(qt.bindir, "windeployqt.exe") + local windeployqt = qt.bindir_host and path.join(qt.bindir_host, "windeployqt" .. (is_host("windows") and ".exe" or "")) + if (not windeployqt or not os.isexec(windeployqt)) and qt.bindir then + windeployqt = path.join(qt.bindir, "windeployqt" .. (is_host("windows") and ".exe" or "")) + end assert(os.isexec(windeployqt), "windeployqt.exe not found!") -- find qml directory @@ -73,9 +76,9 @@ function main(target, opt) end -- bind qt bin path -- https://github.com/xmake-io/xmake/issues/4297 - if qt.bindir then + if qt.bindir_host or qt.bindir then envs = envs or {} - envs.PATH = {qt.bindir} + envs.PATH = {qt.bindir_host, qt.bindir} local curpath = os.getenv("PATH") if curpath then table.join2(envs.PATH, path.splitenv(curpath)) diff --git a/xmake/rules/qt/load.lua b/xmake/rules/qt/load.lua index c9269b0b61d..b9928b26070 100644 --- a/xmake/rules/qt/load.lua +++ b/xmake/rules/qt/load.lua @@ -449,7 +449,11 @@ function main(target, opt) target:add("linkdirs", qt.libdir) target:add("syslinks", "ws2_32", "gdi32", "ole32", "advapi32", "shell32", "user32", "opengl32", "imm32", "winmm", "iphlpapi") -- for debugger, https://github.com/xmake-io/xmake-vscode/issues/225 - target:add("runenvs", "PATH", qt.bindir) + for _, dir in ipairs({qt.bindir_host, qt.bindir}) do + if dir then + target:add("runenvs", "PATH", dir) + end + end elseif target:is_plat("mingw") then target:set("frameworks", nil) -- we need to fix it, because gcc maybe does not work on latest mingw when `-isystem D:\a\_temp\msys64\mingw64\include` is passed. diff --git a/xmake/rules/qt/moc/xmake.lua b/xmake/rules/qt/moc/xmake.lua index d4272b688b7..f14e28a1949 100644 --- a/xmake/rules/qt/moc/xmake.lua +++ b/xmake/rules/qt/moc/xmake.lua @@ -27,12 +27,15 @@ rule("qt.moc") -- get moc local qt = assert(target:data("qt"), "Qt not found!") - local moc = path.join(qt.bindir, is_host("windows") and "moc.exe" or "moc") - if not os.isexec(moc) and qt.libexecdir then - moc = path.join(qt.libexecdir, is_host("windows") and "moc.exe" or "moc") - end - if not os.isexec(moc) and qt.libexecdir_host then - moc = path.join(qt.libexecdir_host, is_host("windows") and "moc.exe" or "moc") + local moc + local moc_name = is_host("windows") and "moc.exe" or "moc" + for _, dir in ipairs({qt.bindir_host, qt.libexecdir_host, qt.bindir, qt.libexecdir}) do + if dir then + moc = path.join(dir, moc_name) + if os.isexec(moc) then + break + end + end end assert(moc and os.isexec(moc), "moc not found!") diff --git a/xmake/rules/qt/qmltyperegistrar/xmake.lua b/xmake/rules/qt/qmltyperegistrar/xmake.lua index 8e25f109e69..031aebe63c2 100644 --- a/xmake/rules/qt/qmltyperegistrar/xmake.lua +++ b/xmake/rules/qt/qmltyperegistrar/xmake.lua @@ -27,12 +27,15 @@ rule("qt.qmltyperegistrar") local qt = assert(target:data("qt"), "Qt not found!") -- get qmltyperegistrar - local qmltyperegistrar = path.join(qt.bindir, is_host("windows") and "qmltyperegistrar.exe" or "qmltyperegistrar") - if not os.isexec(qmltyperegistrar) and qt.libexecdir then - qmltyperegistrar = path.join(qt.libexecdir, is_host("windows") and "qmltyperegistrar.exe" or "qmltyperegistrar") - end - if not os.isexec(qmltyperegistrar) and qt.libexecdir_host then - qmltyperegistrar = path.join(qt.libexecdir_host, is_host("windows") and "qmltyperegistrar.exe" or "qmltyperegistrar") + local qmltyperegistrar + local qmltyperegistrar_name = is_host("windows") and "qmltyperegistrar.exe" or "qmltyperegistrar" + for _, dir in ipairs({qt.bindir_host, qt.libexecdir_host, qt.bindir, qt.libexecdir}) do + if dir then + qmltyperegistrar = path.join(dir, qmltyperegistrar_name) + if os.isexec(qmltyperegistrar) then + break + end + end end assert(qmltyperegistrar and os.isexec(qmltyperegistrar), "qmltyperegistrar not found!") diff --git a/xmake/rules/qt/qrc/xmake.lua b/xmake/rules/qt/qrc/xmake.lua index 084a7fff02a..b7beb9feb73 100644 --- a/xmake/rules/qt/qrc/xmake.lua +++ b/xmake/rules/qt/qrc/xmake.lua @@ -25,12 +25,15 @@ rule("qt.qrc") -- get rcc local qt = assert(target:data("qt"), "Qt not found!") - local rcc = path.join(qt.bindir, is_host("windows") and "rcc.exe" or "rcc") - if not os.isexec(rcc) and qt.libexecdir then - rcc = path.join(qt.libexecdir, is_host("windows") and "rcc.exe" or "rcc") - end - if not os.isexec(rcc) and qt.libexecdir_host then - rcc = path.join(qt.libexecdir_host, is_host("windows") and "rcc.exe" or "rcc") + local rcc + local rcc_name = is_host("windows") and "rcc.exe" or "rcc" + for _, dir in ipairs({qt.bindir_host, qt.libexecdir_host, qt.bindir, qt.libexecdir}) do + if dir then + rcc = path.join(dir, rcc_name) + if os.isexec(rcc) then + break + end + end end assert(os.isexec(rcc), "rcc not found!") diff --git a/xmake/rules/qt/ts/xmake.lua b/xmake/rules/qt/ts/xmake.lua index 95e44d2a286..2160a2f054c 100644 --- a/xmake/rules/qt/ts/xmake.lua +++ b/xmake/rules/qt/ts/xmake.lua @@ -20,22 +20,31 @@ rule("qt.ts") if sourcefile_ts then -- get lupdate and lrelease local qt = assert(target:data("qt"), "qt not found!") - local lupdate = path.join(qt.bindir, is_host("windows") and "lupdate.exe" or "lupdate") - local lrelease = path.join(qt.bindir, is_host("windows") and "lrelease.exe" or "lrelease") - if not os.isexec(lupdate) and qt.libexecdir then - lupdate = path.join(qt.libexecdir, is_host("windows") and "lupdate.exe" or "lupdate") - end - if not os.isexec(lrelease) and qt.libexecdir then - lrelease = path.join(qt.libexecdir, is_host("windows") and "lrelease.exe" or "lrelease") - end - if not os.isexec(lupdate) and qt.libexecdir_host then - lupdate = path.join(qt.libexecdir_host, is_host("windows") and "lupdate.exe" or "lupdate") - end - if not os.isexec(lrelease) and qt.libexecdir_host then - lrelease = path.join(qt.libexecdir_host, is_host("windows") and "lrelease.exe" or "lrelease") + + local lupdate + local lupdate_name = is_host("windows") and "lupdate.exe" or "lupdate" + for _, dir in ipairs({qt.bindir_host, qt.libexecdir_host, qt.bindir, qt.libexecdir}) do + if dir then + lupdate = path.join(dir, lupdate_name) + if os.isexec(lupdate) then + break + end + end end assert(os.isexec(lupdate), "lupdate not found!") + + local lrelease + local lrelease_name = is_host("windows") and "lrelease.exe" or "lrelease" + for _, dir in ipairs({qt.bindir_host, qt.libexecdir_host, qt.bindir, qt.libexecdir}) do + if dir then + lrelease = path.join(dir, lrelease_name) + if os.isexec(lrelease) then + break + end + end + end assert(os.isexec(lrelease), "lrelease not found!") + for _, tsfile in ipairs(sourcefile_ts) do local tsargv = {} table.join2(tsargv, lupdate_argv) diff --git a/xmake/rules/qt/ui/xmake.lua b/xmake/rules/qt/ui/xmake.lua index b4f769050b5..f871f828eb4 100644 --- a/xmake/rules/qt/ui/xmake.lua +++ b/xmake/rules/qt/ui/xmake.lua @@ -25,12 +25,15 @@ rule("qt.ui") -- get uic local qt = assert(target:data("qt"), "Qt not found!") - local uic = path.join(qt.bindir, is_host("windows") and "uic.exe" or "uic") - if not os.isexec(uic) and qt.libexecdir then - uic = path.join(qt.libexecdir, is_host("windows") and "uic.exe" or "uic") - end - if not os.isexec(uic) and qt.libexecdir_host then - uic = path.join(qt.libexecdir_host, is_host("windows") and "uic.exe" or "uic") + local uic + local uic_name = is_host("windows") and "uic.exe" or "uic" + for _, dir in ipairs({qt.bindir_host, qt.libexecdir_host, qt.bindir, qt.libexecdir}) do + if dir then + uic = path.join(dir, uic_name) + if os.isexec(uic) then + break + end + end end assert(uic and os.isexec(uic), "uic not found!")