xmake.lua 3.0 KB

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