xmake.lua 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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", "mingw", function (package)
  17. io.replace("libusb/CMakeLists.txt",
  18. "pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0>=1.0.9)",
  19. "pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb)", {plain = true})
  20. local configs = {
  21. "-DHIDAPI_WITH_TESTS=OFF",
  22. "-DHIDAPI_BUILD_PP_DATA_DUMP=OFF",
  23. "-DHIDAPI_BUILD_HIDTEST=OFF",
  24. }
  25. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  26. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  27. table.insert(configs, "-DHIDAPI_ENABLE_ASAN=" .. (package:config("asan") and "ON" or "OFF"))
  28. import("package.tools.cmake").install(package, configs)
  29. end)
  30. on_test(function (package)
  31. assert(package:has_cfuncs("hid_init", {includes = "hidapi/hidapi.h"}))
  32. end)