summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-01-10 00:23:32 +0800
committerGitHub <[email protected]>2022-01-10 00:23:32 +0800
commitb8026df6e9788100fc7ae4a3facc148b0500b9fc (patch)
treed4da47f81d9acd6e026a19135a2d35118a30748e
parent2431dd7e6142ff98b55741cfd4de4d2e69f4f8b5 (diff)
parenta9590e436e0054e2ee9b952f3d0f1f2310c6f002 (diff)
Merge pull request #1967 from fasiondog/master
Improve cmake_build, supports the specified config and target
-rw-r--r--xmake/modules/package/tools/cmake.lua18
1 files 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