Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cmake & mingw detect cross-compilation on windows #5888

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion xmake/modules/package/tools/cmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
star-hengxing marked this conversation as resolved.
Show resolved Hide resolved

return configs
end

Expand Down
Loading