From 0fc304af564ce6215df38fbda571d3ee204e585d Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 12 Jun 2017 23:15:52 +0800 Subject: use brew to improve find_package() --- xmake/modules/lib/detect/pkg_config.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'xmake/modules/lib') diff --git a/xmake/modules/lib/detect/pkg_config.lua b/xmake/modules/lib/detect/pkg_config.lua index 880db92a8..4a7140471 100644 --- a/xmake/modules/lib/detect/pkg_config.lua +++ b/xmake/modules/lib/detect/pkg_config.lua @@ -29,7 +29,7 @@ import("detect.tool.find_pkg_config") -- get package info -- -- @param name the package name --- @param opt the argument options, {version = true} +-- @param opt the argument options, {version = true, configdirs = {"/xxxx/pkgconfig/"}} -- -- @return {links = {"ssl", "crypto", "z"}, linkdirs = {""}, includedirs = {""}, version = ""} -- @@ -47,6 +47,13 @@ function info(name, opt) return end + -- add PKG_CONFIG_PATH + local configdirs = nil + if opt and opt.configdirs then + configdirs = os.getenv("PKG_CONFIG_PATH") + os.addenv("PKG_CONFIG_PATH", unpack(table.wrap(opt.configdirs))) + end + -- get libs and cflags local result = nil local flags = try { function () return os.iorunv(pkg_config, {"--libs", "--cflags", name}) end } @@ -92,6 +99,11 @@ function info(name, opt) end end + -- restore PKG_CONFIG_PATH + if configdirs then + os.setenv("PKG_CONFIG_PATH", configdirs) + end + -- ok? return result end -- cgit v1.3.1