summaryrefslogtreecommitdiff
path: root/xmake/modules/package/manager/conan/find_package.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/modules/package/manager/conan/find_package.lua')
-rw-r--r--xmake/modules/package/manager/conan/find_package.lua34
1 files changed, 31 insertions, 3 deletions
diff --git a/xmake/modules/package/manager/conan/find_package.lua b/xmake/modules/package/manager/conan/find_package.lua
index ca39a2f12..8c3541866 100644
--- a/xmake/modules/package/manager/conan/find_package.lua
+++ b/xmake/modules/package/manager/conan/find_package.lua
@@ -27,10 +27,30 @@ import("core.base.option")
import("core.project.config")
-- get build info file
-function _get_buildinfo_file(name)
+function _conan_get_buildinfo_file(name)
return path.absolute(path.join(config.buildir() or os.tmpdir(), ".conan", name, "conanbuildinfo.xmake.lua"))
end
+-- get conan platform
+function _conan_get_plat(opt)
+ local plats = {macosx = "Macos", windows = "Windows", linux = "Linux"}
+ return plats[opt.plat]
+end
+
+-- get conan architecture
+function _conan_get_arch(opt)
+ if opt.plat == "windows" then
+ return opt.arch == "x64" and "x86_64" or "x86"
+ else
+ return opt.arch == "i386" and "x86" or opt.arch
+ end
+end
+
+-- get conan mode
+function _conan_get_mode(opt)
+ return opt.mode == "debug" and "Debug" or "Release"
+end
+
-- find package using the conan package manager
--
-- @param name the package name
@@ -39,7 +59,7 @@ end
function main(name, opt)
-- get the build info
- local buildinfo_file = _get_buildinfo_file(name)
+ local buildinfo_file = _conan_get_buildinfo_file(name)
if not os.isfile(buildinfo_file) then
return
end
@@ -47,10 +67,18 @@ function main(name, opt)
-- load build info
local buildinfo = io.load(buildinfo_file)
+ -- get platform, architecture and mode
+ local plat = _conan_get_plat(opt)
+ local arch = _conan_get_arch(opt)
+ local mode = _conan_get_mode(opt)
+ if not plat and not arch and not mode then
+ return
+ end
+
-- get the package info of the given platform, architecture and mode
local found = false
local result = {}
- for k, v in pairs(buildinfo[opt.plat .. "_" .. opt.arch .. "_" .. opt.mode]) do
+ for k, v in pairs(buildinfo[plat .. "_" .. arch .. "_" .. mode]) do
if #table.wrap(v) > 0 then
result[k] = v
found = true