xmake.lua 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package("materialx")
  2. set_homepage("http://www.materialx.org/")
  3. set_description("MaterialX is an open standard for the exchange of rich material and look-development content across applications and renderers.")
  4. set_license("Apache-2.0")
  5. set_urls("https://github.com/AcademySoftwareFoundation/MaterialX/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/AcademySoftwareFoundation/MaterialX.git", {submodules = false})
  7. add_versions("v1.39.3", "1f299d14c1243a4834e2363921d98465cc002b37e7f5cddb6f8747ab58fbf6d1")
  8. add_versions("v1.39.0", "cc470da839cdc0e31e4b46ee46ff434d858c38c803b1d4a1012ed12546ace541")
  9. add_versions("v1.38.10", "706f44100188bc283a135ad24b348e55b405ac9e70cb64b7457c381383cc2887")
  10. add_configs("glsl", {description = "Build the GLSL shader generator back-end.", default = false, type = "boolean"})
  11. add_configs("osl", {description = "Build the OSL shader generator back-end.", default = false, type = "boolean"})
  12. add_configs("mdl", {description = "Build the MDL shader generator back-end.", default = false, type = "boolean"})
  13. add_configs("msl", {description = "Build the MSL shader generator back-end.", default = false, type = "boolean"})
  14. add_configs("render", {description = "Build the MaterialX Render modules.", default = false, type = "boolean"})
  15. add_configs("render_platforms", {description = "Build platform-specific render modules for each shader generator.", default = true, type = "boolean"})
  16. add_configs("openimageio", {description = "Build OpenImageIO support for MaterialXRender.", default = false, type = "boolean"})
  17. add_configs("opencolorio", {description = "Build OpenColorIO support for shader generators.", default = false, type = "boolean"})
  18. add_configs("monolithic", {description = "Build single shared library", default = false, type = "boolean"})
  19. if is_plat("linux", "bsd") then
  20. add_syslinks("m", "dl")
  21. end
  22. add_deps("cmake")
  23. on_load(function (package)
  24. if package:config("render") and package:config("render_platforms") then
  25. if package:is_plat("linux") then
  26. package:add("deps", "libx11", "libxt")
  27. elseif package:is_plat("macosx") then
  28. package:add("deps", "opengl", {optional = true})
  29. package:add("frameworks", "Cocoa")
  30. end
  31. end
  32. if package:config("openimageio") then
  33. package:add("deps", "openimageio")
  34. end
  35. if package:config("opencolorio") then
  36. package:add("deps", "opencolorio")
  37. end
  38. if package:config("shared") then
  39. package:add("defines", "MATERIALX_BUILD_SHARED_LIBS")
  40. end
  41. end)
  42. on_install(function (package)
  43. io.replace("CMakeLists.txt", "set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)", "", {plain = true})
  44. if package:version() and package:version():lt("1.39.4") then
  45. -- fix gcc15
  46. io.replace("source/MaterialXCore/Library.h", "#include <algorithm>", "#include <algorithm>\n#include <cstdint>", {plain = true})
  47. end
  48. local configs = {
  49. "-DMATERIALX_BUILD_TESTS=OFF",
  50. "-DMATERIALX_TEST_RENDER=OFF",
  51. "-DMATERIALX_BUILD_USE_CCACHE=OFF",
  52. "-DMATERIALX_INSTALL_RESOURCES=OFF",
  53. }
  54. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  55. table.insert(configs, "-DMATERIALX_BUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  56. table.insert(configs, "-DMATERIALX_BUILD_MONOLITHIC=" .. (package:config("monolithic") and "ON" or "OFF"))
  57. table.insert(configs, "-DMATERIALX_BUILD_GEN_GLSL=" .. (package:config("glsl") and "ON" or "OFF"))
  58. table.insert(configs, "-DMATERIALX_BUILD_GEN_OSL=" .. (package:config("osl") and "ON" or "OFF"))
  59. table.insert(configs, "-DMATERIALX_BUILD_GEN_MDL=" .. (package:config("mdl") and "ON" or "OFF"))
  60. table.insert(configs, "-DMATERIALX_BUILD_GEN_MSL=" .. (package:config("msl") and "ON" or "OFF"))
  61. table.insert(configs, "-DMATERIALX_BUILD_RENDER=" .. (package:config("render") and "ON" or "OFF"))
  62. table.insert(configs, "-DMATERIALX_BUILD_RENDER_PLATFORMS=" .. (package:config("render_platforms") and "ON" or "OFF"))
  63. table.insert(configs, "-DMATERIALX_BUILD_OIIO=" .. (package:config("openimageio") and "ON" or "OFF"))
  64. table.insert(configs, "-DMATERIALX_BUILD_OCIO=" .. (package:config("opencolorio") and "ON" or "OFF"))
  65. import("package.tools.cmake").install(package, configs)
  66. os.trycp(path.join(package:buildir(), "source/MaterialXCore/Generated.h"), package:installdir("include/MaterialXCore"))
  67. os.tryrm(package:installdir("*.md"))
  68. os.tryrm(package:installdir("LICENSE"))
  69. end)
  70. on_test(function (package)
  71. assert(package:check_cxxsnippets({test = [[
  72. #include <MaterialXCore/Document.h>
  73. void test() {
  74. MaterialX::DocumentPtr doc = MaterialX::createDocument();
  75. }
  76. ]]}, {configs = {languages = "c++17"}}))
  77. end)