@@ -366,6 +366,14 @@ function _get_mingw32_make(package)
366
366
end
367
367
end
368
368
369
+ -- get ninja
370
+ function _get_ninja (package )
371
+ local ninja = find_tool (" ninja" )
372
+ if ninja then
373
+ return ninja .program
374
+ end
375
+ end
376
+
369
377
-- https://github.com/xmake-io/xmake-repo/pull/1096
370
378
function _fix_cxx_compiler_cmake (package , envs )
371
379
local cxx = envs .CMAKE_CXX_COMPILER
@@ -601,10 +609,17 @@ function _get_configs_for_wasm(package, configs, opt)
601
609
local emscripten_cmakefile = find_file (" Emscripten.cmake" , path .join (emsdk .emscripten , " cmake/Modules/Platform" ))
602
610
assert (emscripten_cmakefile , " Emscripten.cmake not found!" )
603
611
table.insert (configs , " -DCMAKE_TOOLCHAIN_FILE=" .. emscripten_cmakefile )
604
- if is_subhost (" windows" ) and opt .cmake_generator ~= " Ninja" then
605
- local mingw_make = _get_mingw32_make (package )
606
- if mingw_make then
607
- table.insert (configs , " -DCMAKE_MAKE_PROGRAM=" .. mingw_make )
612
+ if is_subhost (" windows" ) then
613
+ if opt .cmake_generator == " Ninja" then
614
+ local ninja = _get_ninja (package )
615
+ if ninja then
616
+ table.insert (configs , " -DCMAKE_MAKE_PROGRAM=" .. ninja )
617
+ end
618
+ else
619
+ local mingw_make = _get_mingw32_make (package )
620
+ if mingw_make then
621
+ table.insert (configs , " -DCMAKE_MAKE_PROGRAM=" .. mingw_make )
622
+ end
608
623
end
609
624
end
610
625
_get_configs_for_generic (package , configs , opt )
@@ -757,15 +772,8 @@ function _get_configs_for_generator(package, configs, opt)
757
772
table.insert (configs , " -G" )
758
773
table.insert (configs , _get_cmake_generator_for_msvc (package ))
759
774
elseif package :is_plat (" wasm" ) and is_subhost (" windows" ) then
760
- -- we attempt to use ninja if it exist
761
- -- @see https://github.com/xmake-io/xmake/issues/3771
762
775
table.insert (configs , " -G" )
763
- if find_tool (" ninja" ) then
764
- table.insert (configs , " Ninja" )
765
- opt .cmake_generator = " Ninja"
766
- else
767
- table.insert (configs , " MinGW Makefiles" )
768
- end
776
+ table.insert (configs , " MinGW Makefiles" )
769
777
else
770
778
table.insert (configs , " -G" )
771
779
table.insert (configs , " Unix Makefiles" )
@@ -1142,9 +1150,9 @@ function _get_cmake_generator(package, opt)
1142
1150
if not cmake_generator then
1143
1151
if package :has_tool (" cc" , " clang_cl" ) or package :has_tool (" cxx" , " clang_cl" ) then
1144
1152
cmake_generator = " Ninja"
1145
- elseif is_subhost (" windows" ) and package :is_plat (" mingw" ) then
1146
- local mingw_make = _get_mingw32_make (package )
1147
- if not mingw_make and find_tool ( " ninja" ) then
1153
+ elseif is_subhost (" windows" ) and package :is_plat (" mingw" , " wasm " ) then
1154
+ local ninja = _get_ninja (package )
1155
+ if ninja then
1148
1156
cmake_generator = " Ninja"
1149
1157
end
1150
1158
end
0 commit comments