@@ -1002,12 +1002,13 @@ end
1002
1002
-- do build for make
1003
1003
function _build_for_make (package , configs , opt )
1004
1004
local argv = {}
1005
- if opt .target then
1006
- table.insert (argv , opt .target )
1005
+ local target = table .wrap (opt .target )
1006
+ if # target ~= 0 then
1007
+ table .join2 (argv , target )
1007
1008
end
1008
1009
local jobs = _get_parallel_njobs (opt )
1009
1010
table.insert (argv , " -j" .. jobs )
1010
- if option .get (" diagnosis " ) then
1011
+ if option .get (" verbose " ) then
1011
1012
table.insert (argv , " VERBOSE=1" )
1012
1013
end
1013
1014
if is_host (" bsd" ) then
@@ -1047,9 +1048,19 @@ function _build_for_cmakebuild(package, configs, opt)
1047
1048
table.insert (argv , " --config" )
1048
1049
table.insert (argv , opt .config )
1049
1050
end
1050
- if opt .target then
1051
+ local target = table .wrap (opt .target )
1052
+ if # target ~= 0 then
1051
1053
table.insert (argv , " --target" )
1052
- table.insert (argv , opt .target )
1054
+ if # target > 1 then
1055
+ -- https://stackoverflow.com/questions/47553569/how-can-i-build-multiple-targets-using-cmake-build
1056
+ if _get_cmake_version ():ge (" 3.15" ) then
1057
+ table .join2 (argv , target )
1058
+ else
1059
+ raise (" Build multiple targets need cmake >=3.15" )
1060
+ end
1061
+ else
1062
+ table.insert (argv , target [1 ])
1063
+ end
1053
1064
end
1054
1065
os .vrunv (cmake .program , argv , {envs = opt .envs or buildenvs (package )})
1055
1066
end
@@ -1082,7 +1093,7 @@ end
1082
1093
function _install_for_make (package , configs , opt )
1083
1094
local jobs = _get_parallel_njobs (opt )
1084
1095
local argv = {" -j" .. jobs }
1085
- if option .get (" diagnosis " ) then
1096
+ if option .get (" verbose " ) then
1086
1097
table.insert (argv , " VERBOSE=1" )
1087
1098
end
1088
1099
if is_host (" bsd" ) then
@@ -1160,10 +1171,8 @@ function _get_cmake_generator(package, opt)
1160
1171
return cmake_generator
1161
1172
end
1162
1173
1163
- -- build package
1164
- function build (package , configs , opt )
1174
+ function configure (package , configs , opt )
1165
1175
opt = opt or {}
1166
- local cmake_generator = _get_cmake_generator (package , opt )
1167
1176
1168
1177
-- enter build directory
1169
1178
local buildir = opt .buildir or package :buildir ()
@@ -1188,6 +1197,15 @@ function build(package, configs, opt)
1188
1197
local cmake = assert (find_tool (" cmake" ), " cmake not found!" )
1189
1198
os .vrunv (cmake .program , argv , {envs = opt .envs or buildenvs (package , opt )})
1190
1199
1200
+ return oldir
1201
+ end
1202
+
1203
+ -- build package
1204
+ function build (package , configs , opt )
1205
+ opt = opt or {}
1206
+ local cmake_generator = _get_cmake_generator (package , opt )
1207
+ local oldir = configure (package , configs , opt )
1208
+
1191
1209
-- do build
1192
1210
if opt .cmake_build then
1193
1211
_build_for_cmakebuild (package , configs , opt )
@@ -1215,29 +1233,7 @@ end
1215
1233
function install (package , configs , opt )
1216
1234
opt = opt or {}
1217
1235
local cmake_generator = _get_cmake_generator (package , opt )
1218
-
1219
- -- enter build directory
1220
- local buildir = opt .buildir or package :buildir ()
1221
- os .mkdir (path .join (buildir , " install" ))
1222
- local oldir = os .cd (buildir )
1223
-
1224
- -- pass configurations
1225
- local argv = {}
1226
- for name , value in pairs (_get_configs (package , configs , opt )) do
1227
- value = tostring (value ):trim ()
1228
- if type (name ) == " number" then
1229
- if value ~= " " then
1230
- table.insert (argv , value )
1231
- end
1232
- else
1233
- table.insert (argv , " -D" .. name .. " =" .. value )
1234
- end
1235
- end
1236
- table.insert (argv , oldir )
1237
-
1238
- -- generate build file
1239
- local cmake = assert (find_tool (" cmake" ), " cmake not found!" )
1240
- os .vrunv (cmake .program , argv , {envs = opt .envs or buildenvs (package , opt )})
1236
+ local oldir = configure (package , configs , opt )
1241
1237
1242
1238
-- do build and install
1243
1239
if opt .cmake_build then
0 commit comments