xmake.lua 2.1 KB

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