xmake.lua 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package("libuvc")
  2. set_homepage("https://github.com/libuvc/libuvc")
  3. set_description("A cross-platform video device oynchronous I/O.")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/libuvc/libuvc.git")
  6. add_versions("2024.03.05", "047920bcdfb1dac42424c90de5cc77dfc9fba04d")
  7. if is_plat("macosx") then
  8. add_extsources("brew::libuvc")
  9. elseif is_plat("linux") then
  10. add_extsources("apt::libuvc-dev", "pacman::libuvc")
  11. elseif is_plat("mingw") and is_subhost("msys") then
  12. add_extsources("pacman::libuvc")
  13. end
  14. add_configs("jpeg", {description = "Enable jpeg support.", default = true, type = "boolean"})
  15. add_configs("winsock2", {description = "Use winsock2.h or winsock.h in windows.", default = true, type = "boolean"})
  16. add_deps("cmake", "pkgconf")
  17. add_deps("libusb")
  18. if is_plat("windows") then
  19. add_patches("2024.03.05", "patches/2024.03.05/windows.patch", "1a3356ad2a37ac68bd29ea61457de85210740643843f57e030b20fd70efc9597")
  20. add_deps("pthreads4w")
  21. else
  22. add_patches("2024.03.05", "patches/2024.03.05/linux.patch", "6a17c1eb271a6db1a2fd17aa2003159f60b85f02a3443ee5b600472f94786bda")
  23. end
  24. if is_plat("macosx") then
  25. add_frameworks("CoreFoundation", "IOKit", "Security")
  26. end
  27. on_load(function (package)
  28. if package:config("jpeg") then
  29. package:add("deps", "libjpeg")
  30. end
  31. end)
  32. on_install("windows|x64", "windows|x86", "linux", "macosx", function (package)
  33. if package:is_plat("windows") and not package:config("winsock2") then
  34. io.replace("include/libuvc/libuvc.h", "winsock2.h", "winsock.h", {plain = true})
  35. end
  36. local configs = {}
  37. table.insert(configs, "-DBUILD_EXAMPLE=OFF")
  38. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  39. table.insert(configs, "-DCMAKE_BUILD_TARGET=" .. (package:config("shared") and "Shared" or "Static"))
  40. import("package.tools.cmake").install(package, configs)
  41. end)
  42. on_test(function (package)
  43. assert(package:has_cfuncs("uvc_init", {includes = "libuvc/libuvc.h"}))
  44. end)