2
0

xmake.lua 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package("matplotplusplus")
  2. set_homepage("https://alandefreitas.github.io/matplotplusplus/")
  3. set_description("A C++ Graphics Library for Data Visualization")
  4. set_license("MIT")
  5. add_urls("https://github.com/alandefreitas/matplotplusplus/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/alandefreitas/matplotplusplus.git")
  7. add_versions("v1.2.2", "c7434b4fea0d0cc3508fd7104fafbb2fa7c824b1d2ccc51c52eaee26fc55a9a0")
  8. add_versions("v1.2.1", "9dd7cc92b2425148f50329f5a3bf95f9774ac807657838972d35334b5ff7cb87")
  9. add_versions("v1.2.0", "42e24edf717741fcc721242aaa1fdb44e510fbdce4032cdb101c2258761b2554")
  10. add_versions("v1.1.0", "5c3a1bdfee12f5c11fd194361040fe4760f57e334523ac125ec22b2cb03f27bb")
  11. local configdeps = {jpeg = "libjpeg-turbo",
  12. tiff = "libtiff",
  13. zlib = "zlib",
  14. png = "libpng",
  15. blas = "openblas",
  16. fftw = "fftw",
  17. opencv = "opencv"}
  18. for config, dep in pairs(configdeps) do
  19. add_configs(config, {description = "Enable " .. config .. " support.", default = (config == "zlib"), type = "boolean"})
  20. end
  21. if is_plat("windows") then
  22. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  23. end
  24. add_deps("cmake")
  25. add_deps("nodesoup", "cimg")
  26. if is_plat("windows") then
  27. add_syslinks("user32", "shell32", "gdi32")
  28. end
  29. if on_check then
  30. on_check("linux", function (package)
  31. if package:version() and package:version():eq("1.2.2") then
  32. if package:is_debug() then
  33. raise("package(matplotplusplus 1.2.2) unsupported debug build type")
  34. end
  35. end
  36. end)
  37. end
  38. on_load(function (package)
  39. for config, dep in pairs(configdeps) do
  40. if package:config(config) then
  41. package:add("deps", dep)
  42. end
  43. end
  44. end)
  45. on_install("windows", "macosx", "linux", function (package)
  46. if package:is_plat("windows") then
  47. local vs = import("core.tool.toolchain").load("msvc"):config("vs")
  48. if tonumber(vs) < 2019 then
  49. raise("Your compiler is too old to use this library.")
  50. end
  51. end
  52. local configs = {
  53. "-DBUILD_EXAMPLES=OFF",
  54. "-DMATPLOTPP_BUILD_EXAMPLES=OFF",
  55. "-DBUILD_TESTS=OFF",
  56. "-DBUILD_INSTALLER=ON",
  57. "-DBUILD_PACKAGE=OFF",
  58. "-DWITH_SYSTEM_NODESOUP=ON",
  59. "-DMATPLOTPP_WITH_SYSTEM_NODESOUP=ON",
  60. "-DMATPLOTPP_WITH_SYSTEM_CIMG=ON",
  61. }
  62. for config, dep in pairs(configdeps) do
  63. if not package:config(config) then
  64. table.insert(configs, "-DCMAKE_DISABLE_FIND_PACKAGE_" .. config:upper() .. "=ON")
  65. end
  66. end
  67. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  68. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  69. import("package.tools.cmake").install(package, configs)
  70. end)
  71. on_test(function (package)
  72. assert(package:check_cxxsnippets({test = [[
  73. #include <cmath>
  74. #include <vector>
  75. void test() {
  76. using namespace matplot;
  77. std::vector<double> x = linspace(0, 2 * pi);
  78. std::vector<double> y = transform(x, [](auto x) { return sin(x); });
  79. plot(x, y, "-o");
  80. show();
  81. }
  82. ]]}, {configs = {languages = "c++17"}, includes = "matplot/matplot.h"}))
  83. end)