xmake.lua 5.1 KB

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