Skip to content

Commit 62d5480

Browse files
committed
improve cmake for ninja
1 parent 014838d commit 62d5480

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

xmake/modules/package/tools/cmake.lua

+10-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,11 @@ 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+
print("_get_configs_for_generator", cmake_generator, ninja)
780+
if ninja then
781+
table.insert(configs, "-DCMAKE_MAKE_PROGRAM=" .. ninja)
782+
end
786783
end
787784
elseif package:is_plat("mingw") and is_subhost("msys") then
788785
table.insert(configs, "-G")
@@ -964,6 +961,7 @@ function _get_configs(package, configs, opt)
964961
table.insert(configs, "-DCMAKE_CXX_COMPILER_LAUNCHER=" .. ccache)
965962
end
966963

964+
print("configs", configs)
967965
return configs
968966
end
969967

@@ -1312,13 +1310,16 @@ function configure(package, configs, opt)
13121310
table.insert(argv, "-D" .. name .. "=" .. value)
13131311
end
13141312
end
1313+
print("before shrink", argv)
13151314
-- shrink cmake arguments, fix too long arguments
13161315
-- @see https://github.com/xmake-io/xmake-repo/pull/5247#discussion_r1780302212
13171316
_shrink_cmake_arguments(argv, oldir, opt)
13181317
table.insert(argv, oldir)
13191318

13201319
-- do configure
13211320
local cmake = assert(find_tool("cmake"), "cmake not found!")
1321+
print(argv)
1322+
print(package:name(), package:plat(), package:arch(), opt)
13221323
os.vrunv(cmake.program, argv, {envs = opt.envs or buildenvs(package, opt)})
13231324
os.cd(oldir)
13241325
end

0 commit comments

Comments
 (0)