|
| 1 | +package("enoki") |
| 2 | + |
| 3 | + set_homepage("https://github.com/mitsuba-renderer/enoki") |
| 4 | + set_description("Enoki: structured vectorization and differentiation on modern processor architectures") |
| 5 | + set_license("BSD-3-Clause") |
| 6 | + |
| 7 | + add_urls("https://github.com/mitsuba-renderer/enoki.git") |
| 8 | + add_versions("2024.04.19", "63a5f4c0a35a8513a39393a9ee92646ce44a386e") |
| 9 | + |
| 10 | + add_configs("shared", {description = "Build shared library", default = true, type = "boolean", readonly = true}) |
| 11 | + add_configs("cuda", {description = "Build Enoki CUDA library", default = false, type = "boolean"}) |
| 12 | + add_configs("cudacc", {description = "CUDA compute capability", default = "75", type = "string", values = {"35", "50", "52", "60", "61", "70", "75", "80", "86", "89", "90"}}) |
| 13 | + add_configs("autodiff", {description = "Build Enoki automatic differentation library", default = false, type = "boolean"}) |
| 14 | + add_configs("python", {description = "Build pybind11 interface to CUDA & automatic differentiation libraries", default = false, type = "boolean"}) |
| 15 | + |
| 16 | + on_load(function (package) |
| 17 | + if package:config("cuda") then |
| 18 | + package:add("deps", "cuda") |
| 19 | + end |
| 20 | + if package:config("python") then |
| 21 | + package:add("deps", "python 3.x") |
| 22 | + end |
| 23 | + if package:config("cuda") or package:config("autodiff") then |
| 24 | + package:add("deps", "cmake") |
| 25 | + else |
| 26 | + package:set("kind", "library", {headeronly = true}) |
| 27 | + end |
| 28 | + end) |
| 29 | + |
| 30 | + on_install("windows", "macosx", "linux", "mingw", function (package) |
| 31 | + os.cp("include/enoki", package:installdir("include")) |
| 32 | + if package:config("cuda") or package:config("autodiff") then |
| 33 | + local configs = {} |
| 34 | + table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) |
| 35 | + table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) |
| 36 | + table.insert(configs, "-DENOKI_CUDA=" .. (package:config("cuda") and "ON" or "OFF")) |
| 37 | + if package:config("cuda") then |
| 38 | + table.insert(configs, "-DENOKI_CUDA_COMPUTE_CAPABILITY=" .. package:config("cudacc")) |
| 39 | + end |
| 40 | + table.insert(configs, "-DENOKI_AUTODIFF=" .. (package:config("autodiff") and "ON" or "OFF")) |
| 41 | + table.insert(configs, "-DENOKI_PYTHON=" .. (package:config("python") and "ON" or "OFF")) |
| 42 | + import("package.tools.cmake").install(package, configs) |
| 43 | + end |
| 44 | + end) |
| 45 | + |
| 46 | + on_test(function (package) |
| 47 | + assert(package:check_cxxsnippets({test = [[ |
| 48 | + #ifndef _USE_MATH_DEFINES |
| 49 | + #define _USE_MATH_DEFINES |
| 50 | + #endif |
| 51 | + #include <enoki/array.h> |
| 52 | + void test() { |
| 53 | + enoki::Array<int, 4> idx(1, 2, 3, 4); |
| 54 | + using MyFloat = enoki::Array<float, 4>; |
| 55 | + MyFloat a = enoki::zero<MyFloat>(); |
| 56 | + } |
| 57 | + ]]}, {configs = {languages = "c++17"}})) |
| 58 | + end) |
0 commit comments