xmake.lua 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package("rtmidi")
  2. set_homepage("https://github.com/thestk/rtmidi")
  3. set_description("A set of C++ classes that provide a common API for realtime MIDI input/output across Linux (ALSA & JACK), Macintosh OS X (CoreMIDI) and Windows (Multimedia)")
  4. add_urls("https://github.com/thestk/rtmidi/archive/refs/tags/$(version).tar.gz",
  5. "https://github.com/thestk/rtmidi.git")
  6. add_versions("6.0.0", "ef7bcda27fee6936b651c29ebe9544c74959d0b1583b716ce80a1c6fea7617f0")
  7. if is_plat("linux") then
  8. add_configs("alsa", {default = false, description = "Use alsa api on linux.", type = "boolean"})
  9. end
  10. if is_plat("linux", "macosx", "bsd") then
  11. add_configs("jack", {default = false, description = "Use jack api on posix.", type = "boolean"})
  12. end
  13. if is_plat("windows", "mingw") then
  14. add_syslinks("winmm")
  15. elseif is_plat("macosx") then
  16. add_frameworks("CoreFoundation", "CoreMIDI", "CoreAudio", "CoreServices")
  17. elseif is_plat("iphoneos") then
  18. add_frameworks("CoreMIDI")
  19. elseif is_plat("linux", "bsd") then
  20. add_syslinks("pthread")
  21. elseif is_plat("android") then
  22. add_syslinks("amidi")
  23. end
  24. add_deps("cmake")
  25. on_load("linux", "macosx", "bsd", function(package)
  26. if package:config("alsa") then
  27. package:add("syslinks", "asound")
  28. end
  29. if package:config("jack") then
  30. package:add("syslinks", "jack")
  31. end
  32. end)
  33. on_install("windows", "linux", "macosx", "bsd", "mingw", "msys", "iphoneos", "cross", "wasm", function (package)
  34. local configs = {"-DRTMIDI_BUILD_TESTING=OFF"}
  35. table.insert(configs, "-DRTMIDI_API_ALSA=" .. (package:config("alsa") and "ON" or "OFF"))
  36. table.insert(configs, "-DRTMIDI_API_JACK=" .. (package:config("jack") and "ON" or "OFF"))
  37. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  38. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  39. import("package.tools.cmake").install(package, configs)
  40. end)
  41. on_test(function (package)
  42. assert(package:check_cxxsnippets({test = [[
  43. #include <rtmidi/RtMidi.h>
  44. void test() {
  45. try {
  46. RtMidiIn midiin;
  47. } catch (RtMidiError &error) {
  48. error.printMessage();
  49. }
  50. }
  51. ]]}, {configs = {languages = "c++11"}}))
  52. end)