summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-11-26 22:42:56 +0800
committerGitHub <[email protected]>2024-11-26 22:42:56 +0800
commitf4599d3129cf4025174a58e20c9402687e73bb78 (patch)
tree2306c694490f7f5d362829dfe6aead548be20cb9
parent3276686e4d2356dab029d94ada8f780e0702889a (diff)
parentcd3b327d4e15c79a64e749c5b04ecb5e93dd06a7 (diff)
Merge pull request #5888 from star-hengxing/cmake-mingw
fix cmake & mingw detect cross-compilation on windows
-rw-r--r--xmake/modules/package/tools/cmake.lua13
1 files changed, 12 insertions, 1 deletions
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua
index ca01fe11a..6d7f15dce 100644
--- a/xmake/modules/package/tools/cmake.lua
+++ b/xmake/modules/package/tools/cmake.lua
@@ -580,7 +580,11 @@ 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_MODULE_LINKER_FLAGS = _get_shflags(package, opt)
- envs.CMAKE_SYSTEM_NAME = "Windows"
+ -- @see https://cmake.org/cmake/help/latest/variable/CMAKE_CROSSCOMPILING.html
+ -- https://github.com/xmake-io/xmake/pull/5888
+ if not is_host("windows") then
+ envs.CMAKE_SYSTEM_NAME = "Windows"
+ end
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
@@ -948,6 +952,13 @@ function _get_configs(package, configs, opt)
end
end
_insert_configs_from_envs(configs, envs or {}, opt)
+
+ local ccache = package:data("ccache")
+ if ccache then
+ table.insert(configs, "-DCMAKE_C_COMPILER_LAUNCHER=" .. ccache)
+ table.insert(configs, "-DCMAKE_CXX_COMPILER_LAUNCHER=" .. ccache)
+ end
+
return configs
end