Browse Source

add msmpi and hypre (#395)

* add msmpi

* add hypre

* improve msmpi
Hoildkv 4 years ago
parent
commit
145925720f
3 changed files with 65 additions and 1 deletions
  1. 22 0
      packages/h/hypre/xmake.lua
  2. 39 0
      packages/m/msmpi/xmake.lua
  3. 4 1
      packages/t/tbb/fetch.lua

+ 22 - 0
packages/h/hypre/xmake.lua

@@ -0,0 +1,22 @@
+package("hypre")
+
+    set_homepage("https://computing.llnl.gov/projects/hypre-scalable-linear-solvers-multigrid-methods")
+    set_description("Parallel solvers for sparse linear systems featuring multigrid methods.")
+    set_license("Apache-2.0")
+
+    add_urls("https://github.com/hypre-space/hypre/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/hypre-space/hypre.git")
+    add_versions("v2.20.0", "5be77b28ddf945c92cde4b52a272d16fb5e9a7dc05e714fc5765948cba802c01")
+
+    add_deps("cmake")
+    on_install("windows", "linux", "macosx", function (package)
+        os.cd("src")
+        local configs = {"-DHYPRE_WITH_MPI=OFF"}
+        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
+        table.insert(configs, "-DHYPRE_ENABLE_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
+        import("package.tools.cmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("HYPRE_Init", {includes = "HYPRE_utilities.h"}))
+    end)

+ 39 - 0
packages/m/msmpi/xmake.lua

@@ -0,0 +1,39 @@
+package("msmpi")
+
+    set_homepage("https://docs.microsoft.com/en-us/message-passing-interface/microsoft-mpi")
+    set_description("Microsoft MPI (MS-MPI) is a Microsoft implementation of the Message Passing Interface standard for developing and running parallel applications on the Windows platform.")
+
+    on_fetch("windows", function (package, opt)
+        if opt.system then
+            import("lib.detect.find_path")
+            import("lib.detect.find_library")
+
+            -- init search paths
+            local paths = {
+                "$(env MSMPI_ROOT)",
+                "$(env MSMPI_INC)\\..",
+                "$(env PROGRAMFILES%(x86%))\\Microsoft SDKs\\MPI"
+            }
+
+            -- find library
+            local result = {links = {}, linkdirs = {}, includedirs = {}}
+            local arch = package:is_arch("x64") and "x64" or "x86"
+            for _, lib in ipairs({"msmpi", "msmpifec", "msmpifmc"}) do
+                local linkinfo = find_library(lib, paths, {suffixes = path.join("Lib", arch)})
+                if linkinfo then
+                    table.insert(result.linkdirs, linkinfo.linkdir)
+                    table.insert(result.links, lib)
+                end
+            end
+            result.linkdirs = table.unique(result.linkdirs)
+
+            -- find headers
+            local path = find_path("mpi.h", paths, {suffixes = "Include"})
+            if path then
+                table.insert(result.includedirs, path)
+            end
+            if #result.includedirs > 0 and #result.linkdirs > 0 then
+                return result
+            end
+        end
+    end)

+ 4 - 1
packages/t/tbb/fetch.lua

@@ -18,7 +18,10 @@ function _find_package_on_windows(package, opt)
         end
     end
     result.linkdirs = table.unique(result.linkdirs)
-    table.insert(result.includedirs, find_path(path.join("tbb", "tbb.h"), paths, {suffixes = "include"}))
+    local path = find_path(path.join("tbb", "tbb.h"), paths, {suffixes = "include"})
+    if path then
+        table.insert(result.includedirs, path)
+    end
 
     if #result.includedirs > 0 and #result.linkdirs > 0 then
         local root = result.includedirs[1]