Skip to content

Commit

Permalink
Merge pull request #5407 from xiaobfly/dev
Browse files Browse the repository at this point in the history
fix Qt static compilation issue
  • Loading branch information
waruqi authored Jul 29, 2024
2 parents 8cd2a3b + 0936bb1 commit 2b3aca5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion xmake/modules/core/tools/link.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ end

-- make the link flag
function nf_link(self, lib)
if not lib:endswith(".lib") then
if not lib:endswith(".lib") and not lib:endswith(".obj") then
lib = lib .. ".lib"
end
return lib
Expand Down
27 changes: 19 additions & 8 deletions xmake/rules/qt/load.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function _get_frameworks_from_target(target)
return table.unique(values)
end

function _add_qmakeprllibs(target, prlfile, qtlibdir)
function _add_qmakeprllibs(target, prlfile, qt)
if os.isfile(prlfile) then
local contents = io.readfile(prlfile)
local envs = {}
Expand All @@ -157,11 +157,22 @@ function _add_qmakeprllibs(target, prlfile, qtlibdir)
local libdir = lib:sub(3)
target:add("linkdirs", libdir)
else
local libstr = string.gsub(lib, "%$%$%[QT_INSTALL_LIBS%]", qtlibdir)
if libstr:startswith("-l") then
libstr = libstr:sub(3)
if qt.qmldir then
lib = string.gsub(lib, "%$%$%[QT_INSTALL_QML%]", qt.qmldir)
end
target:add("syslinks", libstr)
if qt.sdkdir then
lib = string.gsub(lib, "%$%$%[QT_INSTALL_PREFIX%]", qt.sdkdir)
end
if qt.pluginsdir then
lib = string.gsub(lib, "%$%$%[QT_INSTALL_PLUGINS%]", qt.pluginsdir)
end
if qt.libdir then
lib = string.gsub(lib, "%$%$%[QT_INSTALL_LIBS%]", qt.libdir)
end
if lib:startswith("-l") then
lib = lib:sub(3)
end
target:add("syslinks", lib)
end
end
end
Expand Down Expand Up @@ -295,7 +306,7 @@ function main(target, opt)
for _, qt_link in ipairs(target:values("qt.links")) do
for _, qt_libdir in ipairs(qtprldirs) do
local prl_file = path.join(qt_libdir, qt_link .. ".prl")
_add_qmakeprllibs(target, prl_file, qt.libdir)
_add_qmakeprllibs(target, prl_file, qt)
end
end

Expand Down Expand Up @@ -354,7 +365,7 @@ function main(target, opt)
else
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_qmakeprllibs(target, path.join(qt.libdir, link .. ".prl"), qt)
_add_includedirs(target, path.join(qt.includedir, framework))
-- e.g. QtGui/5.15.0/QtGui/qpa/qplatformopenglcontext.h
_add_includedirs(target, path.join(qt.includedir, framework, qt.sdkver))
Expand All @@ -363,7 +374,7 @@ function main(target, opt)
else
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_qmakeprllibs(target, path.join(qt.libdir, link .. ".prl"), qt)
_add_includedirs(target, path.join(qt.includedir, framework))
_add_includedirs(target, path.join(qt.includedir, framework, qt.sdkver))
_add_includedirs(target, path.join(qt.includedir, framework, qt.sdkver, framework))
Expand Down

0 comments on commit 2b3aca5

Please sign in to comment.