浏览代码

libfacedetection: add package (#2773)

* libfacedetection: add package

* fix arm

* fix arm

* improve configs

* disable plat
star9029 1 年之前
父节点
当前提交
5c4c8fe56b
共有 1 个文件被更改,包括 37 次插入0 次删除
  1. 37 0
      packages/l/libfacedetection/xmake.lua

+ 37 - 0
packages/l/libfacedetection/xmake.lua

@@ -0,0 +1,37 @@
+package("libfacedetection")
+    set_homepage("https://github.com/ShiqiYu/libfacedetection")
+    set_description("An open source library for face detection in images. The face detection speed can reach 1000FPS. ")
+    set_license("BSD-3-Clause")
+
+    add_urls("https://github.com/ShiqiYu/libfacedetection/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/ShiqiYu/libfacedetection.git")
+
+    add_versions("v3.0", "66dc6b47b11db4bf4ef73e8b133327aa964dbd8b2ce9e0ef4d1e94ca08d40b6a")
+
+    add_configs("neon", {description = "Use neon", default = is_arch("arm.*"), type = "boolean"})
+    add_configs("avx512", {description = "Use avx512", default = false, type = "boolean"})
+    add_configs("avx2", {description = "Use avx2", default = not is_arch("arm.*"), type = "boolean"})
+    add_configs("openmp", {description = "Use openmp", default = false, type = "boolean"})
+
+    add_deps("cmake")
+
+    on_install("windows", "linux", "macosx", "bsd", "mingw", "msys", "android", "iphoneos", function (package)
+        local configs = {}
+        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"))
+        if package:is_arch("arm.*") then
+            table.insert(configs, "-DENABLE_NEON=" .. (package:config("neon") and "ON" or "OFF"))
+            table.insert(configs, "-DENABLE_AVX512=OFF")
+            table.insert(configs, "-DENABLE_AVX2=OFF")
+        else
+            table.insert(configs, "-DENABLE_NEON=OFF")
+            table.insert(configs, "-DENABLE_AVX512=" .. (package:config("avx512") and "ON" or "OFF"))
+            table.insert(configs, "-DENABLE_AVX2=" .. (package:config("avx2") and "ON" or "OFF"))
+        end
+        table.insert(configs, "-DUSE_OPENMP=" .. (package:config("openmp") and "ON" or "OFF"))
+        import("package.tools.cmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:has_cxxfuncs("facedetect_cnn", {includes = "facedetection/facedetectcnn.h", configs = {languages = "c++11"}}))
+    end)