summaryrefslogtreecommitdiff
path: root/xmake/modules/lib/detect/pkgconfig.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2023-05-31 22:33:42 +0800
committerruki <[email protected]>2023-05-31 22:33:42 +0800
commit2c4e281d00f8019a4416d0b8b89eeac4b37a34e5 (patch)
treece0e4bf5d649a1bec038b8c93a6564af81d94290 /xmake/modules/lib/detect/pkgconfig.lua
parent853d25d9192c4e2c936b2dbd267342ad5a6766ae (diff)
improve to find package from pkg-config #3777
Diffstat (limited to 'xmake/modules/lib/detect/pkgconfig.lua')
-rw-r--r--xmake/modules/lib/detect/pkgconfig.lua15
1 files changed, 10 insertions, 5 deletions
diff --git a/xmake/modules/lib/detect/pkgconfig.lua b/xmake/modules/lib/detect/pkgconfig.lua
index ccf3f1e1f..f58477f04 100644
--- a/xmake/modules/lib/detect/pkgconfig.lua
+++ b/xmake/modules/lib/detect/pkgconfig.lua
@@ -149,10 +149,11 @@ function libinfo(name, opt)
end
-- get cflags
- local result = nil
- local cflags = try { function () return os.iorunv(pkgconfig, {"--cflags", name}, {envs = envs}) end }
+ local found
+ local result = {}
+ local cflags = try {function () return os.iorunv(pkgconfig, {"--cflags", name}, {envs = envs}) end,
+ catch {function (errs) found = false end}}
if cflags then
- result = result or {}
for _, flag in ipairs(os.argv(cflags)) do
if flag:startswith("-I") and #flag > 2 then
local includedir = flag:sub(3)
@@ -171,10 +172,15 @@ function libinfo(name, opt)
end
end
+ -- libinfo may be empty body, but it's also valid
+ -- @see https://github.com/xmake-io/xmake/issues/3777#issuecomment-1568453316
+ if found == false then
+ return
+ end
+
-- get libs and ldflags
local ldflags = try { function () return os.iorunv(pkgconfig, {"--libs", name}, {envs = envs}) end }
if ldflags then
- result = result or {}
for _, flag in ipairs(os.argv(ldflags)) do
if flag:startswith("-L") and #flag > 2 then
local linkdir = flag:sub(3)
@@ -198,7 +204,6 @@ function libinfo(name, opt)
-- get version
local version = try { function() return os.iorunv(pkgconfig, {"--modversion", name}, {envs = envs}) end }
if version then
- result = result or {}
result.version = version:trim()
end
return result