summaryrefslogtreecommitdiff
path: root/xmake/modules/lib/detect/pkgconfig.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2021-04-04 21:08:49 +0800
committerruki <[email protected]>2021-04-04 21:08:49 +0800
commitafbbe0900bd48341084c11bcf4e0120782dff6e5 (patch)
tree00483b42d206f438f764519d691c032ee5a280aa /xmake/modules/lib/detect/pkgconfig.lua
parent7deb549fee853b96d396b63e8f1192fb1973d000 (diff)
improve pkgconfig
Diffstat (limited to 'xmake/modules/lib/detect/pkgconfig.lua')
-rw-r--r--xmake/modules/lib/detect/pkgconfig.lua13
1 files changed, 4 insertions, 9 deletions
diff --git a/xmake/modules/lib/detect/pkgconfig.lua b/xmake/modules/lib/detect/pkgconfig.lua
index 98f9eae68..f7d17fe33 100644
--- a/xmake/modules/lib/detect/pkgconfig.lua
+++ b/xmake/modules/lib/detect/pkgconfig.lua
@@ -134,15 +134,15 @@ function libinfo(name, opt)
opt = opt or {}
-- init PKG_CONFIG_PATH
- local configdirs_old = os.getenv("PKG_CONFIG_PATH")
+ local envs = {}
local configdirs = table.wrap(opt.configdirs)
if #configdirs > 0 then
- os.setenv("PKG_CONFIG_PATH", unpack(configdirs))
+ envs.PKG_CONFIG_PATH = path.joinenv(configdirs)
end
-- get libs and cflags
local result = nil
- local flags = try { function () return os.iorunv(pkgconfig, {"--libs", "--cflags", name}) end }
+ local flags = try { function () return os.iorunv(pkgconfig, {"--libs", "--cflags", name}, {envs = envs}) end }
if flags then
-- init result
@@ -172,16 +172,11 @@ function libinfo(name, opt)
end
-- get version
- local version = try { function() return os.iorunv(pkgconfig, {"--modversion", name}) end }
+ local version = try { function() return os.iorunv(pkgconfig, {"--modversion", name}, {envs = envs}) end }
if version then
result = result or {}
result.version = version:trim()
end
-
- -- restore PKG_CONFIG_PATH
- if configdirs_old then
- os.setenv("PKG_CONFIG_PATH", configdirs_old)
- end
return result
end