Browse Source

h3: add new package (#7745)

* h3: add new package

* Fix m lib link

* Make usage of m lib link common for every platform

* improve windows shared defines

---------

Co-authored-by: star9029 <[email protected]>
Saikari 1 tháng trước cách đây
mục cha
commit
e7745d1f67
2 tập tin đã thay đổi với 59 bổ sung0 xóa
  1. 14 0
      packages/h/h3/patches/v4.3.0/fix-m-lib.diff
  2. 45 0
      packages/h/h3/xmake.lua

+ 14 - 0
packages/h/h3/patches/v4.3.0/fix-m-lib.diff

@@ -0,0 +1,14 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index b59b470f..8e6b2e3c 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -361,6 +361,9 @@ function(add_h3_library name h3_alloc_prefix_override)
+     target_compile_features(${name} PUBLIC c_std_99)
+ 
+     find_library(M_LIB m)
++    if(NOT(M_LIB))
++        find_library(M_LIB m PATHS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES})
++    endif()
+     if(M_LIB)
+         target_link_libraries(${name} PUBLIC ${M_LIB})
+     endif()

+ 45 - 0
packages/h/h3/xmake.lua

@@ -0,0 +1,45 @@
+package("h3")
+    set_homepage("https://h3geo.org")
+    set_description("Hexagonal hierarchical geospatial indexing system")
+    set_license("Apache-2.0")
+
+    add_urls("https://github.com/uber/h3/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/uber/h3.git")
+
+    add_versions("v4.3.0", "a47cfa36e255e4bf16c63015aaff8e6fe2afc14ffaa3f6b281718158446c0e9b")
+
+    add_patches("v4.3.0", "patches/v4.3.0/fix-m-lib.diff", "4cacd501c8a63f5b336569b18855ddfc4f80bcc9d9ef441cd590a5c64242680f")
+
+    add_configs("filters", {description = "Build filter applications.", default = true, type = "boolean"})
+
+    add_deps("cmake")
+
+    if is_plat("linux", "bsd") then
+        add_syslinks("m")
+    end
+
+    on_install(function (package)
+        if package:is_plat("windows") and package:config("shared") then
+            package:add("defines", "BUILD_SHARED_LIBS")
+        end
+
+        local configs = {
+            "-DENABLE_COVERAGE=OFF",
+            "-DENABLE_DOCS=OFF",
+            "-DENABLE_FORMAT=OFF",
+            "-DENABLE_LINTING=OFF",
+            "-DBUILD_BENCHMARKS=OFF",
+            "-DBUILD_FUZZERS=OFF",
+            "-DBUILD_GENERATORS=OFF",
+            "-DBUILD_TESTING=OFF",
+            "-DWARNINGS_AS_ERRORS=OFF"
+        }
+        table.insert(configs, "-DBUILD_FILTERS=" .. (package:config("filters") and "ON" or "OFF"))
+        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"))
+        import("package.tools.cmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("radsToDegs", {includes = "h3/h3api.h"}))
+    end)