summaryrefslogtreecommitdiff
path: root/xmake/modules/package/manager/find_package.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2024-04-11 00:53:07 +0800
committerruki <[email protected]>2024-04-11 00:53:07 +0800
commitdec2cf143065520452917393ecf28d7479f026c4 (patch)
treec4684bcaca8e454558c2d4d9e9459286edb12e06 /xmake/modules/package/manager/find_package.lua
parent6bf4a28541f4a785db59fdd7bc62c3b2ede4017f (diff)
improve to fetch package for cross-compilation #4935
Diffstat (limited to 'xmake/modules/package/manager/find_package.lua')
-rw-r--r--xmake/modules/package/manager/find_package.lua27
1 files changed, 7 insertions, 20 deletions
diff --git a/xmake/modules/package/manager/find_package.lua b/xmake/modules/package/manager/find_package.lua
index 82f029c34..022e92511 100644
--- a/xmake/modules/package/manager/find_package.lua
+++ b/xmake/modules/package/manager/find_package.lua
@@ -23,6 +23,7 @@ import("core.base.semver")
import("core.base.option")
import("core.project.config")
import("lib.detect.find_tool")
+import("private.core.base.is_cross")
-- Is the current version matched?
function _is_match_version(current_version, require_version)
@@ -53,37 +54,23 @@ function _find_package_with_builtin_rule(package_name, opt)
-- find system package if be not disabled
if opt.system ~= false then
-
- -- find it from homebrew
- if not is_host("windows") then
+ local plat = opt.plat
+ local arch = opt.arch
+ local find_from_host = not is_cross(plat, arch)
+ if find_from_host and not is_host("windows") then
table.insert(managers, "brew")
end
-
- -- find it from vcpkg (support multi-platforms/architectures)
+ -- vcpkg/conan support multi-platforms/architectures
table.insert(managers, "vcpkg")
-
- -- find it from conan (support multi-platforms/architectures)
table.insert(managers, "conan")
-
- -- only support the current sub-host platform and sub-architecture, e.g. linux, macosx, or msys (subsystem)
- local plat = opt.plat
- local arch = opt.arch
- if plat == os.subhost() and arch == os.subarch() then
-
- -- find it from pkg-config
+ if find_from_host then
table.insert(managers, "pkgconfig")
-
- -- find it from pacman
if is_subhost("linux", "msys") and plat ~= "windows" and find_tool("pacman") then
table.insert(managers, "pacman")
end
-
- -- find it from portage
if is_subhost("linux", "msys") and plat ~= "windows" and find_tool("emerge") then
table.insert(managers, "portage")
end
-
- -- find it from system
table.insert(managers, "system")
end
end