xmake.lua 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package("symengine")
  2. set_homepage("https://symengine.org")
  3. set_description("SymEngine is a fast symbolic manipulation library, written in C++")
  4. set_license("MIT")
  5. add_urls("https://github.com/symengine/symengine/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/symengine/symengine.git")
  7. add_versions("v0.12.0", "1b5c3b0bc6a9f187635f93585649f24a18e9c7f2167cebcd885edeaaf211d956")
  8. add_versions("v0.11.2", "f6972acd6a65354f6414e69460d2e175729470632bdac05919bc2f7f32e48cbd")
  9. add_configs("integer_class", {description = "Integer class for symengine. Either gmp, gmpxx, flint or piranha", default = "boost", type = "string", values = {"boost", "gmp"}})
  10. add_configs("teuchos", {description = "Build with teuchos", default = false, type = "boolean"})
  11. if is_plat("linux") then
  12. add_syslinks("m")
  13. end
  14. add_deps("cmake")
  15. on_load(function (package)
  16. -- Unsupported gmp
  17. if package:is_plat("windows") then
  18. package:config_set("integer_class", "boost")
  19. end
  20. package:add("deps", package:config("integer_class"))
  21. end)
  22. on_install("windows", "linux", "macosx", "bsd", "mingw", "cross", function (package)
  23. local configs = {"-DBUILD_TESTS=OFF", "-DBUILD_BENCHMARKS=OFF"}
  24. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  25. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  26. table.insert(configs, "-DWITH_SYMENGINE_TEUCHOS=" .. (package:config("teuchos") and "ON" or "OFF"))
  27. if package:config("integer_class") == "boost" then
  28. table.insert(configs, "-DINTEGER_CLASS=boostmp")
  29. else
  30. table.insert(configs, "-DINTEGER_CLASS=gmp")
  31. end
  32. if package:is_plat("windows") then
  33. table.insert(configs, "-DMSVC_USE_MT=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
  34. end
  35. import("package.tools.cmake").install(package, configs)
  36. if os.isfile(package:installdir("lib/libteuchos.a")) then
  37. package:add("links", "symengine", "teuchos")
  38. end
  39. end)
  40. on_test(function (package)
  41. assert(package:check_cxxsnippets({test = [[
  42. #include <symengine/expression.h>
  43. using SymEngine::Expression;
  44. void test() {
  45. Expression x("x");
  46. auto ex = pow(x+sqrt(Expression(2)), 6);
  47. }
  48. ]]}, {configs = {languages = "c++14"}}))
  49. assert(package:has_cfuncs("basic_new_stack", {includes = "symengine/cwrapper.h"}))
  50. end)