xmake.lua 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  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. import("core.base.semver")
  8. local paths = {"$(env OptiX_ROOT)"}
  9. if package:is_plat("windows") then
  10. for _, dir in ipairs(os.dirs("$(env PROGRAMDATA)/NVIDIA Corporation/OptiX SDK *.*.*")) do
  11. if package:version_str() == "latest" or semver.satisfies(dir:match("OptiX SDK (%d+%.%d+%.%d+)"), package:version_str()) then
  12. table.insert(paths, dir)
  13. end
  14. end
  15. end
  16. local inc = find_path("optix.h", paths, {suffixes = "include"})
  17. if inc then
  18. local result = {includedirs = {inc}}
  19. local content = io.readfile(path.join(inc, "optix.h"))
  20. local version_str = content:match("OPTIX_VERSION (%d+)\n")
  21. if version_str then
  22. local version_num = tonumber(version_str)
  23. local version = format("%s.%s.%s", math.floor(version_num/10000), math.floor(version_num%10000/100), version_num%100)
  24. result.version = version
  25. end
  26. return result
  27. end
  28. end
  29. end)