xmake.lua 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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", "mingw") 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. on_check("mingw", function (package)
  38. if package:version() and package:version():lt("1.2.0") then
  39. assert(false, "package(matplotplusplus <1.2.0) unsupported version on mingw")
  40. end
  41. end)
  42. end
  43. on_load(function (package)
  44. for config, dep in pairs(configdeps) do
  45. if package:config(config) then
  46. package:add("deps", dep)
  47. end
  48. end
  49. end)
  50. on_install("windows", "mingw", "macosx", "linux", function (package)
  51. if package:is_plat("windows") then
  52. local vs = import("core.tool.toolchain").load("msvc"):config("vs")
  53. if tonumber(vs) < 2019 then
  54. raise("Your compiler is too old to use this library.")
  55. end
  56. end
  57. local configs = {
  58. "-DBUILD_EXAMPLES=OFF",
  59. "-DMATPLOTPP_BUILD_EXAMPLES=OFF",
  60. "-DBUILD_TESTS=OFF",
  61. "-DBUILD_INSTALLER=ON",
  62. "-DBUILD_PACKAGE=OFF",
  63. "-DWITH_SYSTEM_NODESOUP=ON",
  64. "-DMATPLOTPP_WITH_SYSTEM_NODESOUP=ON",
  65. "-DMATPLOTPP_WITH_SYSTEM_CIMG=ON",
  66. }
  67. for config, dep in pairs(configdeps) do
  68. if not package:config(config) then
  69. table.insert(configs, "-DCMAKE_DISABLE_FIND_PACKAGE_" .. config:upper() .. "=ON")
  70. end
  71. end
  72. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  73. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  74. import("package.tools.cmake").install(package, configs)
  75. end)
  76. on_test(function (package)
  77. assert(package:check_cxxsnippets({test = [[
  78. #include <cmath>
  79. #include <vector>
  80. void test() {
  81. using namespace matplot;
  82. std::vector<double> x = linspace(0, 2 * pi);
  83. std::vector<double> y = transform(x, [](auto x) { return sin(x); });
  84. plot(x, y, "-o");
  85. show();
  86. }
  87. ]]}, {configs = {languages = "c++17"}, includes = "matplot/matplot.h"}))
  88. end)