xmake.lua 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package("portaudio")
  2. set_homepage("http://www.portaudio.com")
  3. set_description("PortAudio is a cross-platform, open-source C language library for real-time audio input and output.")
  4. add_urls("https://github.com/PortAudio/portaudio.git")
  5. add_versions("2023.08.05", "95a5c4ba645e01b32f70458f8ddcd92edd62f982")
  6. add_configs("skeleton", {description = "Use skeleton host API", default = false, type = "boolean"})
  7. add_configs("asio", {description = "Enable support for ASIO", default = false, type = "boolean"})
  8. if is_plat("windows") then
  9. add_configs("direct_sound", {description = "Enable support for DirectSound", default = true, type = "boolean"})
  10. add_configs("wmme", {description = "Enable support for WMME", default = true, type = "boolean"})
  11. add_configs("wasapi", {description = "Enable support for WASAPI", default = true, type = "boolean"})
  12. add_configs("wdmks", {description = "Enable support for WDMKS", default = true, type = "boolean"})
  13. add_configs("wdmks_devcie_info", {description = "Use WDM/KS API for device info", default = true, type = "boolean"})
  14. elseif is_plat("linux") then
  15. add_configs("alsa_dynamic", {description = "Enable dynamically loading libasound with dlopen using PaAlsa_SetLibraryPathName", default = false, type = "boolean"})
  16. end
  17. if is_plat("windows", "mingw") then
  18. add_syslinks("user32", "winmm", "advapi32", "ole32", "setupapi")
  19. elseif is_plat("macosx") then
  20. add_frameworks("CoreFoundation", "CoreAudio", "AudioToolbox", "AudioUnit", "CoreServices")
  21. elseif is_plat("linux", "bsd") then
  22. add_syslinks("pthread")
  23. end
  24. add_deps("cmake")
  25. on_install("windows", "linux", "macosx", "bsd", "mingw", "msys", "android", "wasm", "cross", function (package)
  26. local configs = {"-DPA_BUILD_TESTS=OFF", "-DPA_BUILD_EXAMPLES=OFF"}
  27. if package:is_debug() then
  28. table.insert(configs, "-DCMAKE_BUILD_TYPE=Debug")
  29. table.insert(configs, "-DPA_ENABLE_DEBUG_OUTPUT=ON")
  30. else
  31. table.insert(configs, "-DCMAKE_BUILD_TYPE=Release")
  32. table.insert(configs, "-DPA_ENABLE_DEBUG_OUTPUT=OFF")
  33. end
  34. table.insert(configs, "-DPA_BUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  35. table.insert(configs, "-DPA_USE_SKELETON=" .. (package:config("skeleton") and "ON" or "OFF"))
  36. table.insert(configs, "-DPA_USE_ASIO=" .. (package:config("asio") and "ON" or "OFF"))
  37. if package:is_plat("windows") then
  38. table.insert(configs, "-DPA_DLL_LINK_WITH_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
  39. table.insert(configs, "-DPA_USE_DS=" .. (package:config("direct_sound") and "ON" or "OFF"))
  40. table.insert(configs, "-DPA_USE_WMME=" .. (package:config("wmme") and "ON" or "OFF"))
  41. table.insert(configs, "-DPA_USE_WASAPI=" .. (package:config("wasapi") and "ON" or "OFF"))
  42. table.insert(configs, "-DPA_USE_WDMKS=" .. (package:config("wdmks") and "ON" or "OFF"))
  43. table.insert(configs, "-DPA_USE_WDMKS_DEVICE_INFO=" .. (package:config("wdmks_devcie_info") and "ON" or "OFF"))
  44. elseif package:is_plat("linux") then
  45. table.insert(configs, "-DPA_ALSA_DYNAMIC=" .. (package:config("alsa_dynamic") and "ON" or "OFF"))
  46. end
  47. import("package.tools.cmake").install(package, configs)
  48. end)
  49. on_test(function (package)
  50. assert(package:has_cfuncs("Pa_Initialize", {includes = "portaudio.h"}))
  51. end)