xmake.lua 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/AcademySoftwareFoundation/openexr/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/AcademySoftwareFoundation/openexr.git")
  7. add_versions("v3.3.2", "5013e964de7399bff1dd328cbf65d239a989a7be53255092fa10b85a8715744d")
  8. add_versions("v3.3.1", "58aad2b32c047070a52f1205b309bdae007442e0f983120e4ff57551eb6f10f1")
  9. add_versions("v3.3.0", "58b00f50d2012f3107573c4b7371f70516d2972c2b301a50925e1b4a60a7be6f")
  10. add_versions("v3.2.4", "81e6518f2c4656fdeaf18a018f135e96a96e7f66dbe1c1f05860dd94772176cc")
  11. add_versions("v3.2.3", "f3f6c4165694d5c09e478a791eae69847cadb1333a2948ca222aa09f145eba63")
  12. add_versions("v2.5.3", "6a6525e6e3907715c6a55887716d7e42d09b54d2457323fcee35a0376960bebf")
  13. add_versions("v2.5.5", "59e98361cb31456a9634378d0f653a2b9554b8900f233450f2396ff495ea76b3")
  14. add_versions("v2.5.7", "36ecb2290cba6fc92b2ec9357f8dc0e364b4f9a90d727bf9a57c84760695272d")
  15. add_versions("v3.1.0", "8c2ff765368a28e8210af741ddf91506cef40f1ed0f1a08b6b73bb3a7faf8d93")
  16. add_versions("v3.1.1", "045254e201c0f87d1d1a4b2b5815c4ae54845af2e6ec0ab88e979b5fdb30a86e")
  17. add_versions("v3.1.3", "6f70a624d1321319d8269a911c4032f24950cde52e76f46e9ecbebfcb762f28c")
  18. add_versions("v3.1.4", "cb019c3c69ada47fe340f7fa6c8b863ca0515804dc60bdb25c942c1da886930b")
  19. add_versions("v3.1.5", "93925805c1fc4f8162b35f0ae109c4a75344e6decae5a240afdfce25f8a433ec")
  20. add_versions("v3.2.1", "61e175aa2203399fb3c8c2288752fbea3c2637680d50b6e306ea5f8ffdd46a9b")
  21. add_configs("build_both", {description = "Build both static library and shared library. (deprecated)", default = false, type = "boolean"})
  22. add_configs("tools", {description = "Build tools", default = false, type = "boolean"})
  23. if is_plat("linux", "bsd") then
  24. add_syslinks("pthread")
  25. end
  26. add_includedirs("include/OpenEXR", "include")
  27. add_deps("cmake")
  28. add_deps("zlib", "libdeflate")
  29. if on_check then
  30. on_check("windows", function (package)
  31. local vs_toolset = package:toolchain("msvc"):config("vs_toolset")
  32. if vs_toolset and package:is_arch("arm.*") then
  33. local vs_toolset_ver = import("core.base.semver").new(vs_toolset)
  34. local minor = vs_toolset_ver:minor()
  35. assert(minor and minor >= 30, "package(openexr) dep(libdeflate) requires vs_toolset >= 14.3")
  36. end
  37. end)
  38. end
  39. on_load(function (package)
  40. local ver = package:version()
  41. local suffix = format("-%d_%d", ver:major(), ver:minor())
  42. local links = {}
  43. if ver:ge("3.0") then
  44. package:add("deps", "imath")
  45. links = {"OpenEXRUtil", "OpenEXR", "OpenEXRCore", "IlmThread", "Iex"}
  46. else
  47. links = {"IlmImfUtil", "IlmImf", "IlmThread", "Imath", "Half", "IexMath", "Iex"}
  48. end
  49. for _, link in ipairs(links) do
  50. package:add("links", link .. suffix)
  51. end
  52. if package:is_plat("windows") and package:config("shared") then
  53. package:add("defines", "OPENEXR_DLL")
  54. end
  55. end)
  56. on_install(function (package)
  57. io.replace("CMakeLists.txt", "add_subdirectory(website/src)", "", {plain = true})
  58. local configs = {
  59. "-DBUILD_TESTING=OFF",
  60. "-DINSTALL_OPENEXR_EXAMPLES=OFF",
  61. "-DOPENEXR_BUILD_EXAMPLES=OFF",
  62. "-DINSTALL_OPENEXR_DOCS=OFF",
  63. "-DBUILD_WEBSITE=OFF",
  64. "-DCMAKE_DEBUG_POSTFIX=''",
  65. }
  66. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  67. if package:is_plat("windows") then
  68. table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=''")
  69. end
  70. table.insert(configs, "-DOPENEXR_BUILD_TOOLS=" .. (package:config("tools") and "ON" or "OFF"))
  71. table.insert(configs, "-DOPENEXR_BUILD_UTILS=" .. (package:config("tools") and "ON" or "OFF"))
  72. if package:version():ge("3.0") then
  73. if package:is_plat("windows") and package:version():le("3.1.4") then
  74. local vs_toolset = import("core.tool.toolchain").load("msvc"):config("vs_toolset")
  75. if vs_toolset then
  76. local toolsetver = vs_toolset:match("(%d+%.%d+)%.%d+")
  77. assert(tonumber(toolsetver) < 14.31, "This version is incompatible with MSVC 14.31.")
  78. end
  79. end
  80. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  81. else
  82. if package:config("build_both") then
  83. table.insert(configs, "-DBUILD_SHARED_LIBS=ON")
  84. table.insert(configs, "-DOPENEXR_BUILD_BOTH_STATIC_SHARED=ON")
  85. table.insert(configs, "-DILMBASE_BUILD_BOTH_STATIC_SHARED=ON")
  86. else
  87. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  88. table.insert(configs, "-DOPENEXR_BUILD_BOTH_STATIC_SHARED=OFF")
  89. table.insert(configs, "-DILMBASE_BUILD_BOTH_STATIC_SHARED=OFF")
  90. end
  91. table.insert(configs, "-DPYILMBASE_ENABLE=OFF")
  92. end
  93. import("package.tools.cmake").install(package, configs)
  94. if package:is_plat("windows") and package:is_debug() then
  95. os.vcp(path.join(package:buildir(), "bin/*.pdb"), package:installdir("bin"))
  96. os.vcp(path.join(package:buildir(), "src/lib/*.pdb"), package:installdir("lib"))
  97. end
  98. end)
  99. on_test(function (package)
  100. assert(package:check_cxxsnippets({test = [[
  101. void test() {
  102. Imf::RgbaInputFile file("hello.exr");
  103. }
  104. ]]}, {configs = {languages = "c++14"}, includes = {"ImfRgbaFile.h"}}))
  105. end)