xmake.lua 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package("opensubdiv")
  2. set_homepage("https://graphics.pixar.com/opensubdiv/docs/intro.html")
  3. set_description("OpenSubdiv is a set of open source libraries that implement high performance subdivision surface (subdiv) evaluation on massively parallel CPU and GPU architectures.")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/PixarAnimationStudios/OpenSubdiv/archive/refs/tags/v$(version).tar.gz", {version = function (version) return version:gsub("%.", "_") end})
  6. add_versions("3.4.4", "20d49f80a2b778ad4d01f091ad88d8c2f91cf6c7363940c6213241ce6f1048fb")
  7. if is_plat("windows") then
  8. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  9. end
  10. add_configs("glfw", {description = "Enable components depending on GLFW.", default = true, type = "boolean"})
  11. add_configs("ptex", {description = "Enable components depending on Ptex.", default = true, type = "boolean"})
  12. add_configs("tbb", {description = "Enable components depending on TBB.", default = false, type = "boolean"})
  13. add_configs("opencl", {description = "Enable OpenCL backend.", default = false, type = "boolean"})
  14. add_configs("cuda", {description = "Enable CUDA backend.", default = false, type = "boolean"})
  15. add_deps("cmake")
  16. if is_plat("windows") then
  17. add_defines("NOMINMAX")
  18. end
  19. on_load("windows", "macosx", "linux", function (package)
  20. for _, dep in ipairs({"glfw", "ptex", "tbb"}) do
  21. if package:config(dep) then
  22. package:add("deps", dep)
  23. end
  24. end
  25. for _, dep in ipairs({"opencl", "cuda"}) do
  26. if package:config(dep) then
  27. package:add("deps", dep, {system = true})
  28. end
  29. end
  30. end)
  31. on_install("windows", "macosx", "linux", function (package)
  32. local configs = {"-DNO_EXAMPLES=ON", "-DNO_TUTORIALS=ON", "-DNO_REGRESSION=ON", "-DNO_DOC=ON", "-DNO_CLEW=ON", "-DNO_TESTS=ON", "-DNO_GLTESTS=ON"}
  33. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  34. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  35. for _, dep in ipairs({"glfw", "ptex", "tbb", "opencl", "cuda"}) do
  36. table.insert(configs, "-DNO_" .. dep:upper() .. "=" .. (package:config(dep) and "ON" or "OFF"))
  37. end
  38. if package:is_plat("windows") then
  39. local vs_sdkver = import("core.tool.toolchain").load("msvc"):config("vs_sdkver")
  40. if vs_sdkver then
  41. local build_ver = string.match(vs_sdkver, "%d+%.%d+%.(%d+)%.?%d*")
  42. assert(tonumber(build_ver) >= 18362, "OpenSubDiv requires Windows SDK to be at least 10.0.18362.0")
  43. table.insert(configs, "-DCMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION=" .. vs_sdkver)
  44. table.insert(configs, "-DCMAKE_SYSTEM_VERSION=" .. vs_sdkver)
  45. end
  46. table.insert(configs, "-DMSVC_STATIC_CRT=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
  47. end
  48. import("package.tools.cmake").install(package, configs)
  49. if package:config("shared") then
  50. os.tryrm(path.join(package:installdir("lib"), "lib*.a"))
  51. end
  52. end)
  53. on_test(function (package)
  54. assert(package:check_cxxsnippets({test = [[
  55. #include <opensubdiv/osd/glMesh.h>
  56. void test() {
  57. OpenSubdiv::Osd::MeshBitset bits;
  58. bits.set(OpenSubdiv::Osd::MeshAdaptive, true);
  59. bits.set(OpenSubdiv::Osd::MeshUseSingleCreasePatch, true);
  60. }
  61. ]]}, {configs = {languages = "c++14"}}))
  62. end)