diff options
| author | ruki <[email protected]> | 2020-09-04 22:53:41 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-09-04 22:53:41 +0800 |
| commit | 6d94dd1d7ae4b19977fddef3396b454235f6a6f1 (patch) | |
| tree | ad98079a8a3400b053451200e4aa1ae056626416 | |
| parent | 304cd31298a66501aecec161c31f5e94aa5ac142 (diff) | |
improve pkg_config.find_package
| -rw-r--r-- | xmake/modules/lib/detect/pkg_config.lua | 61 | ||||
| -rw-r--r-- | xmake/modules/package/manager/pkg_config/find_package.lua | 20 |
2 files changed, 20 insertions, 61 deletions
diff --git a/xmake/modules/lib/detect/pkg_config.lua b/xmake/modules/lib/detect/pkg_config.lua index f6c8f74be..4935f0c1e 100644 --- a/xmake/modules/lib/detect/pkg_config.lua +++ b/xmake/modules/lib/detect/pkg_config.lua @@ -151,7 +151,7 @@ function libinfo(name, opt) -- get links local link = flag:match("%-l(.*)") - if link then + if link and not link:find(path.sep(), 1, true) then result.links = result.links or {} table.insert(result.links, link) end @@ -190,62 +190,3 @@ function libinfo(name, opt) return result end --- find package --- --- @param name the package name --- @param opt the argument options, {plat = "", arch = "", links = {...}} --- --- @return {links = {"ssl", "crypto", "z"}, linkdirs = {""}, includedirs = {""}} --- --- @code --- --- local libinfo = pkg_config.find("openssl") --- --- @endcode --- -function find(name, opt) - - -- init options - opt = opt or {} - - -- get library info - local libinfo = libinfo(name, opt) - if not libinfo then - return - end - - -- get links - local links = libinfo.links - if not links or #links == 0 then - links = opt.links - end - - -- find library - local result = nil - local linkdirs = table.wrap(libinfo.linkdirs) - for _, link in ipairs(links) do - local libinfo = find_library(link, linkdirs) - if libinfo then - result = result or {} - result.links = table.join(result.links or {}, libinfo.link) - result.linkdirs = table.join(result.linkdirs or {}, libinfo.linkdir) - end - end - if result and result.links then - result.linkdirs = table.unique(result.linkdirs) - end - - -- get includedirs - if libinfo.includedirs then - result = result or {} - result.includedirs = libinfo.includedirs - end - - -- save version - if result and libinfo.version then - result.version = libinfo.version - end - - -- ok? - return result -end diff --git a/xmake/modules/package/manager/pkg_config/find_package.lua b/xmake/modules/package/manager/pkg_config/find_package.lua index b96a480ff..5ca2d5394 100644 --- a/xmake/modules/package/manager/pkg_config/find_package.lua +++ b/xmake/modules/package/manager/pkg_config/find_package.lua @@ -27,5 +27,23 @@ import("lib.detect.pkg_config") -- @param opt the options, e.g. {verbose = true, version = "1.12.x") -- function main(name, opt) - return pkg_config.find(name, opt) + + -- init options + opt = opt or {} + + -- get library info + local libinfo = pkg_config.libinfo(name, opt) + if not libinfo then + return + end + + local result = nil + if libinfo.links or libinfo.includedirs then + result = result or {} + result.includedirs = libinfo.includedirs + result.linkdirs = libinfo.linkdirs + result.links = libinfo.links + result.version = libinfo.version + end + return result end |
