Skip to content

Commit 51a3bf4

Browse files
committed
improve cmake for ninja
1 parent 014838d commit 51a3bf4

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

xmake/modules/package/tools/cmake.lua

+7-9
Original file line numberDiff line numberDiff line change
@@ -601,9 +601,6 @@ function _get_configs_for_mingw(package, configs, opt)
601601
if is_subhost("windows") and opt.cmake_generator ~= "Ninja" then
602602
envs.CMAKE_MAKE_PROGRAM = _get_mingw32_make(package)
603603
end
604-
if opt.cmake_generator == "Ninja" then
605-
envs.CMAKE_MAKE_PROGRAM = "ninja"
606-
end
607604
_fix_cxx_compiler_cmake(package, envs)
608605
_insert_configs_from_envs(configs, envs, opt)
609606
end
@@ -618,12 +615,7 @@ function _get_configs_for_wasm(package, configs, opt)
618615
assert(emscripten_cmakefile, "Emscripten.cmake not found!")
619616
table.insert(configs, "-DCMAKE_TOOLCHAIN_FILE=" .. emscripten_cmakefile)
620617
if is_subhost("windows") then
621-
if opt.cmake_generator == "Ninja" then
622-
local ninja = _get_ninja(package)
623-
if ninja then
624-
table.insert(configs, "-DCMAKE_MAKE_PROGRAM=" .. ninja)
625-
end
626-
else
618+
if opt.cmake_generator ~= "Ninja" then
627619
local mingw_make = _get_mingw32_make(package)
628620
if mingw_make then
629621
table.insert(configs, "-DCMAKE_MAKE_PROGRAM=" .. mingw_make)
@@ -783,6 +775,10 @@ function _get_configs_for_generator(package, configs, opt)
783775
table.insert(configs, "-DCMAKE_JOB_POOL_LINK:STRING=link")
784776
table.insert(configs, ("-DCMAKE_JOB_POOLS:STRING=compile=%s;link=%s"):format(jobs, linkjobs))
785777
end
778+
local ninja = _get_ninja(package)
779+
if ninja then
780+
table.insert(configs, "-DCMAKE_MAKE_PROGRAM=" .. ninja)
781+
end
786782
end
787783
elseif package:is_plat("mingw") and is_subhost("msys") then
788784
table.insert(configs, "-G")
@@ -1319,6 +1315,8 @@ function configure(package, configs, opt)
13191315

13201316
-- do configure
13211317
local cmake = assert(find_tool("cmake"), "cmake not found!")
1318+
print(argv)
1319+
print(package:name(), opt)
13221320
os.vrunv(cmake.program, argv, {envs = opt.envs or buildenvs(package, opt)})
13231321
os.cd(oldir)
13241322
end

0 commit comments

Comments
 (0)