Sfoglia il codice sorgente

fix compilation error of rtmidi under linux when libasound is installed (#2661)

* fix compilation error under linux

* clean code style

* adjust again

* revert some change
Yiheng Wu 1 anno fa
parent
commit
ba6722056a
1 ha cambiato i file con 18 aggiunte e 0 eliminazioni
  1. 18 0
      packages/r/rtmidi/xmake.lua

+ 18 - 0
packages/r/rtmidi/xmake.lua

@@ -7,6 +7,13 @@ package("rtmidi")
 
     add_versions("6.0.0", "ef7bcda27fee6936b651c29ebe9544c74959d0b1583b716ce80a1c6fea7617f0")
 
+    if is_plat("linux") then
+        add_configs("alsa", {default = false, description = "Use alsa api on linux.", type = "boolean"})
+    end
+    if is_plat("linux", "macosx", "bsd") then
+        add_configs("jack", {default = false, description = "Use jack api on posix.", type = "boolean"})
+    end
+
     if is_plat("windows", "mingw") then
         add_syslinks("winmm")
     elseif is_plat("macosx") then
@@ -21,8 +28,19 @@ package("rtmidi")
 
     add_deps("cmake")
 
+    on_load("linux", "macosx", "bsd", function(package)
+        if package:config("alsa") then
+            package:add("syslinks", "asound")
+        end
+        if package:config("jack") then
+            package:add("syslinks", "jack")
+        end
+    end)
+
     on_install("windows", "linux", "macosx", "bsd", "mingw", "msys", "iphoneos", "cross", "wasm", function (package)
         local configs = {"-DRTMIDI_BUILD_TESTING=OFF"}
+        table.insert(configs, "-DRTMIDI_API_ALSA=" .. (package:config("alsa") and "ON" or "OFF"))
+        table.insert(configs, "-DRTMIDI_API_JACK=" .. (package:config("jack") and "ON" or "OFF"))
         table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
         table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
         import("package.tools.cmake").install(package, configs)