xmake.lua 5.1 KB

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