summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-03-24 22:34:40 +0800
committerruki <[email protected]>2023-03-24 22:34:40 +0800
commit2b26ccfe4deeccdf73d405254bb81becbefc7da8 (patch)
tree45a37fd8e4fd5316ab3dcea4ad8e98acb3a42459
parentdfa565e29779ca534506e2ee526a4399003585f4 (diff)
improve to find qt6 from qmake6
-rw-r--r--xmake/core/sandbox/modules/import/core/base/semver.lua5
-rw-r--r--xmake/modules/detect/sdks/find_qt.lua26
2 files changed, 30 insertions, 1 deletions
diff --git a/xmake/core/sandbox/modules/import/core/base/semver.lua b/xmake/core/sandbox/modules/import/core/base/semver.lua
index 8d1dfe33a..f842a0a38 100644
--- a/xmake/core/sandbox/modules/import/core/base/semver.lua
+++ b/xmake/core/sandbox/modules/import/core/base/semver.lua
@@ -35,6 +35,11 @@ function sandbox_core_base_semver.new(version)
return result
end
+-- try parsing the given version string to semver instance
+function sandbox_core_base_semver.try_parse(version)
+ return semver.new(version)
+end
+
-- match a valid version from the string
--
-- semver.match('xxx 1.2.3 xxx') => { major = 1, minor = 2, patch = 3, ... }
diff --git a/xmake/modules/detect/sdks/find_qt.lua b/xmake/modules/detect/sdks/find_qt.lua
index 8477a1a02..379baba8a 100644
--- a/xmake/modules/detect/sdks/find_qt.lua
+++ b/xmake/modules/detect/sdks/find_qt.lua
@@ -21,6 +21,7 @@
-- imports
import("lib.detect.find_file")
import("lib.detect.find_tool")
+import("core.base.semver")
import("core.base.option")
import("core.base.global")
import("core.project.config")
@@ -139,11 +140,34 @@ end
-- find qmake
function _find_qmake(sdkdir, sdkver)
+
+ -- we attempt to find qmake from qt sdkdir first
local sdkdir, qmakefile = _find_sdkdir(sdkdir, sdkver)
if qmakefile then
return qmakefile
end
- local qmake = find_tool("qmake", {paths = sdkdir and path.join(sdkdir, "bin")})
+
+ -- try finding qmake with the specific version, e.g. /usr/bin/qmake6
+ -- https://github.com/xmake-io/xmake/pull/3555
+ local qmake
+ if sdkver then
+ sdkver = semver.try_parse(sdkver)
+ if sdkver then
+ qmake = find_tool("qmake", {program = "qmake" .. sdkver:major(), paths = sdkdir and path.join(sdkdir, "bin")})
+ end
+ end
+
+ -- we need find the default qmake in current system
+ -- maybe we only installed qmake6
+ if not qmake then
+ local suffixes = {"", "6"}
+ for _, suffix in ipairs(suffixes) do
+ qmake = find_tool("qmake", {program = "qmake" .. suffix, paths = sdkdir and path.join(sdkdir, "bin")})
+ if qmake then
+ break
+ end
+ end
+ end
if qmake then
return qmake.program
end