xmake.lua 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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/matplotplus.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. add_deps("cmake")
  19. add_deps("nodesoup")
  20. if is_plat("windows") then
  21. add_syslinks("user32", "shell32", "gdi32")
  22. end
  23. on_load("windows", "macosx", "linux", function (package)
  24. for config, dep in pairs(configdeps) do
  25. if package:config(config) then
  26. package:add("deps", dep)
  27. end
  28. end
  29. end)
  30. on_install("windows", "macosx", "linux", function (package)
  31. if is_plat("windows") then
  32. local vs = import("core.tool.toolchain").load("msvc"):config("vs")
  33. if tonumber(vs) < 2019 then
  34. raise("Your compiler is too old to use this library.")
  35. end
  36. end
  37. local configs = {"-DBUILD_EXAMPLES=OFF", "-DBUILD_TESTS=OFF", "-DBUILD_INSTALLER=ON", "-DBUILD_PACKAGE=OFF", "-DWITH_SYSTEM_NODESOUP=ON"}
  38. for config, dep in pairs(configdeps) do
  39. if not package:config(config) then
  40. table.insert(configs, "-DCMAKE_DISABLE_FIND_PACKAGE_" .. config:upper() .. "=ON")
  41. end
  42. end
  43. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  44. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  45. import("package.tools.cmake").install(package, configs)
  46. end)
  47. on_test(function (package)
  48. assert(package:check_cxxsnippets({test = [[
  49. #include <cmath>
  50. #include <vector>
  51. void test() {
  52. using namespace matplot;
  53. std::vector<double> x = linspace(0, 2 * pi);
  54. std::vector<double> y = transform(x, [](auto x) { return sin(x); });
  55. plot(x, y, "-o");
  56. show();
  57. }
  58. ]]}, {configs = {languages = "c++17"}, includes = "matplot/matplot.h"}))
  59. end)