summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-08-29 23:14:01 +0800
committerGitHub <[email protected]>2024-08-29 23:14:01 +0800
commit7336c8a5459d105febde0a2f43c02502bce30fc7 (patch)
tree3b726d95b03e3ab04c9ee14dc40ea07f82d4c375
parentd2476ab94d82b7c2cc1c80b1d1ce81b716b155dc (diff)
parente432b35f84dcfa2daad137a0fbb96d22ad48af04 (diff)
Merge pull request #5534 from Chi-EEE/windows-wasm
fix windows wasm compilation with packages
-rw-r--r--xmake/modules/package/tools/cmake.lua38
1 files changed, 23 insertions, 15 deletions
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua
index 99dfe0436..7d5550390 100644
--- a/xmake/modules/package/tools/cmake.lua
+++ b/xmake/modules/package/tools/cmake.lua
@@ -366,6 +366,14 @@ function _get_mingw32_make(package)
end
end
+-- get ninja
+function _get_ninja(package)
+ local ninja = find_tool("ninja")
+ if ninja then
+ return ninja.program
+ end
+end
+
-- https://github.com/xmake-io/xmake-repo/pull/1096
function _fix_cxx_compiler_cmake(package, envs)
local cxx = envs.CMAKE_CXX_COMPILER
@@ -601,10 +609,17 @@ function _get_configs_for_wasm(package, configs, opt)
local emscripten_cmakefile = find_file("Emscripten.cmake", path.join(emsdk.emscripten, "cmake/Modules/Platform"))
assert(emscripten_cmakefile, "Emscripten.cmake not found!")
table.insert(configs, "-DCMAKE_TOOLCHAIN_FILE=" .. emscripten_cmakefile)
- if is_subhost("windows") and opt.cmake_generator ~= "Ninja" then
- local mingw_make = _get_mingw32_make(package)
- if mingw_make then
- table.insert(configs, "-DCMAKE_MAKE_PROGRAM=" .. mingw_make)
+ if is_subhost("windows") then
+ if opt.cmake_generator == "Ninja" then
+ local ninja = _get_ninja(package)
+ if ninja then
+ table.insert(configs, "-DCMAKE_MAKE_PROGRAM=" .. ninja)
+ end
+ else
+ local mingw_make = _get_mingw32_make(package)
+ if mingw_make then
+ table.insert(configs, "-DCMAKE_MAKE_PROGRAM=" .. mingw_make)
+ end
end
end
_get_configs_for_generic(package, configs, opt)
@@ -757,15 +772,8 @@ function _get_configs_for_generator(package, configs, opt)
table.insert(configs, "-G")
table.insert(configs, _get_cmake_generator_for_msvc(package))
elseif package:is_plat("wasm") and is_subhost("windows") then
- -- we attempt to use ninja if it exist
- -- @see https://github.com/xmake-io/xmake/issues/3771
table.insert(configs, "-G")
- if find_tool("ninja") then
- table.insert(configs, "Ninja")
- opt.cmake_generator = "Ninja"
- else
- table.insert(configs, "MinGW Makefiles")
- end
+ table.insert(configs, "MinGW Makefiles")
else
table.insert(configs, "-G")
table.insert(configs, "Unix Makefiles")
@@ -1142,9 +1150,9 @@ function _get_cmake_generator(package, opt)
if not cmake_generator then
if package:has_tool("cc", "clang_cl") or package:has_tool("cxx", "clang_cl") then
cmake_generator = "Ninja"
- elseif is_subhost("windows") and package:is_plat("mingw") then
- local mingw_make = _get_mingw32_make(package)
- if not mingw_make and find_tool("ninja") then
+ elseif is_subhost("windows") and package:is_plat("mingw", "wasm") then
+ local ninja = _get_ninja(package)
+ if ninja then
cmake_generator = "Ninja"
end
end