summaryrefslogtreecommitdiff
path: root/xmake/modules
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/modules')
-rw-r--r--xmake/modules/detect/packages/find_zlib.lua14
-rw-r--r--xmake/modules/lib/detect/pkg_config.lua28
2 files changed, 19 insertions, 23 deletions
diff --git a/xmake/modules/detect/packages/find_zlib.lua b/xmake/modules/detect/packages/find_zlib.lua
index e31065f6e..56a76f4cd 100644
--- a/xmake/modules/detect/packages/find_zlib.lua
+++ b/xmake/modules/detect/packages/find_zlib.lua
@@ -63,14 +63,12 @@ function main(opt)
-- save include directory
table.insert(result.includedirs, includedir)
- -- match version
- if opt.version then
- local zlib_h = io.readfile(path.join(includedir, "zlib.h"))
- if zlib_h then
- local version = zlib_h:match("#define ZLIB_VERSION \"(%d+%.?%d+%.?%d+)\"")
- if version ~= opt.version then
- return
- end
+ -- get version
+ local zlib_h = io.readfile(path.join(includedir, "zlib.h"))
+ if zlib_h then
+ local version = zlib_h:match("#define ZLIB_VERSION \"(%d+%.?%d+%.?%d+)\"")
+ if version then
+ result.version = version
end
end
end
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