From a9590e436e0054e2ee9b952f3d0f1f2310c6f002 Mon Sep 17 00:00:00 2001 From: fasiondog Date: Sun, 9 Jan 2022 23:07:48 +0800 Subject: Improve cmake_build, supports the specified config and target --- xmake/modules/package/tools/cmake.lua | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index f49cedf0b..4e2662604 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -593,7 +593,16 @@ end -- do build for cmake/build function _build_for_cmakebuild(package, configs, opt) local cmake = assert(find_tool("cmake"), "cmake not found!") - os.vrunv(cmake.program, {"--build", os.curdir()}, {envs = opt.envs or buildenvs(package)}) + local argv = {"--build", os.curdir()} + if opt.config then + table.insert(argv, "--config") + table.insert(argv, opt.config) + end + if opt.target then + table.insert(argv, "--target") + table.insert(argv, opt.target) + end + os.vrunv(cmake.program, argv, {envs = opt.envs or buildenvs(package)}) end -- do install for msvc @@ -662,7 +671,12 @@ end function _install_for_cmakebuild(package, configs, opt) opt = opt or {} local cmake = assert(find_tool("cmake"), "cmake not found!") - os.vrunv(cmake.program, {"--build", os.curdir()}, {envs = opt.envs or buildenvs(package)}) + local argv = {"--build", os.curdir()} + if opt.config then + table.insert(argv, "--config") + table.insert(argv, opt.config) + end + os.vrunv(cmake.program, argv, {envs = opt.envs or buildenvs(package)}) os.vrunv(cmake.program, {"--install", os.curdir()}) end -- cgit v1.3.1