xmake.lua 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. package("optix")
  2. set_homepage("https://developer.nvidia.com/optix")
  3. set_description("NVIDIA OPTIX™ RAY TRACING ENGINE")
  4. on_fetch(function (package, opt)
  5. if opt.system then
  6. import("lib.detect.find_path")
  7. local paths = {"$(env OptiX_ROOT)"}
  8. if package:is_plat("windows") then
  9. for _, dir in ipairs(os.dirs("$(env PROGRAMDATA)/NVIDIA Corporation/OptiX SDK *.*.*")) do
  10. table.insert(paths, dir)
  11. end
  12. end
  13. local inc = find_path("optix.h", paths, {suffixes = "include"})
  14. if inc then
  15. local result = {includedirs = {inc}}
  16. local content = io.readfile(path.join(inc, "optix.h"))
  17. local version_str = content:match("OPTIX_VERSION (%d+)\n")
  18. if version_str then
  19. local version_num = tonumber(version_str)
  20. local version = format("%s.%s.%s", math.floor(version_num/10000), math.floor(version_num%10000/100), version_num%100)
  21. result.version = version
  22. end
  23. return result
  24. end
  25. end
  26. end)