flann: enable some platform (#5227)

* flann: enable some platform

* fix mingw static build
pull/5238/head
star9029 2 months ago committed by GitHub
parent 4248c8dc54
commit 7721db2c3a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 19
      packages/f/flann/xmake.lua

@ -1,11 +1,11 @@
package("flann") package("flann")
set_homepage("https://github.com/flann-lib/flann/") set_homepage("https://github.com/flann-lib/flann/")
set_description("Fast Library for Approximate Nearest Neighbors") set_description("Fast Library for Approximate Nearest Neighbors")
set_license("BSD-3-Clause") set_license("BSD-3-Clause")
add_urls("https://github.com/flann-lib/flann/archive/refs/tags/$(version).tar.gz", add_urls("https://github.com/flann-lib/flann/archive/refs/tags/$(version).tar.gz",
"https://github.com/flann-lib/flann.git") "https://github.com/flann-lib/flann.git")
add_versions("1.9.1", "b23b5f4e71139faa3bcb39e6bbcc76967fbaf308c4ee9d4f5bfbeceaa76cc5d3") add_versions("1.9.1", "b23b5f4e71139faa3bcb39e6bbcc76967fbaf308c4ee9d4f5bfbeceaa76cc5d3")
add_versions("1.9.2", "e26829bb0017f317d9cc45ab83ddcb8b16d75ada1ae07157006c1e7d601c8824") add_versions("1.9.2", "e26829bb0017f317d9cc45ab83ddcb8b16d75ada1ae07157006c1e7d601c8824")
@ -14,13 +14,16 @@ package("flann")
add_configs("with_cuda", {description = "Enable cuda build.", default = false, type = "boolean"}) add_configs("with_cuda", {description = "Enable cuda build.", default = false, type = "boolean"})
add_deps("cmake", "lz4") add_deps("cmake", "lz4")
on_load("windows", "linux", "macosx", function (package)
if package:is_plat("windows") and not package:config("shared") then on_load(function (package)
if package:is_plat("windows", "mingw") and not package:config("shared") then
package:add("defines", "FLANN_STATIC") package:add("defines", "FLANN_STATIC")
end end
if package:config("with_cuda") then if package:config("with_cuda") then
package:add("deps", "cuda", {system = true}) package:add("deps", "cuda", {system = true})
package:add("defines", "FLANN_USE_CUDA")
end end
local suffix = package:config("shared") and "" or "_s" local suffix = package:config("shared") and "" or "_s"
local libs = package:config("with_cuda") and {"flann"} or {"flann", "flann_cuda"} local libs = package:config("with_cuda") and {"flann"} or {"flann", "flann_cuda"}
for _, lib in ipairs(libs) do for _, lib in ipairs(libs) do
@ -28,14 +31,14 @@ package("flann")
end end
end) end)
on_install("windows", "linux", "macosx", function (package) on_install(function (package)
os.cd("src/cpp") os.cd("src/cpp")
io.replace("flann/util/serialization.h", "flann/ext/lz4", "lz4", {plain = true}) io.replace("flann/util/serialization.h", "flann/ext/lz4", "lz4", {plain = true})
io.replace("flann/defines.h", "#ifdef WIN32", "#ifdef _WIN32", {plain = true}) io.replace("flann/defines.h", "#ifdef WIN32", "#ifdef _WIN32", {plain = true})
io.writefile("xmake.lua", format([[ io.writefile("xmake.lua", format([[
add_rules("mode.debug", "mode.release") add_rules("mode.debug", "mode.release")
add_requires("lz4") add_requires("lz4")
if is_plat("windows") then if is_plat("windows", "mingw") then
if is_kind("static") then if is_kind("static") then
add_defines("FLANN_STATIC") add_defines("FLANN_STATIC")
elseif is_kind("shared") then elseif is_kind("shared") then
@ -65,11 +68,7 @@ package("flann")
add_includedirs("flann") add_includedirs("flann")
add_packages("lz4") add_packages("lz4")
]], package:config("with_cuda") and "true" or "false")) ]], package:config("with_cuda") and "true" or "false"))
local configs = {kind = package:config("shared") and "shared" or "static"} import("package.tools.xmake").install(package)
if package:config("with_cuda") then
package:add("defines", "FLANN_USE_CUDA")
end
import("package.tools.xmake").install(package, configs)
end) end)
on_test(function (package) on_test(function (package)

Loading…
Cancel
Save