Skip to content

Commit 63c0cd0

Browse files
committed
add _get_ninja(package), remove _get_configs_for_generator in install
1 parent 09f4c71 commit 63c0cd0

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

xmake/modules/package/tools/cmake.lua

+12-6
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,13 @@ function _get_mingw32_make(package)
366366
end
367367
end
368368

369+
-- get ninja
370+
function _get_ninja(package)
371+
local ninja = find_tool("ninja")
372+
assert(ninja, "ninja not found!")
373+
return ninja.program
374+
end
375+
369376
-- https://github.com/xmake-io/xmake-repo/pull/1096
370377
function _fix_cxx_compiler_cmake(package, envs)
371378
local cxx = envs.CMAKE_CXX_COMPILER
@@ -608,9 +615,10 @@ function _get_configs_for_wasm(package, configs, opt)
608615
table.insert(configs, "-DCMAKE_MAKE_PROGRAM=" .. mingw_make)
609616
end
610617
else
611-
local ninja = find_tool("ninja")
612-
assert(ninja, "ninja not found!")
613-
table.insert(configs, "-DCMAKE_MAKE_PROGRAM=" .. ninja.program)
618+
local ninja = _get_ninja(package)
619+
if ninja then
620+
table.insert(configs, "-DCMAKE_MAKE_PROGRAM=" .. ninja)
621+
end
614622
end
615623
end
616624
_get_configs_for_generic(package, configs, opt)
@@ -768,7 +776,6 @@ function _get_configs_for_generator(package, configs, opt)
768776
table.insert(configs, "-G")
769777
if find_tool("ninja") then
770778
table.insert(configs, "Ninja")
771-
opt.cmake_generator = "Ninja"
772779
else
773780
table.insert(configs, "MinGW Makefiles")
774781
end
@@ -1148,7 +1155,7 @@ function _get_cmake_generator(package, opt)
11481155
if not cmake_generator then
11491156
if package:has_tool("cc", "clang_cl") or package:has_tool("cxx", "clang_cl") then
11501157
cmake_generator = "Ninja"
1151-
elseif is_subhost("windows") and package:is_plat("mingw") then
1158+
elseif is_subhost("windows") and (package:is_plat("mingw", "wasm")) then
11521159
local mingw_make = _get_mingw32_make(package)
11531160
if not mingw_make and find_tool("ninja") then
11541161
cmake_generator = "Ninja"
@@ -1220,7 +1227,6 @@ end
12201227
-- install package
12211228
function install(package, configs, opt)
12221229
opt = opt or {}
1223-
_get_configs_for_generator(package, configs, opt)
12241230

12251231
local cmake_generator = _get_cmake_generator(package, opt)
12261232
-- enter build directory

0 commit comments

Comments
 (0)