Skip to content

Commit 3ee57aa

Browse files
committed
improve cmake configure
1 parent 7d2b492 commit 3ee57aa

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

xmake/modules/package/tools/cmake.lua

+14-11
Original file line numberDiff line numberDiff line change
@@ -1171,14 +1171,9 @@ function _get_cmake_generator(package, opt)
11711171
return cmake_generator
11721172
end
11731173

1174-
function configure(package, configs, opt)
1174+
function configure(package, configs, opt, sourcedir)
11751175
opt = opt or {}
11761176

1177-
-- enter build directory
1178-
local buildir = opt.buildir or package:buildir()
1179-
os.mkdir(path.join(buildir, "install"))
1180-
local oldir = os.cd(buildir)
1181-
11821177
-- pass configurations
11831178
local argv = {}
11841179
for name, value in pairs(_get_configs(package, configs, opt)) do
@@ -1191,20 +1186,23 @@ function configure(package, configs, opt)
11911186
table.insert(argv, "-D" .. name .. "=" .. value)
11921187
end
11931188
end
1194-
table.insert(argv, oldir)
1189+
table.insert(argv, sourcedir)
11951190

11961191
-- do configure
11971192
local cmake = assert(find_tool("cmake"), "cmake not found!")
11981193
os.vrunv(cmake.program, argv, {envs = opt.envs or buildenvs(package, opt)})
1199-
1200-
return oldir
12011194
end
12021195

12031196
-- build package
12041197
function build(package, configs, opt)
12051198
opt = opt or {}
12061199
local cmake_generator = _get_cmake_generator(package, opt)
1207-
local oldir = configure(package, configs, opt)
1200+
1201+
-- enter build directory
1202+
local buildir = opt.buildir or package:buildir()
1203+
os.mkdir(path.join(buildir, "install"))
1204+
local oldir = os.cd(buildir)
1205+
configure(package, configs, opt, oldir)
12081206

12091207
-- do build
12101208
if opt.cmake_build then
@@ -1233,7 +1231,12 @@ end
12331231
function install(package, configs, opt)
12341232
opt = opt or {}
12351233
local cmake_generator = _get_cmake_generator(package, opt)
1236-
local oldir = configure(package, configs, opt)
1234+
1235+
-- enter build directory
1236+
local buildir = opt.buildir or package:buildir()
1237+
os.mkdir(path.join(buildir, "install"))
1238+
local oldir = os.cd(buildir)
1239+
configure(package, configs, opt, oldir)
12371240

12381241
-- do build and install
12391242
if opt.cmake_build then

0 commit comments

Comments
 (0)