xmake.lua 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package("opencolorio")
  2. set_homepage("https://opencolorio.org/")
  3. set_description("A complete color management solution geared towards motion picture production with an emphasis on visual effects and computer animation.")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/AcademySoftwareFoundation/OpenColorIO/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/AcademySoftwareFoundation/OpenColorIO.git")
  7. add_versions("v2.4.2", "2d8f2c47c40476d6e8cea9d878f6601d04f6d5642b47018eaafa9e9f833f3690")
  8. add_versions("v2.3.2", "6bbf4e7fa4ea2f743a238cb22aff44890425771a2f57f62cece1574e46ceec2f")
  9. add_versions("v2.1.1", "16ebc3e0f21f72dbe90fe60437eb864f4d4de9c255ef8e212f837824fc9b8d9c")
  10. add_versions("v2.1.0", "81fc7853a490031632a69c73716bc6ac271b395e2ba0e2587af9995c2b0efb5f")
  11. if is_plat("windows") then
  12. add_syslinks("user32", "gdi32")
  13. elseif is_plat("macosx") then
  14. add_frameworks("CoreFoundation", "CoreGraphics", "ColorSync", "IOKit")
  15. end
  16. add_deps("cmake")
  17. add_deps("expat", "yaml-cpp", "imath", "pystring")
  18. on_check("windows|arm64", function (package)
  19. if not package:is_cross() then
  20. raise("package(opencolorio) unsupported windows arm64 native build")
  21. end
  22. end)
  23. on_load(function (package)
  24. if package:version() and package:version():ge("2.2.0") then
  25. package:add("deps", "minizip-ng")
  26. end
  27. if not package:config("shared") and package:is_plat("windows") then
  28. package:add("defines", "OpenColorIO_SKIP_IMPORTS")
  29. end
  30. end)
  31. on_install("!mingw and !iphoneos", function (package)
  32. local minizip_ng = package:dep("minizip-ng")
  33. local version = package:version()
  34. if version then
  35. -- Fix GCC 15
  36. if version:ge("2.3.0") then
  37. io.replace("include/OpenColorIO/OpenColorIO.h", "#include <string>", "#include <string>\n#include <cstdint>", {plain = true})
  38. end
  39. if version:lt("2.4.0") then
  40. io.replace("src/OpenColorIO/FileRules.cpp", "#include <cctype>", "#include <cctype>\n#include <cstring>", {plain = true})
  41. end
  42. if version:lt("2.3.0") then
  43. os.rm("share/cmake/modules/Findyaml-cpp.cmake")
  44. io.replace("src/OpenColorIO/CMakeLists.txt", "yaml-cpp", "yaml-cpp::yaml-cpp", {plain = true})
  45. end
  46. end
  47. if minizip_ng and package:is_plat("macosx") then
  48. -- Break shared build
  49. -- https://github.com/AcademySoftwareFoundation/OpenColorIO/pull/1729
  50. io.replace("src/OpenColorIO/CMakeLists.txt", "elseif(APPLE)", "elseif(0)", {plain = true})
  51. end
  52. local configs = {"-DOCIO_BUILD_APPS=OFF", "-DOCIO_BUILD_OPENFX=OFF", "-DOCIO_BUILD_PYTHON=OFF", "-DOCIO_BUILD_DOCS=OFF", "-DOCIO_BUILD_TESTS=OFF", "-DOCIO_BUILD_GPU_TESTS=OFF"}
  53. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  54. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  55. local opt = {}
  56. if minizip_ng then
  57. opt.packagedeps = "minizip-ng"
  58. end
  59. import("package.tools.cmake").install(package, configs, opt)
  60. end)
  61. on_test(function (package)
  62. assert(package:check_cxxsnippets({test = [[
  63. #include <OpenColorIO/OpenColorIO.h>
  64. namespace OCIO = OCIO_NAMESPACE;
  65. void test() {
  66. OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
  67. OCIO::ConstProcessorRcPtr processor =
  68. config->getProcessor(OCIO::ROLE_COMPOSITING_LOG, OCIO::ROLE_SCENE_LINEAR);
  69. OCIO::ConstCPUProcessorRcPtr cpu = processor->getDefaultCPUProcessor();
  70. }
  71. ]]}, {configs = {languages = "c++17"}}))
  72. end)