xmake.lua 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package("pybind11")
  2. set_kind("library", {headeronly = true})
  3. set_homepage("https://github.com/pybind/pybind11")
  4. set_description("Seamless operability between C++11 and Python.")
  5. set_license("BSD-3-Clause")
  6. add_urls("https://github.com/pybind/pybind11/archive/refs/tags/$(version).zip",
  7. "https://github.com/pybind/pybind11.git")
  8. add_versions("v3.0.1", "20fb420fe163d0657a262a8decb619b7c3101ea91db35f1a7227e67c426d4c7e")
  9. add_versions("v3.0.0", "dfe152af2f454a9d8cd771206c014aecb8c3977822b5756123f29fd488648334")
  10. add_versions("v2.13.6", "d0a116e91f64a4a2d8fb7590c34242df92258a61ec644b79127951e821b47be6")
  11. add_versions("v2.13.5", "0b4f2d6a0187171c6d41e20cbac2b0413a66e10e014932c14fae36e64f23c565")
  12. add_versions("v2.5.0", "1859f121837f6c41b0c6223d617b85a63f2f72132bae3135a2aa290582d61520")
  13. add_versions("v2.6.2", "0bdb5fd9616fcfa20918d043501883bf912502843d5afc5bc7329a8bceb157b3")
  14. add_versions("v2.7.1", "350ebf8f4c025687503a80350897c95d8271bf536d98261f0b8ed2c1a697070f")
  15. add_versions("v2.8.1", "90907e50b76c8e04f1b99e751958d18e72c4cffa750474b5395a93042035e4a3")
  16. add_versions("v2.9.1", "ef9e63be55b3b29b4447ead511a7a898fdf36847f21cec27a13df0db051ed96b")
  17. add_versions("v2.9.2", "d1646e6f70d8a3acb2ddd85ce1ed543b5dd579c68b8fb8e9638282af20edead8")
  18. add_versions("v2.10.0", "225df6e6dea7cea7c5754d4ed954e9ca7c43947b849b3795f87cb56437f1bd19")
  19. add_versions("v2.12.0", "411f77380c43798506b39ec594fc7f2b532a13c4db674fcf2b1ca344efaefb68")
  20. add_versions("v2.13.1", "a3c9ea1225cb731b257f2759a0c12164db8409c207ea5cf851d4b95679dda072")
  21. add_deps("cmake")
  22. if is_plat("windows", "mingw") then
  23. add_deps("python 3.x", {configs = {headeronly = false}})
  24. elseif is_plat("macosx") then
  25. add_deps("python 3.x", {configs = {headeronly = true}})
  26. else
  27. add_deps("python 3.x")
  28. end
  29. on_load("macosx", function (package)
  30. -- fix segmentation fault for macosx
  31. -- @see https://github.com/xmake-io/xmake/issues/2177#issuecomment-1209398292
  32. package:add("shflags", "-undefined dynamic_lookup", {force = true})
  33. end)
  34. on_install("windows|native", "macosx", "linux", function (package)
  35. import("detect.tools.find_python3")
  36. local configs = {"-DPYBIND11_TEST=OFF"}
  37. local python = find_python3()
  38. if python and path.is_absolute(python) then
  39. table.insert(configs, "-DPython_EXECUTABLE=" .. python)
  40. end
  41. import("package.tools.cmake").install(package, configs)
  42. end)
  43. on_test(function (package)
  44. assert(package:check_cxxsnippets({test = [[
  45. #include <pybind11/pybind11.h>
  46. int add(int i, int j) {
  47. return i + j;
  48. }
  49. PYBIND11_MODULE(example, m) {
  50. m.def("add", &add, "A function which adds two numbers");
  51. }
  52. ]]}, {configs = {languages = "c++11"}}))
  53. end)