diff options
| author | ruki <[email protected]> | 2017-06-12 23:15:52 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-06-12 23:15:52 +0800 |
| commit | 0fc304af564ce6215df38fbda571d3ee204e585d (patch) | |
| tree | f410caa7920fe822204cb84659bbea4cde21ef2a /xmake/modules/lib/detect/pkg_config.lua | |
| parent | fe5c0e9a6b99ae6ad3ab7ab24d50018fe1c8442d (diff) | |
use brew to improve find_package()
Diffstat (limited to 'xmake/modules/lib/detect/pkg_config.lua')
| -rw-r--r-- | xmake/modules/lib/detect/pkg_config.lua | 14 |
1 files changed, 13 insertions, 1 deletions
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 |
