summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-12-13 00:47:10 +0800
committerruki <[email protected]>2018-12-12 22:43:03 +0800
commit11d0bbaebf5804d331ffa126ec0dab21913dad15 (patch)
tree1cc1c6f839e7d19174dae3c51d72a016efebcd5e
parent8342e3aa500138d13b04b081c974eee89a33ed83 (diff)
improve cmake tool
-rw-r--r--xmake/modules/package/tools/cmake.lua21
1 files changed, 13 insertions, 8 deletions
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua
index 3cf548d0a..26ec111ed 100644
--- a/xmake/modules/package/tools/cmake.lua
+++ b/xmake/modules/package/tools/cmake.lua
@@ -28,28 +28,33 @@ import("lib.detect.find_file")
-- install package
function install(package, configs)
+
+ -- enter build directory
os.mkdir("build/install")
local oldir = os.cd("build")
- local argv = {
- "-DCMAKE_INSTALL_PREFIX=\"" .. path.absolute("install") .. "\""
- }
-
+ -- init arguments
+ local argv = {"-DCMAKE_INSTALL_PREFIX=\"" .. path.absolute("install") .. "\""}
if is_plat("windows") and is_arch("x64") then
table.insert(argv, "-A")
table.insert(argv, "x64")
end
-
for name, value in pairs(configs) do
value = tostring(value):trim()
- if value ~= "" then
- table.insert(argv, value)
+ if type(name) == "number" then
+ if value ~= "" then
+ table.insert(argv, value)
+ end
+ else
+ table.insert(argv, "--" .. name .. "=" .. value)
end
end
-
table.insert(argv, '..')
+
+ -- generate build file
os.vrunv("cmake", argv)
+ -- do build and install
if is_host("windows") then
local slnfile = assert(find_file("*.sln", os.curdir()), "*.sln file not found!")
os.vrun("msbuild \"%s\" -nologo -t:Rebuild -p:Configuration=%s -p:Platform=%s", slnfile, package:debug() and "Debug" or "Release", is_arch("x64") and "x64" or "Win32")