xmake.lua 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package("nlopt")
  2. set_homepage("https://github.com/stevengj/nlopt")
  3. set_description("library for nonlinear optimization, wrapping many algorithms for global and local, constrained or unconstrained, optimization")
  4. set_license("LGPL-2.1")
  5. add_urls("https://github.com/stevengj/nlopt/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/stevengj/nlopt.git")
  7. add_versions("v2.9.1", "1e6c33f8cbdc4138d525f3326c231f14ed50d99345561e85285638c49b64ee93")
  8. add_versions("v2.8.0", "e02a4956a69d323775d79fdaec7ba7a23ed912c7d45e439bc933d991ea3193fd")
  9. add_versions("v2.7.0", "b881cc2a5face5139f1c5a30caf26b7d3cb43d69d5e423c9d78392f99844499f")
  10. add_versions("v2.7.1", "db88232fa5cef0ff6e39943fc63ab6074208831dc0031cf1545f6ecd31ae2a1a")
  11. add_configs("octave", {description = "build octave bindings", default = false, type = "boolean", readonly = true})
  12. add_configs("matlab", {description = "build matlab bindings", default = false, type = "boolean", readonly = true})
  13. add_configs("guile", {description = "build guile bindings", default = false, type = "boolean", readonly = true})
  14. add_deps("cmake")
  15. on_load("windows", function (package)
  16. if package:config("shared") then
  17. package:add("defines", "NLOPT_DLL")
  18. end
  19. end)
  20. on_install(function (package)
  21. local configs = {
  22. "-DNLOPT_TESTS=OFF",
  23. "-DNLOPT_PYTHON=OFF",
  24. "-DNLOPT_SWIG=OFF",
  25. }
  26. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  27. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  28. table.insert(configs, "-DNLOPT_OCTAVE=" .. (package:config("octave") and "ON" or "OFF"))
  29. table.insert(configs, "-DNLOPT_MATLAB=" .. (package:config("matlab") and "ON" or "OFF"))
  30. table.insert(configs, "-DNLOPT_GUILE=" .. (package:config("guile") and "ON" or "OFF"))
  31. import("package.tools.cmake").install(package, configs)
  32. end)
  33. on_test(function (package)
  34. assert(package:has_cfuncs("nlopt_create", {includes = "nlopt.h"}))
  35. end)