xmake.lua 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. package("igraph")
  2. set_homepage("https://igraph.org")
  3. set_description("Library for the analysis of networks")
  4. set_license("GPL-2.0")
  5. add_urls("https://github.com/igraph/igraph/releases/download/$(version)/igraph-$(version).tar.gz",
  6. "https://github.com/igraph/igraph.git")
  7. add_versions("1.0.0", "91e23e080634393dec4dfb02c2ae53ac4e3837172bb9047d32e39380b16c0bb0")
  8. add_versions("0.10.16", "15a1540a8d270232c9aa99adeeffb7787bea96289d6bef6646ec9c91a9a93992")
  9. add_versions("0.10.15", "03ba01db0544c4e32e51ab66f2356a034394533f61b4e14d769b9bbf5ad5e52c")
  10. add_configs("glpk", {description = "Compile igraph with GLPK support", default = false, type = "boolean"})
  11. add_configs("graphml", {description = "Compile igraph with GraphML support", default = false, type = "boolean"})
  12. add_configs("openmp", {description = "Use OpenMP for parallelization", default = false, type = "boolean"})
  13. if is_plat("wasm") then
  14. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  15. end
  16. if is_plat("linux", "bsd") then
  17. add_syslinks("pthread")
  18. end
  19. add_deps("cmake")
  20. add_deps("plfit")
  21. on_check(function (package)
  22. if package:is_cross() then
  23. if not package:is_plat("windows", "macosx") then
  24. raise("package(igraph) unsupported cross-compilation now. To support it, see https://igraph.org/c/html/latest/igraph-Installation.html#igraph-Installation-cross-compiling")
  25. end
  26. end
  27. end)
  28. on_load(function (package)
  29. if package:gitref() then
  30. wprint("If build failed with flex/bison, please see https://github.com/igraph/igraph/issues/2713")
  31. package:add("deps", "flex", "bison", {kind = "binary"})
  32. end
  33. -- TODO: unbundle deps gmp, arpack, blas, lapack
  34. -- https://igraph.org/c/html/latest/igraph-Installation.html#igraph-Installation-prerequisites
  35. if package:is_plat("linux", "macosx") then
  36. package:add("deps", "gmp")
  37. end
  38. if package:config("glpk") then
  39. package:add("deps", "glpk")
  40. end
  41. if package:config("graphml") then
  42. package:add("deps", "libxml2")
  43. end
  44. if package:config("openmp") then
  45. package:add("deps", "openmp")
  46. end
  47. if not package:config("shared") then
  48. package:add("defines", "IGRAPH_STATIC")
  49. end
  50. end)
  51. on_install("!cross and !bsd", function (package)
  52. -- Disable test/doc/cpack
  53. io.replace("CMakeLists.txt", "CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME", "0", {plain = true})
  54. if package:config("graphml") then
  55. io.replace("etc/cmake/dependencies.cmake", "find_package(LibXml2 ${LIBXML2_VERSION_MIN} QUIET)", "find_package(LibXml2 CONFIG REQUIRED)", {plain = true})
  56. end
  57. if package:gitref() then
  58. io.writefile("IGRAPH_VERSION", package:version_str())
  59. end
  60. -- https://igraph.org/c/html/latest/igraph-Installation.html
  61. local configs = {
  62. "-DUSE_CCACHE=OFF",
  63. "-DIGRAPH_WARNINGS_AS_ERRORS=OFF",
  64. -- "-DIGRAPH_USE_INTERNAL_GMP=OFF",
  65. -- "-DIGRAPH_USE_INTERNAL_ARPACK=OFF",
  66. -- "-DIGRAPH_USE_INTERNAL_BLAS=OFF",
  67. -- "-DIGRAPH_USE_INTERNAL_LAPACK=OFF",
  68. "-DIGRAPH_USE_INTERNAL_GLPK=OFF",
  69. "-DIGRAPH_USE_INTERNAL_PLFIT=OFF",
  70. }
  71. if package:is_plat("linux", "macosx") then
  72. table.insert(configs, "-DIGRAPH_USE_INTERNAL_GMP=OFF")
  73. end
  74. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  75. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  76. table.insert(configs, "-DIGRAPH_ENABLE_LTO=" .. (package:config("lto") and "ON" or "OFF"))
  77. table.insert(configs, "-DIGRAPH_GLPK_SUPPORT=" .. (package:config("glpk") and "ON" or "OFF"))
  78. table.insert(configs, "-DIGRAPH_OPENMP_SUPPORT=" .. (package:config("openmp") and "ON" or "OFF"))
  79. -- AUTO -> find_package, ON -> find_dependency (unavailable)
  80. table.insert(configs, "-DIGRAPH_GRAPHML_SUPPORT=" .. (package:config("graphml") and "AUTO" or "OFF"))
  81. if package:is_cross() then
  82. -- from https://github.com/microsoft/vcpkg/tree/0857a4b08c14030bbe41e80accb2b1fddb047a74/ports/igraph
  83. local header
  84. if package:is_plat("macosx") then
  85. header = "arith_osx.h"
  86. elseif package:is_plat("windows") then
  87. if package:is_arch64() then
  88. header = "arith_win64.h"
  89. else
  90. header = "arith_win32.h"
  91. end
  92. end
  93. if header then
  94. local header_path = path.unix(path.join(os.scriptdir(), header))
  95. table.insert(configs, "-DF2C_EXTERNAL_ARITH_HEADER=" .. header_path)
  96. end
  97. end
  98. local opt = {}
  99. if package:config("glpk") then
  100. opt.packagedeps = "zlib"
  101. end
  102. import("package.tools.cmake").install(package, configs, opt)
  103. end)
  104. on_test(function (package)
  105. assert(package:has_cfuncs("igraph_rng_seed", {includes = "igraph/igraph.h"}))
  106. end)