summaryrefslogtreecommitdiff
path: root/xmake/modules/detect
diff options
context:
space:
mode:
authorxq114 <[email protected]>2022-02-14 15:12:36 +0800
committerxq114 <[email protected]>2022-02-14 15:12:36 +0800
commit5bcd2bbb668d73d4619be28e601b9c8d1b109175 (patch)
tree90f289b2e6146bf3b5e2e81488a203b2c5a1b261 /xmake/modules/detect
parent4adce623e6632f42c37f6b31614816312299c3d5 (diff)
improve find_cuda.lua
Diffstat (limited to 'xmake/modules/detect')
-rw-r--r--xmake/modules/detect/sdks/find_cuda.lua23
1 files changed, 10 insertions, 13 deletions
diff --git a/xmake/modules/detect/sdks/find_cuda.lua b/xmake/modules/detect/sdks/find_cuda.lua
index e3284f533..6189ca58e 100644
--- a/xmake/modules/detect/sdks/find_cuda.lua
+++ b/xmake/modules/detect/sdks/find_cuda.lua
@@ -32,18 +32,19 @@ function _find_sdkdir(version)
-- init the search directories
local paths = {}
if version then
- if os.host() == "macosx" then
+ if is_host("macosx") then
table.insert(paths, format("/Developer/NVIDIA/CUDA-%s/bin", version))
- elseif os.host() == "windows" then
+ elseif is_host("windows") then
+ table.insert(paths, format("$(env CUDA_PATH_V%s)/bin", version:gsub("%.", "_")))
table.insert(paths, format("C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v%s\\bin", version))
else
table.insert(paths, format("/usr/local/cuda-%s/bin", version))
end
else
- if os.host() == "macosx" then
+ if is_host("macosx") then
table.insert(paths, "/Developer/NVIDIA/CUDA/bin")
table.insert(paths, "/Developer/NVIDIA/CUDA*/bin")
- elseif os.host() == "windows" then
+ elseif is_host("windows") then
table.insert(paths, "$(env CUDA_PATH)/bin")
table.insert(paths, "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\*\\bin")
else
@@ -55,7 +56,7 @@ function _find_sdkdir(version)
end
-- attempt to find nvcc
- local nvcc = find_file(os.host() == "windows" and "nvcc.exe" or "nvcc", paths)
+ local nvcc = find_file(is_host("windows") and "nvcc.exe" or "nvcc", paths)
if nvcc then
return path.directory(path.directory(nvcc))
end
@@ -101,10 +102,10 @@ function _find_cuda(sdkdir)
-- get linkdirs
local linkdirs = {}
- if is_plat("windows") then
+ if is_host("windows") then
local subdir = is_arch("x64") and "x64" or "Win32"
table.insert(linkdirs, path.join(sdkdir, "lib", subdir))
- elseif is_plat("linux") and is_arch("x86_64") then
+ elseif is_host("linux") and is_arch("x86_64") then
table.insert(linkdirs, path.join(sdkdir, "lib64", "stubs"))
table.insert(linkdirs, path.join(sdkdir, "lib64"))
else
@@ -120,16 +121,12 @@ function _find_cuda(sdkdir)
-- find msbuildextensionsdir on windows
local msbuildextensionsdir
- if is_plat("windows") then
+ if is_host("windows") then
msbuildextensionsdir = _find_msbuildextensionsdir(sdkdir)
end
-- get toolchains
- local result = {sdkdir = sdkdir, bindir = bindir, version = version, linkdirs = linkdirs, includedirs = includedirs}
- if msbuildextensionsdir then
- result.msbuildextensionsdir = msbuildextensionsdir
- end
- return result
+ return {sdkdir = sdkdir, bindir = bindir, version = version, linkdirs = linkdirs, includedirs = includedirs, msbuildextensionsdir = msbuildextensionsdir}
end
-- find cuda sdk toolchains