summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-03-09 23:17:43 +0800
committerruki <[email protected]>2018-03-09 13:46:22 +0800
commit952efe5c652fae38a3d86ce9a4b0f81c6262726a (patch)
tree0136ee1fbf951a25966dc2af7e9be488bb19e55f
parenta6f86e9466987f5e14006245bb35cefc5339dfc0 (diff)
add cuda for linux
-rw-r--r--xmake/platforms/cross/xmake.lua1
-rw-r--r--xmake/platforms/linux/check.lua7
-rw-r--r--xmake/platforms/linux/load.lua13
-rw-r--r--xmake/platforms/linux/xmake.lua14
-rw-r--r--xmake/platforms/macosx/load.lua4
-rw-r--r--xmake/platforms/windows/xmake.lua11
6 files changed, 43 insertions, 7 deletions
diff --git a/xmake/platforms/cross/xmake.lua b/xmake/platforms/cross/xmake.lua
index c8fd0086a..e430bc22e 100644
--- a/xmake/platforms/cross/xmake.lua
+++ b/xmake/platforms/cross/xmake.lua
@@ -38,4 +38,3 @@ platform("cross")
on_load("load")
-
diff --git a/xmake/platforms/linux/check.lua b/xmake/platforms/linux/check.lua
index 7ecbb400f..f5d4c4359 100644
--- a/xmake/platforms/linux/check.lua
+++ b/xmake/platforms/linux/check.lua
@@ -145,6 +145,11 @@ function _toolchains(config)
checker.toolchain_insert(toolchains, "rc-sh", "", "rustc", "the rust shared library linker")
checker.toolchain_insert(toolchains, "rc-ld", "", "rustc", "the rust linker")
+ -- insert cuda tools to toolchains
+ checker.toolchain_insert(toolchains, "cu", "", "nvcc", "the cuda compiler")
+ checker.toolchain_insert(toolchains, "cu-sh", "", "nvcc", "the cuda shared library linker")
+ checker.toolchain_insert(toolchains, "cu-ld", "", "nvcc", "the cuda linker")
+
-- save toolchains
_g.TOOLCHAINS = toolchains
@@ -164,12 +169,14 @@ function main(kind, toolkind)
_g.config =
{
__check_arch
+ , checker.check_cuda_toolchains
}
-- init the check list of global
_g.global =
{
_check_ndk_sdkver
+ , checker.check_cuda_toolchains
}
-- check it
diff --git a/xmake/platforms/linux/load.lua b/xmake/platforms/linux/load.lua
index f821d89de..74ebe5640 100644
--- a/xmake/platforms/linux/load.lua
+++ b/xmake/platforms/linux/load.lua
@@ -75,6 +75,19 @@ function main()
_g["rc-shflags"] = {}
_g["rc-ldflags"] = {}
+ -- init flags for cuda
+ local cu_archs = { i386 = "-m32 -Xcompiler -arch -Xcompiler -m32", x86_64 = "-m64 -Xcompiler -arch -Xcompiler -m64" }
+ _g.cuflags = {cu_archs[arch] or ""}
+ _g["cu-shflags"] = {cu_archs[arch] or ""}
+ _g["cu-ldflags"] = {cu_archs[arch] or ""}
+ local cuda_dir = config.get("cuda_dir")
+ if cuda_dir then
+ table.insert(_g.cuflags, "-I" .. os.args(path.join(cuda_dir, "include")))
+ table.insert(_g["cu-ldflags"], "-L" .. os.args(path.join(cuda_dir, "lib")))
+ table.insert(_g["cu-shflags"], "-L" .. os.args(path.join(cuda_dir, "lib")))
+ table.insert(_g["cu-ldflags"], "-Wl,-rpath=" .. os.args(path.join(cuda_dir, "lib")))
+ end
+
-- ok
return _g
end
diff --git a/xmake/platforms/linux/xmake.lua b/xmake/platforms/linux/xmake.lua
index dacd0bf56..a5a96ad7c 100644
--- a/xmake/platforms/linux/xmake.lua
+++ b/xmake/platforms/linux/xmake.lua
@@ -46,5 +46,19 @@ platform("linux")
-- on load
on_load("load")
+ -- set menu
+ set_menu {
+ config =
+ {
+ {category = "Cuda SDK Configuration" }
+ , {nil, "cuda_dir", "kv", "auto", "The Cuda SDK Directory" }
+ }
+
+ , global =
+ {
+ {}
+ , {nil, "cuda_dir", "kv", "auto", "The Cuda SDK Directory" }
+ }
+ }
diff --git a/xmake/platforms/macosx/load.lua b/xmake/platforms/macosx/load.lua
index 35dabe581..34465029c 100644
--- a/xmake/platforms/macosx/load.lua
+++ b/xmake/platforms/macosx/load.lua
@@ -94,8 +94,8 @@ function main()
-- init flags for cuda
local cu_archs = { i386 = "-m32 -Xcompiler -arch -Xcompiler i386", x86_64 = "-m64 -Xcompiler -arch -Xcompiler x86_64" }
_g.cuflags = {cu_archs[arch] or ""}
- _g["cu-shflags"] = {"-ccbin", "clang++", cu_archs[arch] or ""}
- _g["cu-ldflags"] = {"-ccbin", "clang++", cu_archs[arch] or ""}
+ _g["cu-shflags"] = {cu_archs[arch] or ""}
+ _g["cu-ldflags"] = {cu_archs[arch] or ""}
local cuda_dir = config.get("cuda_dir")
if cuda_dir then
table.insert(_g.cuflags, "-I" .. os.args(path.join(cuda_dir, "include")))
diff --git a/xmake/platforms/windows/xmake.lua b/xmake/platforms/windows/xmake.lua
index dbcc42b80..abff4752d 100644
--- a/xmake/platforms/windows/xmake.lua
+++ b/xmake/platforms/windows/xmake.lua
@@ -83,14 +83,17 @@ platform("windows")
set_menu {
config =
{
- {category = "Visual Studio SDK Configuration" }
- , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio" }
+ {category = "Visual Studio SDK Configuration" }
+ , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio" }
+ , {category = "Cuda SDK Configuration" }
+ , {nil, "cuda_dir", "kv", "auto", "The Cuda SDK Directory" }
}
, global =
{
- { }
- , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio" }
+ { }
+ , {nil, "vs", "kv", "auto", "The Microsoft Visual Studio" }
+ , {nil, "cuda_dir", "kv", "auto", "The Cuda SDK Directory" }
}
}