fftw: support more platform (#5751)

* fftw: support more platform

* fix cross-compilation

* Update xmake.lua

* use cmake on mac
pull/2965/merge
star9029 2 weeks ago committed by GitHub
parent 9d19f5de1f
commit 5abec9c6a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 56
      packages/f/fftw/xmake.lua

@ -1,10 +1,10 @@
package("fftw")
set_homepage("http://fftw.org/")
set_description("A C subroutine library for computing the discrete Fourier transform (DFT) in one or more dimensions.")
set_license("GPL-2.0")
add_urls("http://fftw.org/fftw-$(version).tar.gz")
add_versions("3.3.8", "6113262f6e92c5bd474f2875fa1b01054c4ad5040f6b0da7c03c98821d9ae303")
add_versions("3.3.9", "bf2c7ce40b04ae811af714deb512510cc2c17b9ab9d6ddcf49fe4487eea7af3d")
add_versions("3.3.10", "56c932549852cddcfafdab3820b0200c7742675be92179e59e6215b340e26467")
@ -14,18 +14,33 @@ package("fftw")
add_configs("enable_mpi", {description = "Enable MPI support.", default = false, type = "boolean"})
add_configs("simd", {description = "SIMD instruction sets used.", default = "avx2", type = "string", values = {"none", "sse", "sse2", "avx", "avx2", "avx512", "avx-128-fma", "kcvi", "altivec", "vsx", "neon", "generic-simd128", "generic-simd256"}})
if is_plat("windows") then
if is_plat("linux", "bsd") then
add_syslinks("pthread")
end
if not is_plat("linux") then
add_deps("cmake")
end
on_install("windows", function (package)
local configs = {"-DBUILD_TESTS=OFF"}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
if package:config("shared") then
on_load(function (package)
if package:config("thread") == "openmp" then
package:add("deps", "openmp")
end
if package:is_plat("windows") and package:config("shared") then
package:add("defines", "FFTW_DLL")
table.insert(configs, "-DWITH_COMBINED_THREADS=ON")
end
if package:is_arch("arm.*") then
package:config_set("simd", "none")
end
end)
on_install(function (package)
local configs = {"-DBUILD_TESTS=OFF", "-DCMAKE_POLICY_DEFAULT_CMP0057=NEW"}
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"))
table.insert(configs, "-DWITH_COMBINED_THREADS=" .. (package:config("shared") and "ON" or "OFF"))
if package:config("precision") == "float" then
table.insert(configs, "-DENABLE_FLOAT=ON")
elseif package:config("precision") == "quad" then
@ -38,15 +53,26 @@ package("fftw")
elseif package:config("thread") == "openmp" then
table.insert(configs, "-DENABLE_OPENMP=ON")
end
local simds = import("core.base.hashset").of("sse", "sse2", "avx", "avx2")
local simd = package:config("simd")
if simd ~= "none" and simds:has(simd) then
table.insert(configs, "-DENABLE_" .. string.upper(simd) .. "=ON")
end
import("package.tools.cmake").install(package, configs)
local opt = {}
if package:is_plat("mingw") then
opt.cxflags = "-DWITH_OUR_MALLOC"
end
import("package.tools.cmake").install(package, configs, opt)
if package:is_plat("windows") and package:is_debug() then
local dir = package:installdir(package:config("shared") and "bin" or "lib")
os.trycp(path.join(package:buildir(), "fftw3.pdb"), dir)
end
end)
on_install("linux", "macosx", function (package)
on_install("linux", function (package)
local configs = {}
if package:config("shared") then
table.insert(configs, "--enable-shared")
@ -80,5 +106,13 @@ package("fftw")
end)
on_test(function (package)
assert(package:has_cfuncs("fftw_execute", {includes = "fftw3.h"}))
local precision_map = {
float = "f",
long = "l",
quad = "q",
}
local name = precision_map[package:config("precision")] or ""
local fn = "fftw" .. name .. "_execute"
assert(package:has_cfuncs(fn, {includes = "fftw3.h"}))
end)

Loading…
Cancel
Save