xmake.lua 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package("portmidi")
  2. set_homepage("https://github.com/PortMidi/portmidi")
  3. set_description("portmidi is a cross-platform MIDI input/output library")
  4. add_urls("https://github.com/PortMidi/portmidi/archive/refs/tags/$(version).tar.gz",
  5. "https://github.com/PortMidi/portmidi.git")
  6. add_versions("v2.0.7", "43fa65b4ed7ebaa68b0028a538ba8b2ca4dc9b86a7e22ec48842070e010f823f")
  7. add_versions("v2.0.6", "81d22b34051621cd56c8d5ef12908ef2a59764c9cdfba6dae47aabddb71ac914")
  8. add_versions("v2.0.4", "64893e823ae146cabd3ad7f9a9a9c5332746abe7847c557b99b2577afa8a607c")
  9. if is_plat("linux", "bsd") then
  10. add_configs("sndio", {description = "Use sndio", default = false, type = "boolean"})
  11. end
  12. if is_plat("windows", "mingw") then
  13. add_syslinks("winmm", "advapi32")
  14. elseif is_plat("linux", "bsd") then
  15. add_syslinks("pthread")
  16. elseif is_plat("macosx") then
  17. add_frameworks("CoreAudio", "CoreFoundation", "CoreMIDI", "CoreServices")
  18. end
  19. add_deps("cmake")
  20. if is_plat("linux") then
  21. add_deps("alsa-lib")
  22. end
  23. on_load("linux", "bsd", function (package)
  24. if package:config("sndio") then
  25. package:add("deps", "libsndio")
  26. end
  27. end)
  28. on_install("windows", "linux", "macosx", "mingw", function (package)
  29. io.replace("pm_common/CMakeLists.txt", [[MSVC_RUNTIME_LIBRARY]], "", {plain = true})
  30. io.replace("pm_common/CMakeLists.txt", [["MultiThreaded$<$<CONFIG:Debug>:Debug>${MSVCRT_DLL}"]], "", {plain = true})
  31. io.replace("pm_win/pmwinmm.c", "midi->fill_offset_ptr = &(hdr->dwBytesRecorded);", "midi->fill_offset_ptr = (uint32_t *) &(hdr->dwBytesRecorded);", {plain = true})
  32. local configs = {"-DBUILD_PORTMIDI_TESTS=OFF"}
  33. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  34. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  35. table.insert(configs, "-DUSE_SNDIO=" .. (package:config("sndio") and "ON" or "OFF"))
  36. import("package.tools.cmake").install(package, configs)
  37. end)
  38. on_test(function (package)
  39. assert(package:has_cfuncs("Pm_Initialize", {includes = "portmidi.h"}))
  40. end)