2
0

xmake.lua 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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.1.0", "5c3a1bdfee12f5c11fd194361040fe4760f57e334523ac125ec22b2cb03f27bb")
  8. local configdeps = {jpeg = "libjpeg-turbo",
  9. tiff = "libtiff",
  10. zlib = "zlib",
  11. png = "libpng",
  12. blas = "openblas",
  13. fftw = "fftw",
  14. opencv = "opencv"}
  15. for config, dep in pairs(configdeps) do
  16. add_configs(config, {description = "Enable " .. config .. " support.", default = (config == "zlib"), type = "boolean"})
  17. end
  18. if is_plat("windows") then
  19. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  20. end
  21. add_deps("cmake")
  22. add_deps("nodesoup")
  23. if is_plat("windows") then
  24. add_syslinks("user32", "shell32", "gdi32")
  25. end
  26. on_load("windows", "macosx", "linux", function (package)
  27. for config, dep in pairs(configdeps) do
  28. if package:config(config) then
  29. package:add("deps", dep)
  30. end
  31. end
  32. end)
  33. on_install("windows", "macosx", "linux", function (package)
  34. if package:is_plat("windows") then
  35. local vs = import("core.tool.toolchain").load("msvc"):config("vs")
  36. if tonumber(vs) < 2019 then
  37. raise("Your compiler is too old to use this library.")
  38. end
  39. end
  40. local configs = {"-DBUILD_EXAMPLES=OFF", "-DBUILD_TESTS=OFF", "-DBUILD_INSTALLER=ON", "-DBUILD_PACKAGE=OFF", "-DWITH_SYSTEM_NODESOUP=ON"}
  41. for config, dep in pairs(configdeps) do
  42. if not package:config(config) then
  43. table.insert(configs, "-DCMAKE_DISABLE_FIND_PACKAGE_" .. config:upper() .. "=ON")
  44. end
  45. end
  46. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  47. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  48. import("package.tools.cmake").install(package, configs)
  49. end)
  50. on_test(function (package)
  51. assert(package:check_cxxsnippets({test = [[
  52. #include <cmath>
  53. #include <vector>
  54. void test() {
  55. using namespace matplot;
  56. std::vector<double> x = linspace(0, 2 * pi);
  57. std::vector<double> y = transform(x, [](auto x) { return sin(x); });
  58. plot(x, y, "-o");
  59. show();
  60. }
  61. ]]}, {configs = {languages = "c++17"}, includes = "matplot/matplot.h"}))
  62. end)