xmake.lua 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package("glpk")
  2. set_homepage("https://www.gnu.org/software/glpk/")
  3. set_description("The GLPK (GNU Linear Programming Kit) package is intended for solving large-scale linear programming (LP), mixed integer programming (MIP), and other related problems.")
  4. set_license("GPL-3.0")
  5. set_urls("https://ftp.gnu.org/gnu/glpk/glpk-$(version).tar.gz")
  6. add_versions("5.0", "4a1013eebb50f728fc601bdd833b0b2870333c3b3e5a816eeba921d95bec6f15")
  7. if is_plat("linux") then
  8. add_extsources("apt::libglpk-dev")
  9. end
  10. on_install("macosx|x86_64", "linux", function (package)
  11. local configs = {}
  12. table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
  13. table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
  14. import("package.tools.autoconf").install(package, configs)
  15. end)
  16. on_install("windows", function (package)
  17. os.cd("w64") -- Makefiles are the same in w64 and w32 directory
  18. os.cp("config_VC", "config.h")
  19. local version = package:version()
  20. local basename = string.format("glpk_%d_%d", version:major(), version:minor())
  21. -- glp_netgen_prob is not defined, but should be disabled
  22. -- see: https://www.mail-archive.com/[email protected]/msg01020.html
  23. io.replace(basename .. ".def", "glp_netgen_prob\n", "", {plain = true})
  24. import("package.tools.nmake").build(package, {"/f", package:config("shared") and "makefile_VC_DLL" or "makefile_VC"})
  25. if package:config("shared") then
  26. os.cp(basename .. ".dll", package:installdir("bin"))
  27. os.cp(basename .. ".lib", package:installdir("lib"))
  28. else
  29. os.cp("glpk.lib", package:installdir("lib"))
  30. end
  31. os.cd("..")
  32. os.cp("src/glpk.h", package:installdir("include"))
  33. end)
  34. on_test(function (package)
  35. assert(package:check_cxxsnippets({test = [[
  36. #include <glpk.h>
  37. int main() {
  38. glp_prob* prob = glp_create_prob();
  39. if (prob) {
  40. glp_delete_prob(prob);
  41. }
  42. return 0;
  43. }
  44. ]]}))
  45. end)