xmake.lua 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package("rtaudio")
  2. set_homepage("https://github.com/thestk/rtaudio")
  3. set_description("A set of C++ classes that provide a common API for realtime audio input/output across Linux (native ALSA, JACK, PulseAudio and OSS), Macintosh OS X (CoreAudio and JACK), and Windows (DirectSound, ASIO, and WASAPI) operating systems.")
  4. add_urls("https://github.com/thestk/rtaudio/archive/refs/tags/$(version).tar.gz",
  5. "https://github.com/thestk/rtaudio.git")
  6. add_versions("6.0.1", "7206c8b6cee43b474f43d64988fefaadfdcfc4264ed38d8de5f5d0e6ddb0a123")
  7. add_versions("6.0.0", "bbd637a45ab54ba999883410b9bdd84529c3ac894aee9a68fc3b9a6f0686b9fb")
  8. add_configs("asio", {description = "Build ASIO API", default = false, type = "boolean"})
  9. add_configs("jack", {description = "Build JACK audio server API ", default = false, type = "boolean"})
  10. if is_plat("windows") then
  11. add_configs("direct_sound", {description = "Build DirectSound API", default = false, type = "boolean"})
  12. add_configs("wasapi", {description = "Build WASAPI API", default = false, type = "boolean"})
  13. elseif is_plat("linux") then
  14. add_configs("alsa", {description = "Build ALSA API", default = false, type = "boolean"})
  15. add_configs("pulseaudio", {description = "Build PulseAudio API", default = false, type = "boolean"})
  16. elseif is_plat("macosx") then
  17. add_configs("coreaudio", {description = "Build CoreAudio API", default = false, type = "boolean"})
  18. elseif is_plat("bsd") then
  19. add_configs("oss", {description = "Build OSS4 API", default = false, type = "boolean"})
  20. end
  21. if is_plat("windows", "mingw") then
  22. add_syslinks("winmm", "ole32", "mfplat", "mfuuid", "ksuser", "wmcodecdspuuid", "user32", "dsound")
  23. elseif is_plat("macosx") then
  24. add_frameworks("CoreFoundation", "CoreAudio")
  25. elseif is_plat("linux", "bsd") then
  26. add_syslinks("pthread")
  27. end
  28. add_deps("cmake")
  29. on_install("windows", "linux", "macosx", "mingw", "msys", function (package)
  30. local configs = {"-DRTAUDIO_BUILD_PYTHON=OFF"}
  31. if package:is_debug() then
  32. table.insert(configs, "-DCMAKE_BUILD_TYPE=ON")
  33. package:add("defines", "__RTAUDIO_DEBUG__")
  34. else
  35. table.insert(configs, "-DCMAKE_BUILD_TYPE=OFF")
  36. end
  37. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  38. table.insert(configs, "-DRTAUDIO_API_ASIO=" .. (package:config("asio") and "ON" or "OFF"))
  39. table.insert(configs, "-DRTAUDIO_API_JACK=" .. (package:config("jack") and "ON" or "OFF"))
  40. if package:is_plat("windows") then
  41. table.insert(configs, "-DRTAUDIO_API_DS=" .. (package:config("direct_sound") and "ON" or "OFF"))
  42. table.insert(configs, "-DRTAUDIO_API_WASAPI=" .. (package:config("wasapi") and "ON" or "OFF"))
  43. elseif package:is_plat("linux") then
  44. table.insert(configs, "-DRTAUDIO_API_ALSA=" .. (package:config("alsa") and "ON" or "OFF"))
  45. table.insert(configs, "-DRTAUDIO_API_PULSE=" .. (package:config("pulseaudio") and "ON" or "OFF"))
  46. elseif package:is_plat("macosx") then
  47. table.insert(configs, "-DRTAUDIO_API_CORE=" .. (package:config("coreaudio") and "ON" or "OFF"))
  48. elseif package:is_plat("bsd") then
  49. table.insert(configs, "-DRTAUDIO_API_OSS=" .. (package:config("oss") and "ON" or "OFF"))
  50. end
  51. import("package.tools.cmake").install(package, configs)
  52. end)
  53. on_test(function (package)
  54. assert(package:has_cfuncs("rtaudio_version", {includes = "rtaudio/rtaudio_c.h"}))
  55. assert(package:check_cxxsnippets({test = [[
  56. #include <rtaudio/RtAudio.h>
  57. void test() {
  58. RtAudio::DeviceInfo info;
  59. }
  60. ]]}, {configs = {languages = "c++11"}}))
  61. end)