xmake.lua 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package("libfreenect2")
  2. set_homepage("https://github.com/OpenKinect/libfreenect2")
  3. set_description("Open source drivers for the Kinect for Windows v2 device")
  4. set_license("GPL-2.0")
  5. add_urls("https://github.com/OpenKinect/libfreenect2.git")
  6. add_versions("v0.2.1", "fd64c5d9b214df6f6a55b4419357e51083f15d93")
  7. add_versions("v0.2.0", "v0.2.0")
  8. add_patches("v0.2.0", path.join(os.scriptdir(), "patches", "0.2.0", "frame_listener_impl.cpp.patch"), "47687b34fd0ca275d3e1c2ce87064ffaacd13f2f8d3a310224d3b9fef2cd54a3")
  9. add_configs("cuda", { description = "Enable CUDA support.", default = false, type = "boolean"})
  10. add_configs("opengl", { description = "Enable OpenGL support.", default = true, type = "boolean"})
  11. add_configs("opencl", { description = "Enable OpenCL support.", default = true, type = "boolean"})
  12. add_deps("cmake", "libjpeg-turbo", "libusb")
  13. if is_plat("linux") then
  14. add_syslinks("pthread")
  15. elseif is_plat("macosx") then
  16. add_frameworks("CoreMedia", "CoreFoundation", "CoreVideo", "Foundation", "IOKit", "ImageIO", "VideoToolbox")
  17. end
  18. on_load(function (package)
  19. if package:config("opengl") then
  20. if package:is_plat("macosx") then
  21. package:add("deps", "glfw")
  22. package:add("frameworks", "OpenGL")
  23. end
  24. end
  25. if package:config("opencl") then
  26. if package:is_plat("macosx") then
  27. package:add("frameworks", "OpenCL")
  28. end
  29. end
  30. end)
  31. on_install("windows", "linux", "macosx", function (package)
  32. io.replace("CMakeLists.txt", "FIND_PACKAGE(LibUSB REQUIRED)", "", {plain = true})
  33. local configs = {}
  34. table.insert(configs, "-DBUILD_EXAMPLES=OFF")
  35. table.insert(configs, "-DENABLE_CXX11=ON")
  36. table.insert(configs, "-DENABLE_CUDA=" .. (package:config("cuda") and "ON" or "OFF"))
  37. table.insert(configs, "-DENABLE_OPENGL=" .. (package:config("opengl") and "ON" or "OFF"))
  38. table.insert(configs, "-DENABLE_OPENCL=" .. (package:config("opencl") and "ON" or "OFF"))
  39. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  40. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  41. if package:config("pic") ~= false then
  42. table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
  43. end
  44. local libjpegturbo = package:dep("libjpeg-turbo"):fetch()
  45. if libjpegturbo then
  46. table.insert(configs, "-DTurboJPEG_INCLUDE_DIRS=" .. table.concat(libjpegturbo.includedirs or libjpegturbo.sysincludedirs, ";"))
  47. table.insert(configs, "-DTurboJPEG_LIBRARIES=" .. table.concat(libjpegturbo.libfiles, ";"))
  48. end
  49. local shflags
  50. if package:is_plat("macosx") then
  51. shflags = "-framework IOKit"
  52. end
  53. import("package.tools.cmake").install(package, configs, {packagedeps = "libusb", shflags = shflags})
  54. end)
  55. on_test(function (package)
  56. assert(package:check_cxxsnippets({test = [[
  57. void test() {
  58. libfreenect2::Freenect2 fn2;
  59. fn2.enumerateDevices();
  60. }
  61. ]]}, {configs = {languages = "c++11"}, includes = "libfreenect2/libfreenect2.hpp"}))
  62. end)