From 9aa0516630fbd4d6d5bdf0fe4a704b86a53350c8 Mon Sep 17 00:00:00 2001 From: star9029 Date: Tue, 26 Nov 2024 20:00:50 +0800 Subject: fix cmake & mingw detect cross-compilation on windows --- xmake/modules/package/tools/cmake.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index ca01fe11a..7f2a3d397 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -580,7 +580,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_MODULE_LINKER_FLAGS = _get_shflags(package, opt) - envs.CMAKE_SYSTEM_NAME = "Windows" + envs.CMAKE_SYSTEM_NAME = is_host("windows") and "" or "Windows" 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 -- cgit v1.3.1 From 3bafa9480911717fd9ee49cd48e02c7c7020bc5d Mon Sep 17 00:00:00 2001 From: star9029 Date: Tue, 26 Nov 2024 21:07:47 +0800 Subject: improve mingw CMAKE_SYSTEM_NAME --- xmake/modules/package/tools/cmake.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index 7f2a3d397..0d624522c 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -580,7 +580,10 @@ 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 = is_host("windows") and "" or "Windows" + -- @see https://cmake.org/cmake/help/latest/variable/CMAKE_CROSSCOMPILING.html + 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 +951,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 -- cgit v1.3.1 From cd3b327d4e15c79a64e749c5b04ecb5e93dd06a7 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 26 Nov 2024 21:12:03 +0800 Subject: Update cmake.lua --- xmake/modules/package/tools/cmake.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index 0d624522c..6d7f15dce 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -581,6 +581,7 @@ function _get_configs_for_mingw(package, configs, opt) envs.CMAKE_SHARED_LINKER_FLAGS = _get_shflags(package, opt) envs.CMAKE_MODULE_LINKER_FLAGS = _get_shflags(package, opt) -- @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 -- cgit v1.3.1