xmake.lua 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package("pagmo")
  2. set_homepage("https://esa.github.io/pagmo2/index.html")
  3. set_description("pagmo is a C++ scientific library for massively parallel optimization.")
  4. set_license("LGPL-3.0")
  5. add_urls("https://github.com/esa/pagmo2/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/esa/pagmo2.git")
  7. add_versions("v2.18.0", "5ad40bf3aa91857a808d6b632d9e1020341a33f1a4115d7a2b78b78fd063ae31")
  8. local configdeps = {eigen = "EIGEN3", nlopt = "NLOPT", --[[ipopt = "IPOPT"]]}
  9. for config, dep in pairs(configdeps) do
  10. add_configs(config, {description = "Enable features against " .. config .. ".", default = true, type = "boolean"})
  11. end
  12. add_deps("cmake", "tbb <2021.0")
  13. add_deps("boost", {configs = {serialization = true}})
  14. on_load("windows", "macosx", "linux", function (package)
  15. for config, dep in pairs(configdeps) do
  16. if package:config(config) then
  17. package:add("deps", config)
  18. end
  19. end
  20. end)
  21. on_install("windows", "macosx", "linux", function (package)
  22. local configs = {"-DCMAKE_INSTALL_LIBDIR=lib", "-DPAGMO_BUILD_TESTS=OFF", "-DBoost_USE_STATIC_LIBS=ON"}
  23. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  24. table.insert(configs, "-DPAGMO_BUILD_STATIC_LIBRARY=" .. (package:config("shared") and "OFF" or "ON"))
  25. for config, dep in pairs(configdeps) do
  26. table.insert(configs, "-DPAGMO_WITH_" .. dep .. "=" .. (package:config(config) and "ON" or "OFF"))
  27. end
  28. if package:is_plat("windows") then
  29. table.insert(configs, "-DBoost_USE_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
  30. end
  31. import("package.tools.cmake").install(package, configs)
  32. end)
  33. on_test(function (package)
  34. assert(package:check_cxxsnippets({test = [[
  35. #include <pagmo/algorithm.hpp>
  36. #include <pagmo/algorithms/sade.hpp>
  37. #include <pagmo/archipelago.hpp>
  38. #include <pagmo/problem.hpp>
  39. #include <pagmo/problems/schwefel.hpp>
  40. void test() {
  41. using namespace pagmo;
  42. problem prob{schwefel(30)};
  43. algorithm algo{sade(100)};
  44. archipelago archi{16u, algo, prob, 20u};
  45. archi.evolve(10);
  46. archi.wait_check();
  47. }
  48. ]]}, {configs = {languages = "c++17"}}))
  49. end)