summaryrefslogtreecommitdiff
path: root/xmake/modules/package/tools/cmake.lua
diff options
context:
space:
mode:
authorJérôme Leclercq <[email protected]>2024-06-15 11:46:59 +0200
committerGitHub <[email protected]>2024-06-15 11:46:59 +0200
commitb282d7fbe2f02f1d1433df874f919c997d960505 (patch)
treeeb163a07213c20b1241d7ba940c6a74b2b0722b4 /xmake/modules/package/tools/cmake.lua
parent3f7664af3d3681a4cb51dc08acb1b7439dd2ffaa (diff)
Add _get_cmake_system_processor
Diffstat (limited to 'xmake/modules/package/tools/cmake.lua')
-rw-r--r--xmake/modules/package/tools/cmake.lua20
1 files changed, 18 insertions, 2 deletions
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua
index ad87294b0..20a425868 100644
--- a/xmake/modules/package/tools/cmake.lua
+++ b/xmake/modules/package/tools/cmake.lua
@@ -288,6 +288,22 @@ function _get_cmake_version()
return cmake_version
end
+function _get_cmake_system_processor(package)
+ -- on Windows, CMAKE_SYSTEM_PROCESSOR comes from PROCESSOR_ARCHITECTURE
+ -- on other systems it's the output of uname -m
+ if package:is_plat("windows") then
+ local archs = {
+ x86 = "x86",
+ x64 = "AMD64"
+ x86_64 = "AMD64",
+ arm = "ARM",
+ arm64 = "ARM64"
+ }
+ return archs[package:arch()] or package:arch()
+ end
+ return package:arch()
+end
+
-- insert configs from envs
function _insert_configs_from_envs(configs, envs, opt)
opt = opt or {}
@@ -437,7 +453,7 @@ function _get_configs_for_appleos(package, configs, opt)
end
elseif package:is_cross() then
envs.CMAKE_SYSTEM_NAME = "Darwin"
- envs.CMAKE_SYSTEM_PROCESSOR = package:targetarch()
+ envs.CMAKE_SYSTEM_PROCESSOR = _get_cmake_system_processor(package)
end
envs.CMAKE_OSX_ARCHITECTURES = package:arch()
envs.CMAKE_FIND_ROOT_PATH_MODE_PACKAGE = "BOTH"
@@ -469,7 +485,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()
+ envs.CMAKE_SYSTEM_PROCESSOR = _get_cmake_system_processor(package)
-- avoid find and add system include/library path
-- @see https://github.com/xmake-io/xmake/issues/2037
envs.CMAKE_FIND_ROOT_PATH = sdkdir