Skip to content

Commit

Permalink
Merge pull request #5238 from Elite-stay/patch-1
Browse files Browse the repository at this point in the history
add QT_LIBINFIX property support
  • Loading branch information
waruqi authored Jun 22, 2024
2 parents 872ddbd + 7121f43 commit ecb16eb
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions xmake/rules/qt/load.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import("core.base.hashset")
import("lib.detect.find_library")

-- make link for framework
function _link(target, linkdirs, framework, qt_sdkver)
function _link(target, linkdirs, framework, qt_sdkver, infix)
if framework:startswith("Qt") then
local debug_suffix = "_debug"
if target:is_plat("windows") then
Expand All @@ -41,12 +41,12 @@ function _link(target, linkdirs, framework, qt_sdkver)
debug_suffix = ""
end
if qt_sdkver:ge("5.0") then
framework = "Qt" .. qt_sdkver:major() .. framework:sub(3) .. (is_mode("debug") and debug_suffix or "")
framework = "Qt" .. qt_sdkver:major() .. framework:sub(3) .. infix .. (is_mode("debug") and debug_suffix or "")
else -- for qt4.x, e.g. QtGui4.lib
if target:is_plat("windows", "mingw") then
framework = "Qt" .. framework:sub(3) .. (is_mode("debug") and debug_suffix or "") .. qt_sdkver:major()
framework = "Qt" .. framework:sub(3) .. infix .. (is_mode("debug") and debug_suffix or "") .. qt_sdkver:major()
else
framework = "Qt" .. framework:sub(3) .. (is_mode("debug") and debug_suffix or "")
framework = "Qt" .. framework:sub(3) .. infix .. (is_mode("debug") and debug_suffix or "")
end
end
if target:is_plat("android") then --> -lQt5Core_armeabi/-lQt5CoreDebug_armeabi for 5.14.x
Expand Down Expand Up @@ -185,6 +185,25 @@ function main(target, opt)
raise("Qt SDK version not found, please run `xmake f --qt_sdkver=xxx` to set it.")
end

-- get qt sdk infix
local infix = ""
if qt.mkspecsdir then
if os.isfile(path.join(qt.mkspecsdir, "qconfig.pri")) then
local qconfig = io.readfile(path.join(qt.mkspecsdir, "qconfig.pri"))
if qconfig then
qconfig = qconfig:trim():split("\n")
for _, line in ipairs(qconfig) do
if line:startswith("QT_LIBINFIX") then
local kv = line:split("=", {plain = true, limit = 2})
if #kv == 2 then
infix = kv[2]:trim()
end
end
end
end
end
end

-- add -fPIC
if not target:is_plat("windows", "mingw") then
target:add("cxflags", "-fPIC")
Expand Down Expand Up @@ -333,7 +352,7 @@ function main(target, opt)
_add_includedirs(target, path.join(frameworkdir, "Headers", qt.sdkver, framework))
frameworksset:insert(framework)
else
local link = _link(target, qt.libdir, framework, qt_sdkver)
local link = _link(target, qt.libdir, framework, qt_sdkver, infix)
target:add("syslinks", link)
_add_qmakeprllibs(target, path.join(qt.libdir, link .. ".prl"), qt.libdir)
_add_includedirs(target, path.join(qt.includedir, framework))
Expand All @@ -342,7 +361,7 @@ function main(target, opt)
_add_includedirs(target, path.join(qt.includedir, framework, qt.sdkver, framework))
end
else
local link = _link(target, qt.libdir, framework, qt_sdkver)
local link = _link(target, qt.libdir, framework, qt_sdkver, infix)
target:add("syslinks", link)
_add_qmakeprllibs(target, path.join(qt.libdir, link .. ".prl"), qt.libdir)
_add_includedirs(target, path.join(qt.includedir, framework))
Expand Down

0 comments on commit ecb16eb

Please sign in to comment.