summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxq114 <[email protected]>2021-04-05 11:05:17 +0800
committerxq114 <[email protected]>2021-04-05 11:05:17 +0800
commit7fc0928774fb5d4e022d85e77fea8f3c29426a80 (patch)
tree0eafaa61717e0f307d7a11435d224f57ff19b4c8
parent3c2ca2356818dffe8c6b70e2fcf6f799a47927f2 (diff)
add find_vulkansdk.lua
-rw-r--r--xmake/modules/detect/packages/find_mkl.lua4
-rw-r--r--xmake/modules/detect/packages/find_nvtx.lua26
-rw-r--r--xmake/modules/detect/packages/find_vulkansdk.lua61
3 files changed, 88 insertions, 3 deletions
diff --git a/xmake/modules/detect/packages/find_mkl.lua b/xmake/modules/detect/packages/find_mkl.lua
index cefa0356a..05e9f5c92 100644
--- a/xmake/modules/detect/packages/find_mkl.lua
+++ b/xmake/modules/detect/packages/find_mkl.lua
@@ -43,7 +43,7 @@ function main(opt)
}
-- find library
- local result = {links = {}, linkdirs = {}, includedirs = {}}
+ local result = {links = {}, linkdirs = {}, includedirs = {}, threading = ""}
local linkinfo = find_library("mkl_core", paths, {suffixes = path.join("lib", rdir)})
if not linkinfo then
-- not found?
@@ -61,8 +61,10 @@ function main(opt)
if tbb_res then
table.join2(result.linkdirs, tbb_res.linkdirs)
table.join2(result.links, {"mkl_tbb_thread", "mkl_core", "tbb"})
+ result.threading = "tbb"
else
table.join2(result.links, {"mkl_sequential", "mkl_core"})
+ result.threading = "seq"
end
-- find include
diff --git a/xmake/modules/detect/packages/find_nvtx.lua b/xmake/modules/detect/packages/find_nvtx.lua
index 83f999ded..2b6dd26f6 100644
--- a/xmake/modules/detect/packages/find_nvtx.lua
+++ b/xmake/modules/detect/packages/find_nvtx.lua
@@ -21,6 +21,7 @@
-- imports
import("lib.detect.find_path")
import("lib.detect.find_library")
+import("detect.sdks.find_cuda")
-- find nvtx
--
@@ -29,8 +30,7 @@ import("lib.detect.find_library")
-- @return see the return value of find_package()
--
function main(opt)
-
- -- for windows platform
+
if opt.plat == "windows" then
-- init bits
@@ -62,5 +62,27 @@ function main(opt)
-- ok
return result
+ else
+
+ -- find cuda
+ local cuda = find_cuda()
+ if cuda then
+ local result = {links = {}, linkdirs = {}, includedirs = {}}
+
+ -- find library
+ local linkinfo = find_library("nvToolsExt", cuda.linkdirs)
+ if linkinfo then
+ table.insert(result.links, "nvToolsExt")
+ table.insert(result.linkdirs, linkinfo.linkdir)
+ else
+ return
+ end
+ table.join2(result.includedirs, cuda.includedirs)
+
+ -- ok
+ return result
+ else
+ return
+ end
end
end
diff --git a/xmake/modules/detect/packages/find_vulkansdk.lua b/xmake/modules/detect/packages/find_vulkansdk.lua
new file mode 100644
index 000000000..6e0a542a0
--- /dev/null
+++ b/xmake/modules/detect/packages/find_vulkansdk.lua
@@ -0,0 +1,61 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author xq114
+-- @file find_vulkansdk.lua
+--
+
+-- imports
+import("lib.detect.find_path")
+import("lib.detect.find_library")
+
+-- find vulkansdk
+--
+-- @param opt the package options. e.g. see the options of find_package()
+--
+-- @return see the return value of find_package()
+--
+function main(opt)
+
+ -- init search paths
+ local paths = {
+ "$(env VK_SDK_PATH)",
+ "$(env VULKAN_SDK)"
+ }
+
+ -- find library
+ local result = {links = {}, linkdirs = {}, includedirs = {}}
+
+ local libname = (opt.plat == "windows" and "vulkan-1" or "vulkan")
+ local libsuffix = ((opt.plat == "windows" and opt.arch == "x86") and "lib32" or "lib")
+ local binsuffix = ((opt.plat == "windows" and opt.arch == "x86") and "bin32" or "bin")
+ local linkinfo = find_library(libname, paths, {suffixes = libsuffix})
+ if linkinfo then
+ result.sdkdir = path.directory(linkinfo.linkdir)
+ result.bindir = path.join(result.sdkdir, binsuffix)
+ table.insert(result.linkdirs, linkinfo.linkdir)
+ table.insert(result.links, libname)
+ else
+ -- not found?
+ return
+ end
+
+ -- find include
+ table.insert(result.includedirs, find_path(path.join("vulkan", "vulkan.h"), paths, {suffixes = "include"}))
+
+ -- ok
+ return result
+end