xmake.lua 2.5 KB

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