diff options
| author | ruki <[email protected]> | 2019-06-11 00:26:45 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-06-10 20:40:33 +0800 |
| commit | ae6f488393e8c327a467761bfe09076b38a62d5f (patch) | |
| tree | 78a6dfa5b55a5bac18281152dc3813d6ab203888 | |
| parent | 9535258191b9187e6ba9987391d6777a71f974bd (diff) | |
move linkdirs to find_cuda
| -rw-r--r-- | xmake/modules/detect/sdks/find_cuda.lua | 13 | ||||
| -rw-r--r-- | xmake/rules/cuda/device_link/xmake.lua | 20 |
2 files changed, 19 insertions, 14 deletions
diff --git a/xmake/modules/detect/sdks/find_cuda.lua b/xmake/modules/detect/sdks/find_cuda.lua index a75dfa9f5..cdad64ac1 100644 --- a/xmake/modules/detect/sdks/find_cuda.lua +++ b/xmake/modules/detect/sdks/find_cuda.lua @@ -65,7 +65,18 @@ function _find_cuda(sdkdir) end -- get linkdirs - local linkdirs = {path.join(sdkdir, "lib")} + local linkdirs = {} + if is_plat("windows") then + local subdir = is_arch("x64") and "x64" or "Win32" + table.insert(linkdirs, path.join(sdkdir, "lib", subdir, "stubs")) + table.insert(linkdirs, path.join(sdkdir, "lib", subdir)) + elseif is_plat("linux") and is_arch("x86_64") then + table.insert(linkdirs, path.join(sdkdir, "lib64", "stubs")) + table.insert(linkdirs, path.join(sdkdir, "lib64")) + else + table.insert(linkdirs, path.join(sdkdir, "lib", "stubs")) + table.insert(linkdirs, path.join(sdkdir, "lib")) + end -- get includedirs local includedirs = {path.join(sdkdir, "include")} diff --git a/xmake/rules/cuda/device_link/xmake.lua b/xmake/rules/cuda/device_link/xmake.lua index 989aabdea..8489d8c83 100644 --- a/xmake/rules/cuda/device_link/xmake.lua +++ b/xmake/rules/cuda/device_link/xmake.lua @@ -24,25 +24,19 @@ rule("cuda.device_link") -- after load after_load(function (target) - -- get cuda directory - local cuda_dir = assert(get_config("cuda"), "Cuda SDK directory not found!") + -- imports + import("detect.sdks.find_cuda") + + -- get cuda + local cuda = assert(find_cuda(nil, {verbose = true}), "Cuda SDK directory not found!") -- add links target:add("links", "cudadevrt", "cudart_static") if is_plat("linux") then target:add("links", "rt", "pthread", "dl") end - if is_plat("windows") then - local subdir = is_arch("x64") and "x64" or "Win32" - target:add("linkdirs", path.join(cuda_dir, "lib", subdir)) - target:add("rpathdirs", path.join(cuda_dir, "lib", subdir)) - elseif is_plat("linux") and is_arch("x86_64") then - target:add("linkdirs", path.join(cuda_dir, "lib64")) - target:add("rpathdirs", path.join(cuda_dir, "lib64")) - else - target:add("linkdirs", path.join(cuda_dir, "lib")) - target:add("rpathdirs", path.join(cuda_dir, "lib")) - end + target:add("linkdirs", cuda.linkdirs) + target:add("rpathdirs", cuda.linkdirs) end) -- @see https://devblogs.nvidia.com/separate-compilation-linking-cuda-device-code/ |
