diff options
| -rw-r--r-- | xmake/modules/core/tools/nvcc.lua | 6 | ||||
| -rw-r--r-- | xmake/toolchains/cuda/xmake.lua | 11 |
2 files changed, 15 insertions, 2 deletions
diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua index 011599e8a..df4a6b7f4 100644 --- a/xmake/modules/core/tools/nvcc.lua +++ b/xmake/modules/core/tools/nvcc.lua @@ -317,12 +317,14 @@ function compile(self, sourcefile, objectfile, dependinfo, flags) compflags = table.join(compflags, "-MMD", "-MF", depfile) elseif _has_flags_mm(self) then -- since -MD is not supported, run nvcc twice - os.runv(compargv(self, sourcefile, depfile, table.join(flags, "-MM"))) + local program, argv = compargv(self, sourcefile, depfile, table.join(flags, "-MM")) + os.runv(program, argv, {envs = self:runenvs()}) end end -- do compile - local outdata, errdata = os.iorunv(compargv(self, sourcefile, objectfile, compflags)) + local program, argv = compargv(self, sourcefile, objectfile, compflags) + local outdata, errdata = os.iorunv(program, argv, {envs = self:runenvs()}) return (outdata or "") .. (errdata or "") end, catch diff --git a/xmake/toolchains/cuda/xmake.lua b/xmake/toolchains/cuda/xmake.lua index f7bd54cd0..ca25dcb74 100644 --- a/xmake/toolchains/cuda/xmake.lua +++ b/xmake/toolchains/cuda/xmake.lua @@ -30,3 +30,14 @@ toolchain("cuda") set_toolset("culd", "nvcc") set_toolset("cu-ccbin", "$(env CXX)", "$(env CC)", "clang", "gcc") + -- bind msvc environments, because nvcc will call cl.exe + on_load(function (toolchain) + if toolchain:is_plat("windows") then + import("core.tool.toolchain", {alias = "core_toolchain"}) + local msvc = core_toolchain.load("msvc", {plat = toolchain:plat(), arch = toolchain:arch()}) + for name, values in pairs(msvc:runenvs()) do + toolchain:add("runenvs", name, values) + end + end + end) + |
