xmake.lua 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package("openexr")
  2. set_homepage("https://www.openexr.com/")
  3. set_description("OpenEXR provides the specification and reference implementation of the EXR file format, the professional-grade image storage format of the motion picture industry.")
  4. add_urls("https://github.com/AcademySoftwareFoundation/openexr/archive/v$(version).tar.gz",
  5. "https://github.com/AcademySoftwareFoundation/openexr.git")
  6. add_versions("2.5.3", "6a6525e6e3907715c6a55887716d7e42d09b54d2457323fcee35a0376960bebf")
  7. add_versions("2.5.5", "59e98361cb31456a9634378d0f653a2b9554b8900f233450f2396ff495ea76b3")
  8. add_versions("2.5.7", "36ecb2290cba6fc92b2ec9357f8dc0e364b4f9a90d727bf9a57c84760695272d")
  9. add_versions("3.1.0", "8c2ff765368a28e8210af741ddf91506cef40f1ed0f1a08b6b73bb3a7faf8d93")
  10. add_versions("3.1.1", "045254e201c0f87d1d1a4b2b5815c4ae54845af2e6ec0ab88e979b5fdb30a86e")
  11. add_versions("3.1.3", "6f70a624d1321319d8269a911c4032f24950cde52e76f46e9ecbebfcb762f28c")
  12. add_versions("3.1.4", "cb019c3c69ada47fe340f7fa6c8b863ca0515804dc60bdb25c942c1da886930b")
  13. add_versions("3.1.5", "93925805c1fc4f8162b35f0ae109c4a75344e6decae5a240afdfce25f8a433ec")
  14. add_deps("cmake")
  15. add_deps("zlib")
  16. -- deprecated
  17. add_configs("build_both", {description = "Build both static library and shared library.", default = false, type = "boolean"})
  18. on_load("windows", "macosx", "linux", "mingw@windows", "mingw@msys", function (package)
  19. local ver = package:version()
  20. local suffix = format("-%d_%d", ver:major(), ver:minor())
  21. local links = {}
  22. if ver:ge("3.0") then
  23. package:add("deps", "imath")
  24. links = {"OpenEXRUtil", "OpenEXR", "OpenEXRCore", "IlmThread", "Iex"}
  25. else
  26. links = {"IlmImfUtil", "IlmImf", "IlmThread", "Imath", "Half", "IexMath", "Iex"}
  27. end
  28. for _, link in ipairs(links) do
  29. package:add("links", link .. suffix)
  30. end
  31. if package:is_plat("windows") and package:config("shared") then
  32. package:add("defines", "OPENEXR_DLL")
  33. end
  34. end)
  35. on_install("macosx", "linux", "windows", "mingw@windows", "mingw@msys", function (package)
  36. local configs = {"-DBUILD_TESTING=OFF", "-DINSTALL_OPENEXR_EXAMPLES=OFF", "-DINSTALL_OPENEXR_DOCS=OFF", "-DOPENEXR_BUILD_UTILS=ON"}
  37. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  38. if package:version():ge("3.0") then
  39. if package:is_plat("windows") and package:version():le("3.1.4") then
  40. local vs_toolset = import("core.tool.toolchain").load("msvc"):config("vs_toolset")
  41. if vs_toolset then
  42. local toolsetver = vs_toolset:match("(%d+%.%d+)%.%d+")
  43. assert(tonumber(toolsetver) < 14.31, "This version is incompatible with MSVC 14.31.")
  44. end
  45. end
  46. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  47. else
  48. if package:config("build_both") then
  49. table.insert(configs, "-DBUILD_SHARED_LIBS=ON")
  50. table.insert(configs, "-DOPENEXR_BUILD_BOTH_STATIC_SHARED=ON")
  51. table.insert(configs, "-DILMBASE_BUILD_BOTH_STATIC_SHARED=ON")
  52. else
  53. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  54. table.insert(configs, "-DOPENEXR_BUILD_BOTH_STATIC_SHARED=OFF")
  55. table.insert(configs, "-DILMBASE_BUILD_BOTH_STATIC_SHARED=OFF")
  56. end
  57. table.insert(configs, "-DPYILMBASE_ENABLE=OFF")
  58. end
  59. import("package.tools.cmake").install(package, configs)
  60. end)
  61. on_test(function (package)
  62. assert(package:check_cxxsnippets({test = [[
  63. #include <stdio.h>
  64. void test() {
  65. printf( OPENEXR_PACKAGE_STRING );
  66. }
  67. ]]}, {configs = {languages = "c++14"},
  68. includes = {"OpenEXR/OpenEXRConfig.h"}}))
  69. end)