xmake.lua 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package("msmpi")
  2. set_homepage("https://docs.microsoft.com/en-us/message-passing-interface/microsoft-mpi")
  3. 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.")
  4. on_fetch("windows", function (package, opt)
  5. if opt.system then
  6. import("lib.detect.find_path")
  7. import("lib.detect.find_library")
  8. -- init search paths
  9. local paths = {
  10. "$(env MSMPI_ROOT)",
  11. "$(env MSMPI_INC)\\..",
  12. "$(env PROGRAMFILES%(x86%))\\Microsoft SDKs\\MPI"
  13. }
  14. -- find library
  15. local result = {links = {}, linkdirs = {}, includedirs = {}}
  16. local arch = package:is_arch("x64") and "x64" or "x86"
  17. for _, lib in ipairs({"msmpi", "msmpifec", "msmpifmc"}) do
  18. local linkinfo = find_library(lib, paths, {suffixes = path.join("Lib", arch)})
  19. if linkinfo then
  20. table.insert(result.linkdirs, linkinfo.linkdir)
  21. table.insert(result.links, lib)
  22. end
  23. end
  24. result.linkdirs = table.unique(result.linkdirs)
  25. -- find headers
  26. local path = find_path("mpi.h", paths, {suffixes = "Include"})
  27. if path then
  28. table.insert(result.includedirs, path)
  29. end
  30. if #result.includedirs > 0 and #result.linkdirs > 0 then
  31. return result
  32. end
  33. end
  34. end)