xmake.lua 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package("hidapi")
  2. set_homepage("https://libusb.info/hidapi/")
  3. set_description("A Simple cross-platform library for communicating with HID devices")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/libusb/hidapi/archive/refs/tags/hidapi-$(version).tar.gz",
  6. "https://github.com/libusb/hidapi.git")
  7. add_versions("0.14.0", "a5714234abe6e1f53647dd8cba7d69f65f71c558b7896ed218864ffcf405bcbd")
  8. add_deps("cmake")
  9. if is_plat("linux") then
  10. add_deps("libusb")
  11. elseif is_plat("macosx") then
  12. add_frameworks("IOKit", "CoreFoundation", "AppKit")
  13. elseif is_plat("bsd") then
  14. add_deps("pkg-config")
  15. end
  16. on_install("windows|x86", "windows|x64", "linux", "macosx", function (package)
  17. local configs = {
  18. "-DHIDAPI_WITH_TESTS=OFF",
  19. "-DHIDAPI_BUILD_PP_DATA_DUMP=OFF",
  20. "-DHIDAPI_BUILD_HIDTEST=OFF",
  21. }
  22. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  23. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  24. table.insert(configs, "-DHIDAPI_ENABLE_ASAN=" .. (package:config("asan") and "ON" or "OFF"))
  25. import("package.tools.cmake").install(package, configs)
  26. end)
  27. on_test(function (package)
  28. assert(package:has_cfuncs("hid_init", {includes = "hidapi/hidapi.h"}))
  29. end)