xmake.lua 1.3 KB

12345678910111213141516171819202122232425262728
  1. package("nlopt")
  2. set_homepage("https://github.com/stevengj/nlopt/")
  3. set_description("NLopt is a library for nonlinear local and global optimization, for functions with and without gradient information.")
  4. set_license("LGPL-2.1")
  5. add_urls("https://github.com/stevengj/nlopt/archive/$(version).tar.gz",
  6. "https://github.com/stevengj/nlopt.git")
  7. add_versions("v2.7.0", "b881cc2a5face5139f1c5a30caf26b7d3cb43d69d5e423c9d78392f99844499f")
  8. add_versions("v2.7.1", "db88232fa5cef0ff6e39943fc63ab6074208831dc0031cf1545f6ecd31ae2a1a")
  9. add_deps("cmake")
  10. on_load("windows", function (package)
  11. if package:config("shared") then
  12. package:add("defines", "NLOPT_DLL")
  13. end
  14. end)
  15. on_install("linux", "windows", "macosx", function (package)
  16. local configs = {"-DNLOPT_PYTHON=OFF", "-DNLOPT_OCTAVE=OFF", "-DNLOPT_MATLAB=OFF", "-DNLOPT_GUILE=OFF", "-DNLOPT_TESTS=OFF"}
  17. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  18. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  19. import("package.tools.cmake").install(package, configs)
  20. end)
  21. on_test(function (package)
  22. assert(package:has_cfuncs("nlopt_create", {includes = "nlopt.h"}))
  23. end)