Переглянути джерело

add optix (#408)

* fix openvdb

* add optix
Hoildkv 4 роки тому
батько
коміт
d7028d2e14

+ 1 - 1
packages/g/glew/port/xmake.lua

@@ -7,7 +7,7 @@ end
 target("glew")
     set_kind("$(kind)")
     if is_plat("windows", "mingw") then
-        set_basename("glew32")
+        set_basename(is_kind("shared") and "glew32" or "glew32s")
         add_syslinks("glu32", "opengl32")
     elseif is_plat("macosx") then
         add_frameworks("OpenGL")

+ 5 - 1
packages/o/openvdb/xmake.lua

@@ -29,12 +29,16 @@ package("openvdb")
             end
         end
         if package:config("view") then
-            package:add("deps", "glew")
+            package:add("deps", "glew", {configs = {shared = true}})
             package:add("deps", "glfw")
         end
         if not package:config("shared") then
             package:add("defines", "OPENVDB_STATICLIB")
         end
+        if package:is_plat("windows") then
+            package:add("defines", "_USE_MATH_DEFINES")
+            package:add("defines", "NOMINMAX")
+        end
     end)
 
     on_install("macosx", "linux", "windows", function (package)

+ 31 - 0
packages/o/optix/xmake.lua

@@ -0,0 +1,31 @@
+package("optix")
+
+    set_homepage("https://developer.nvidia.com/optix")
+    set_description("NVIDIA OPTIX™ RAY TRACING ENGINE")
+
+    on_fetch(function (package, opt)
+        if opt.system then
+            import("lib.detect.find_path")
+
+            local paths = {"$(env OptiX_ROOT)"}
+            if package:is_plat("windows") then
+                for _, dir in ipairs(os.dirs("$(env PROGRAMDATA)/NVIDIA Corporation/OptiX SDK *.*.*")) do
+                    table.insert(paths, dir)
+                end
+            end
+
+            local inc = find_path("optix.h", paths, {suffixes = "include"})
+            if inc then
+                local result = {includedirs = {inc}}
+                local content = io.readfile(path.join(inc, "optix.h"))
+                local version_str = content:match("OPTIX_VERSION (%d+)\n")
+                if version_str then
+                    local version_num = tonumber(version_str)
+                    local version = format("%s.%s.%s", math.floor(version_num/10000), math.floor(version_num%10000/100), version_num%100)
+                    result.version = version
+                end
+
+                return result
+            end
+        end
+    end)