diff options
| author | ruki <[email protected]> | 2019-05-18 00:27:34 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-05-17 20:45:25 +0800 |
| commit | 9c464b2ebdf56f4da8202b419db18105e86d45e3 (patch) | |
| tree | e0facad4366513d560bdf0e68d9d0e61675d42f9 | |
| parent | 873c3409ac000da83f057342abf656cb79c3d47f (diff) | |
add --cu-cxx to nvcc/-ccbin
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | xmake/languages/cuda/xmake.lua | 1 | ||||
| -rw-r--r-- | xmake/platforms/linux/config.lua | 12 | ||||
| -rw-r--r-- | xmake/platforms/linux/load.lua | 4 | ||||
| -rw-r--r-- | xmake/platforms/macosx/config.lua | 10 | ||||
| -rw-r--r-- | xmake/platforms/macosx/load.lua | 4 |
6 files changed, 31 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ceec0665..7f72d1910 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * [#397](https://github.com/xmake-io/xmake/issues/397): Add clib package manager support * [#404](https://github.com/xmake-io/xmake/issues/404): Support Qt for android and deploy android apk * Add some qt empty project templates, e.g. `widgetapp_qt`, `quickapp_qt_static` and `widgetapp_qt_static` +* [#415](https://github.com/xmake-io/xmake/issues/415): Add `--cu-cxx` config arguments to `nvcc/-ccbin` ### Changes @@ -586,6 +587,7 @@ * [#397](https://github.com/xmake-io/xmake/issues/397): 添加clib包集成支持 * [#404](https://github.com/xmake-io/xmake/issues/404): 增加Qt/Android编译支持,并且支持android apk生成和部署 * 添加一些Qt空工程模板,例如:`widgetapp_qt`, `quickapp_qt_static` and `widgetapp_qt_static` +* [#415](https://github.com/xmake-io/xmake/issues/415): 添加`--cu-cxx`配置参数到`nvcc/-ccbin` ### 改进 diff --git a/xmake/languages/cuda/xmake.lua b/xmake/languages/cuda/xmake.lua index 4935b49b7..46ba8f902 100644 --- a/xmake/languages/cuda/xmake.lua +++ b/xmake/languages/cuda/xmake.lua @@ -121,6 +121,7 @@ language("cuda") { {category = "Cross Complation Configuration/Compiler Configuration" } , {nil, "cu", "kv", nil, "The Cuda Compiler" } + , {nil, "cu-cxx", "kv", nil, "The Cuda Host C++ Compiler" } , {category = "Cross Complation Configuration/Linker Configuration" } , {nil, "cu-ld", "kv", nil, "The Cuda Linker" } diff --git a/xmake/platforms/linux/config.lua b/xmake/platforms/linux/config.lua index fb1ae10a2..60cc98676 100644 --- a/xmake/platforms/linux/config.lua +++ b/xmake/platforms/linux/config.lua @@ -78,12 +78,13 @@ function _toolchains() local cu = toolchain("the cuda compiler") local cu_ld = toolchain("the cuda linker") local cu_sh = toolchain("the cuda shared library linker") + local cu_cxx = toolchain("the cuda host c++ compiler") local toolchains = {cc = cc, cxx = cxx, as = as, ld = ld, sh = sh, ar = ar, ex = ex, mm = mm, mxx = mxx, gc = gc, ["gc-ld"] = gc_ld, ["gc-ar"] = gc_ar, dc = dc, ["dc-ld"] = dc_ld, ["dc-sh"] = dc_sh, ["dc-ar"] = dc_ar, rc = rc, ["rc-ld"] = rc_ld, ["rc-sh"] = rc_sh, ["rc-ar"] = rc_ar, - cu = cu, ["cu-ld"] = cu_ld, ["cu-sh"] = cu_sh} + cu = cu, ["cu-ld"] = cu_ld, ["cu-sh"] = cu_sh, ["cu-cxx"] = cu_cxx} -- init the c compiler cc:add("$(env CC)", {name = "gcc", cross = cross}, {name = "clang", cross = cross}) @@ -149,6 +150,9 @@ function _toolchains() cu:add("nvcc") cu_ld:add("nvcc") cu_sh:add("nvcc") + if not cross or cross == "" then + cu_cxx:add("$(env CXX)", "$(env CC)", "gcc", "clang", "g++", "clang++") + end return toolchains end @@ -169,6 +173,12 @@ function main(platform, name) -- check cuda check_cuda(config) + + -- check cu-cxx after checking arch + if config.get("cuda") then + local toolchains = singleton.get("linux.toolchains", _toolchains) + check_toolchain(config, "cu-cxx", toolchains["cu-cxx"]) + end end end diff --git a/xmake/platforms/linux/load.lua b/xmake/platforms/linux/load.lua index 622d59200..b9ff210b1 100644 --- a/xmake/platforms/linux/load.lua +++ b/xmake/platforms/linux/load.lua @@ -90,5 +90,9 @@ function main(platform) platform:add("cu-shflags", "-L" .. os.args(path.join(cuda_dir, "lib"))) platform:add("cu-ldflags", "-Xlinker -rpath=" .. os.args(path.join(cuda_dir, "lib"))) end + local cu_cxx = config.get("cu-cxx") + if cu_cxx then + platform:add("cuflags", "-ccbin", os.args(cu_cxx)) + end end diff --git a/xmake/platforms/macosx/config.lua b/xmake/platforms/macosx/config.lua index 4db391d7d..59ad2d7bb 100644 --- a/xmake/platforms/macosx/config.lua +++ b/xmake/platforms/macosx/config.lua @@ -60,12 +60,13 @@ function _toolchains() local cu = toolchain("the cuda compiler") local cu_ld = toolchain("the cuda linker") local cu_sh = toolchain("the cuda shared library linker") + local cu_cxx = toolchain("the cuda host c++ compiler") local toolchains = {cc = cc, cxx = cxx, as = as, ld = ld, sh = sh, ar = ar, ex = ex, mm = mm, mxx = mxx, sc = sc, ["sc-ld"] = sc_ld, ["sc-sh"] = sc_sh, gc = gc, ["gc-ld"] = gc_ld, ["gc-ar"] = gc_ar, dc = dc, ["dc-ld"] = dc_ld, ["dc-sh"] = dc_sh, ["dc-ar"] = dc_ar, rc = rc, ["rc-ld"] = rc_ld, ["rc-sh"] = rc_sh, ["rc-ar"] = rc_ar, - cu = cu, ["cu-ld"] = cu_ld, ["cu-sh"] = cu_sh} + cu = cu, ["cu-ld"] = cu_ld, ["cu-sh"] = cu_sh, ["cu-cxx"] = cu_cxx} -- init the c compiler cc:add("$(env CC)", {name = "clang", cross = cross}, "clang", "gcc") @@ -132,6 +133,7 @@ function _toolchains() cu:add("nvcc") cu_ld:add("nvcc") cu_sh:add("nvcc") + cu_cxx:add("$(env CXX)", "$(env CC)", "clang", "gcc") return toolchains end @@ -155,6 +157,12 @@ function main(platform, name) -- check cuda check_cuda(config) + + -- check cu-cxx after checking arch + if config.get("cuda") then + local toolchains = singleton.get("macosx.toolchains." .. (config.get("arch") or os.arch()), _toolchains) + check_toolchain(config, "cu-cxx", toolchains["cu-cxx"]) + end end end diff --git a/xmake/platforms/macosx/load.lua b/xmake/platforms/macosx/load.lua index d59866419..f47e7a31d 100644 --- a/xmake/platforms/macosx/load.lua +++ b/xmake/platforms/macosx/load.lua @@ -102,5 +102,9 @@ function main(platform) platform:add("cu-shflags", "-L" .. os.args(path.join(cuda_dir, "lib"))) platform:add("cu-ldflags", "-Xlinker -rpath -Xlinker " .. os.args(path.join(cuda_dir, "lib"))) end + local cu_cxx = config.get("cu-cxx") + if cu_cxx then + platform:add("cuflags", "-ccbin", os.args(cu_cxx)) + end end |
