diff options
| author | ruki <[email protected]> | 2024-08-07 23:55:42 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-08-07 23:55:42 +0800 |
| commit | 7b7e98eaf4bc8358beca3bedd8a549f6a05418e3 (patch) | |
| tree | 70373bd2ec30208f41829568a12655fbce00009b /xmake/modules/package/manager/pkgconfig/find_package.lua | |
| parent | 988d038bb95e83325d2bac655a0886f623844d91 (diff) | |
find libfiles from pkg-config
Diffstat (limited to 'xmake/modules/package/manager/pkgconfig/find_package.lua')
| -rw-r--r-- | xmake/modules/package/manager/pkgconfig/find_package.lua | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/xmake/modules/package/manager/pkgconfig/find_package.lua b/xmake/modules/package/manager/pkgconfig/find_package.lua index 041aa8629..b8237ebcb 100644 --- a/xmake/modules/package/manager/pkgconfig/find_package.lua +++ b/xmake/modules/package/manager/pkgconfig/find_package.lua @@ -20,6 +20,7 @@ -- imports import("lib.detect.pkgconfig") +import("lib.detect.find_library") import("private.core.base.is_cross") import("package.manager.system.find_package", {alias = "find_package_from_system"}) @@ -66,5 +67,37 @@ function main(name, opt) result.shflags = libinfo.shflags result.version = libinfo.version end + + -- find libfiles + if result and libinfo then + local libdirs = libinfo.linkdirs + if not libdirs then + local pcfile = pkgconfig.pcfile(name, opt) + if not pcfile and name:startswith("lib") then + pcfile = pkgconfig.pcfile(name:sub(4), opt) + end + if pcfile then + libdirs = path.directory(pcfile) + if path.filename(libdirs) == "pkgconfig" then + libdirs = path.directory(libdirs) + end + end + end + if libdirs and libinfo.links then + for _, link in ipairs(libinfo.links) do + local info = find_library(link, libdirs, {plat = opt.plat}) + if info and info.linkdir and info.filename then + result.libfiles = result.libfiles or {} + table.insert(result.libfiles, path.join(info.linkdir, info.filename)) + if info.kind then + result[info.kind] = true + end + end + end + end + if result.libfiles then + result.libfiles = table.unique(result.libfiles) + end + end return result end |
