xmake.lua 3.3 KB

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