summaryrefslogtreecommitdiff
path: root/xmake/modules/lib/detect/pkg_config.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2018-12-01 00:42:11 +0800
committerruki <[email protected]>2018-11-30 22:13:10 +0800
commit4b5c554e53ca52e80c66f698d41f999a4664c7d4 (patch)
treeeedef660a3594d5d87df0a3fed8efd8097463ea3 /xmake/modules/lib/detect/pkg_config.lua
parent55cebc0c6439c674088a18d3cc289f9f03d666f3 (diff)
improve find_package to get version
Diffstat (limited to 'xmake/modules/lib/detect/pkg_config.lua')
-rw-r--r--xmake/modules/lib/detect/pkg_config.lua28
1 files changed, 13 insertions, 15 deletions
diff --git a/xmake/modules/lib/detect/pkg_config.lua b/xmake/modules/lib/detect/pkg_config.lua
index 2eb675ed7..1f18e15ef 100644
--- a/xmake/modules/lib/detect/pkg_config.lua
+++ b/xmake/modules/lib/detect/pkg_config.lua
@@ -130,14 +130,10 @@ function info(name, opt)
end
-- get version
- if opt.version then
-
- -- get version
- local version = try { function() return os.iorunv(pkg_config, {"--modversion", name}) end }
- if version then
- result = result or {}
- result.version = version:trim()
- end
+ local version = try { function() return os.iorunv(pkg_config, {"--modversion", name}) end }
+ if version then
+ result = result or {}
+ result.version = version:trim()
end
-- restore PKG_CONFIG_PATH
@@ -155,7 +151,7 @@ end
-- find package
--
-- @param name the package name
--- @param opt the argument options, {plat = "", arch = "", version = "1.0.1", links = {...}}
+-- @param opt the argument options, {plat = "", arch = "", links = {...}}
--
-- @return {links = {"ssl", "crypto", "z"}, linkdirs = {""}, includedirs = {""}}
--
@@ -167,18 +163,15 @@ end
--
function find(name, opt)
+ -- init options
+ opt = opt or {}
+
-- get package info
local pkginfo = info(name, opt)
if not pkginfo then
return
end
- -- match version?
- opt = opt or {}
- if opt.version and pkginfo.version ~= opt.version then
- return
- end
-
-- get links
local links = pkginfo.links
if not links or #links == 0 then
@@ -218,6 +211,11 @@ function find(name, opt)
result.includedirs = table.join(result.includedirs or {}, pkginfo.includedirs)
end
+ -- save version
+ if result and pkginfo.version then
+ result.version = pkginfo.version
+ end
+
-- ok?
return result
end