xmake.lua 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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.4", "64893e823ae146cabd3ad7f9a9a9c5332746abe7847c557b99b2577afa8a607c")
  7. if is_plat("linux", "bsd") then
  8. add_configs("sndio", {description = "Use sndio", default = false, type = "boolean"})
  9. end
  10. if is_plat("windows", "mingw") then
  11. add_syslinks("winmm", "advapi32")
  12. elseif is_plat("linux", "bsd") then
  13. add_syslinks("pthread")
  14. elseif is_plat("macosx") then
  15. add_frameworks("CoreAudio", "CoreFoundation", "CoreMIDI", "CoreServices")
  16. end
  17. add_deps("cmake")
  18. if is_plat("linux") then
  19. add_deps("alsa-lib")
  20. end
  21. on_load("linux", "bsd", function (package)
  22. if package:config("sndio") then
  23. package:add("deps", "libsndio")
  24. end
  25. end)
  26. on_install("windows", "linux", "macosx", "mingw", function (package)
  27. io.replace("pm_common/CMakeLists.txt", [[MSVC_RUNTIME_LIBRARY]], "", {plain = true})
  28. io.replace("pm_common/CMakeLists.txt", [["MultiThreaded$<$<CONFIG:Debug>:Debug>${MSVCRT_DLL}"]], "", {plain = true})
  29. io.replace("pm_win/pmwinmm.c", "midi->fill_offset_ptr = &(hdr->dwBytesRecorded);", "midi->fill_offset_ptr = (uint32_t *) &(hdr->dwBytesRecorded);", {plain = true})
  30. local configs = {"-DBUILD_PORTMIDI_TESTS=OFF"}
  31. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  32. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  33. table.insert(configs, "-DUSE_SNDIO=" .. (package:config("sndio") and "ON" or "OFF"))
  34. import("package.tools.cmake").install(package, configs)
  35. end)
  36. on_test(function (package)
  37. assert(package:has_cfuncs("Pm_Initialize", {includes = "portmidi.h"}))
  38. end)