summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérôme Leclercq <[email protected]>2024-06-13 12:56:15 +0200
committerGitHub <[email protected]>2024-06-13 12:56:15 +0200
commitf02020239331bc6665bdfa77211dce1453aa005a (patch)
treea2a2746434d45f7d877b054978c3f0ea9685502a
parent33f3078f4dc7f1f804c91a3d0e30f61bd5f75d02 (diff)
cmake: set CMAKE_SYSTEM_PROCESSOR when cross-compiling
-rw-r--r--xmake/modules/package/tools/cmake.lua8
1 files changed, 5 insertions, 3 deletions
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua
index 03cc3f665..4c6898bd7 100644
--- a/xmake/modules/package/tools/cmake.lua
+++ b/xmake/modules/package/tools/cmake.lua
@@ -435,8 +435,9 @@ function _get_configs_for_appleos(package, configs, opt)
if package:is_arch("x86_64", "i386") then
envs.CMAKE_OSX_SYSROOT = "iphonesimulator"
end
- elseif package:is_plat("macosx") then
+ elseif _is_cross_compilation() then
envs.CMAKE_SYSTEM_NAME = "Darwin"
+ envs.CMAKE_SYSTEM_PROCESSOR = package:targetarch()
end
envs.CMAKE_OSX_ARCHITECTURES = package:arch()
envs.CMAKE_FIND_ROOT_PATH_MODE_PACKAGE = "BOTH"
@@ -468,6 +469,7 @@ function _get_configs_for_mingw(package, configs, opt)
envs.CMAKE_EXE_LINKER_FLAGS = _get_ldflags(package, opt)
envs.CMAKE_SHARED_LINKER_FLAGS = _get_shflags(package, opt)
envs.CMAKE_SYSTEM_NAME = "Windows"
+ envs.CMAKE_SYSTEM_PROCESSOR = package:targetarch()
-- avoid find and add system include/library path
-- @see https://github.com/xmake-io/xmake/issues/2037
envs.CMAKE_FIND_ROOT_PATH = sdkdir
@@ -552,7 +554,7 @@ function _get_configs_for_cross(package, configs, opt)
envs.CMAKE_SHARED_LINKER_FLAGS = _get_shflags(package, opt)
-- we don't need to set it as cross compilation if we just pass toolchain
-- https://github.com/xmake-io/xmake/issues/2170
- if not package:is_plat(os.subhost()) then
+ if _is_cross_compilation() then
local system_name = package:targetos() or "Linux"
if system_name == "linux" then
system_name = "Linux"
@@ -628,7 +630,7 @@ function _get_configs_for_host_toolchain(package, configs, opt)
envs.CMAKE_SHARED_LINKER_FLAGS = _get_shflags(package, opt)
-- we don't need to set it as cross compilation if we just pass toolchain
-- https://github.com/xmake-io/xmake/issues/2170
- if not package:is_plat(os.subhost()) then
+ if _is_cross_compilation() then
envs.CMAKE_SYSTEM_NAME = "Linux"
else
if package:config("pic") ~= false then