parent
bc749d3868
commit
ab25e351f6
3 changed files with 135 additions and 0 deletions
@ -0,0 +1,30 @@ |
||||
package("opencl-clhpp") |
||||
|
||||
set_kind("library", {headeronly = true}) |
||||
set_homepage("https://github.com/KhronosGroup/OpenCL-CLHPP/") |
||||
set_description("OpenCL API C++ bindings") |
||||
set_license("Apache-2.0") |
||||
|
||||
add_urls("https://github.com/KhronosGroup/OpenCL-$(version)", {version = function (version) |
||||
if version:ge("2.0") then |
||||
return "CLHPP/archive/refs/tags/v" .. version .. ".tar.gz" |
||||
else |
||||
return "Registry.git" |
||||
end |
||||
end}) |
||||
add_versions("2.0.15", "0175806508abc699586fc9a9387e01eb37bf812ca534e3b493ff3091ec2a9246") |
||||
add_versions("1.2.8", "2a35cdc00e31234fa8e5306adc61d8944a810c90") |
||||
|
||||
add_deps("opencl", {system = true}) |
||||
|
||||
on_install(function (package) |
||||
if package:version():ge("2.0") then |
||||
os.cp("include/CL", package:installdir("include")) |
||||
else |
||||
os.cp("api/2.1/cl.hpp", package:installdir("include", "CL")) |
||||
end |
||||
end) |
||||
|
||||
on_test(function (package) |
||||
assert(package:has_cxxtypes("cl::Platform", {configs = {languages = "c++14"}, includes = (package:version():ge("2.0") and "CL/opencl.hpp" or "CL/cl.hpp")})) |
||||
end) |
@ -0,0 +1,66 @@ |
||||
package("opencl") |
||||
|
||||
set_homepage("https://opencl.org/") |
||||
set_description("OpenCL is an open, royalty-free industry standard that makes much faster computations possible through parallel computing.") |
||||
|
||||
add_configs("vendor", {description = "Set OpenCL Vendor.", default = nil, type = "string", values = {"nvidia", "intel", "amd"}}) |
||||
|
||||
on_fetch(function (package, opt) |
||||
if opt.system then |
||||
import("lib.detect.find_path") |
||||
import("lib.detect.find_library") |
||||
import("detect.sdks.find_cuda") |
||||
|
||||
local result = {includedirs = {}, linkdirs = {}, links = {"OpenCL"}} |
||||
local vendor = package:config("vendor") |
||||
local archsuffixes = {"lib"} |
||||
if package:is_arch("x64") then |
||||
table.insert(archsuffixes, "lib64") |
||||
table.insert(archsuffixes, path.join("lib", "x64")) |
||||
elseif package:is_arch("x86") then |
||||
table.insert(archsuffixes, path.join("lib", "x86")) |
||||
elseif package:is_arch("x86_64") then |
||||
table.insert(archsuffixes, "lib64") |
||||
table.insert(archsuffixes, path.join("lib", "x86_64")) |
||||
end |
||||
|
||||
if not vendor or vendor == "nvidia" then |
||||
local cuda = find_cuda() |
||||
if cuda then |
||||
result.includedirs = cuda.includedirs |
||||
result.linkdirs = cuda.linkdirs |
||||
return result |
||||
elseif vendor == "nvidia" then |
||||
return nil |
||||
end |
||||
elseif not vendor or vendor == "intel" then |
||||
local intelsdkpaths = {"$(env INTELOCLSDKROOT)"} |
||||
local linkinfo = find_library("OpenCL", intelsdkpaths, {suffixes = archsuffixes}) |
||||
if linkinfo then |
||||
table.insert(result.linkdirs, linkinfo.linkdir) |
||||
local incpath = find_path(path.join("CL", "cl.h"), intelsdkpaths, {suffixes = {"include"}}) |
||||
if incpath then |
||||
table.insert(result.includedirs, incpath) |
||||
return result |
||||
end |
||||
end |
||||
if vendor == "intel" then |
||||
return nil |
||||
end |
||||
elseif not vendor or vendor == "amd" then |
||||
local amdsdkpaths = {"$(env AMDAPPSDKROOT)"} |
||||
local linkinfo = find_library("OpenCL", amdsdkpaths, {suffixes = archsuffixes}) |
||||
if linkinfo then |
||||
table.insert(result.linkdirs, linkinfo.linkdir) |
||||
local incpath = find_path(path.join("CL", "cl.h"), amdsdkpaths, {suffixes = {"include"}}) |
||||
if incpath then |
||||
table.insert(result.includedirs, incpath) |
||||
return result |
||||
end |
||||
end |
||||
if vendor == "amd" then |
||||
return nil |
||||
end |
||||
end |
||||
end |
||||
end) |
@ -0,0 +1,39 @@ |
||||
package("vexcl") |
||||
|
||||
set_homepage("https://github.com/ddemidov/vexcl") |
||||
set_description("VexCL is a C++ vector expression template library for OpenCL/CUDA/OpenMP") |
||||
set_license("MIT") |
||||
|
||||
add_urls("https://github.com/ddemidov/vexcl/archive/refs/tags/$(version).tar.gz", |
||||
"https://github.com/ddemidov/vexcl.git") |
||||
add_versions("1.4.2", "3a2be30e303c4f44a269ca85de48f1a628127012f18abee0aa82c0c2cbb0e0c8") |
||||
|
||||
add_deps("cmake") |
||||
add_deps("opencl-clhpp 1.x") |
||||
add_deps("opencl", {system = true}) |
||||
add_deps("boost", {configs = {filesystem = true, |
||||
date_time = true, |
||||
program_options = true, |
||||
system = true, |
||||
thread = true, |
||||
test = true}}) |
||||
|
||||
if is_plat("windows") then |
||||
add_defines("NOMINMAX") |
||||
end |
||||
|
||||
on_install("windows", "linux", "macosx", function (package) |
||||
local configs = {"-DVEXCL_BUILD_TESTS=OFF", "-DVEXCL_BUILD_EXAMPLES=OFF", "-DBoost_USE_STATIC_LIBS=ON"} |
||||
if package:is_plat("windows") then |
||||
table.insert(configs, "-DBoost_USE_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF")) |
||||
end |
||||
import("package.tools.cmake").install(package, configs) |
||||
end) |
||||
|
||||
on_test(function (package) |
||||
assert(package:check_cxxsnippets({test = [[ |
||||
void test() { |
||||
auto dev = vex::backend::device_list(vex::Filter::Any); |
||||
} |
||||
]]}, {configs = {languages = "c++17"}, includes = "vexcl/devlist.hpp"})) |
||||
end) |
Loading…
Reference in new issue