Skip to content

Commit

Permalink
improve tools.cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Jul 20, 2024
1 parent 84d48dc commit 2412ed9
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions xmake/modules/package/tools/cmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,17 @@ function _get_configs(package, configs, opt)
return configs
end

-- Fix pdb issue, if multiple CL.EXE write to the same .PDB file, please use /FS
-- @see https://github.com/xmake-io/xmake/issues/5353
function _fix_pdbdir_for_ninja(package)
if package:is_plat("windows") and package:has_tool("cxx", "cl") then
local pdbdir = "pdb"
if not os.isdir(pdbdir) then
os.mkdir(pdbdir)
end
end
end

-- get build environments
function buildenvs(package, opt)

Expand Down Expand Up @@ -979,14 +990,7 @@ end
-- do build for ninja
function _build_for_ninja(package, configs, opt)
opt = opt or {}
-- Fix pdb issue, if multiple CL.EXE write to the same .PDB file, please use /FS
-- @see https://github.com/xmake-io/xmake/issues/5353
if package:is_plat("windows") and package:has_tool("cxx", "cl") then
local pdbdir = "pdb"
if not os.isdir(pdbdir) then
os.mkdir(pdbdir)
end
end
_fix_pdbdir_for_ninja(package)
ninja.build(package, {}, {envs = opt.envs or buildenvs(package, opt),
jobs = opt.jobs,
target = opt.target})
Expand Down Expand Up @@ -1071,14 +1075,7 @@ end
-- do install for ninja
function _install_for_ninja(package, configs, opt)
opt = opt or {}
-- Fix pdb issue, if multiple CL.EXE write to the same .PDB file, please use /FS
-- @see https://github.com/xmake-io/xmake/issues/5353
if package:is_plat("windows") and package:has_tool("cxx", "cl") then
local pdbdir = "pdb"
if not os.isdir(pdbdir) then
os.mkdir(pdbdir)
end
end
_fix_pdbdir_for_ninja(package)
ninja.install(package, {}, {envs = opt.envs or buildenvs(package, opt),
jobs = opt.jobs,
target = opt.target})
Expand Down

0 comments on commit 2412ed9

Please sign in to comment.