xmake.lua 1.7 KB

123456789101112131415161718192021222324252627282930313233
  1. package("libopus")
  2. set_homepage("https://opus-codec.org")
  3. set_description("Modern audio compression for the internet.")
  4. set_urls("https://archive.mozilla.org/pub/opus/opus-$(version).tar.gz",
  5. "https://gitlab.xiph.org/xiph/opus.git")
  6. add_versions("1.3.1", "65b58e1e25b2a114157014736a3d9dfeaad8d41be1c8179866f144a2fb44ff9d")
  7. add_patches("1.3.1", path.join(os.scriptdir(), "patches", "1.3.1", "cmake.patch"), "79fba5086d7747d0441f7f156b88e932b662e2d2ccd825279a5a396a2840d3a2")
  8. add_configs("avx", { description = "AVX supported", default = true, type = "boolean" })
  9. add_configs("check_avx", { description = "Does runtime check for AVX support", default = true, type = "boolean" })
  10. add_deps("cmake")
  11. on_install("windows", "linux", "macosx", "iphoneos", "mingw", "android", function (package)
  12. local configs = {}
  13. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  14. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  15. table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
  16. table.insert(configs, "-DAVX_SUPPORTED=" .. (package:config("avx") and "ON" or "OFF"))
  17. table.insert(configs, "-DOPUS_X86_MAY_HAVE_AVX=" .. (package:config("check_avx") and "ON" or "OFF"))
  18. if package:is_plat("mingw") then
  19. -- Disable stack protection on MinGW since it causes link errors
  20. table.insert(configs, "-DOPUS_STACK_PROTECTOR=OFF")
  21. end
  22. import("package.tools.cmake").install(package, configs)
  23. end)
  24. on_test(function (package)
  25. assert(package:has_cfuncs("opus_encoder_create", {includes = "opus/opus.h"}))
  26. end)