xmake.lua 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package("cmake")
  2. set_kind("binary")
  3. set_homepage("https://cmake.org")
  4. set_description("A cross-platform family of tools designed to build, test and package software")
  5. if is_plat("mingw") and is_subhost("msys") then
  6. add_extsources("pacman::cmake")
  7. elseif is_plat("linux") then
  8. add_extsources("pacman::cmake", "apt::cmake")
  9. elseif is_plat("macosx") then
  10. add_extsources("brew::cmake")
  11. end
  12. if add_schemes then
  13. add_schemes("binary", "source")
  14. end
  15. on_source(function (package)
  16. import("schemes.binary")
  17. import("schemes.source")
  18. if package.current_scheme then
  19. binary.add_urls(package, "binary")
  20. source.add_urls(package, "source")
  21. else
  22. if binary.add_urls(package) then
  23. package:data_set("scheme", "binary")
  24. else
  25. source.add_urls(package)
  26. package:data_set("scheme", "source")
  27. end
  28. end
  29. end)
  30. on_load(function (package)
  31. -- xmake v3.x will enable this ninja policy by default
  32. import("core.project.project")
  33. if xmake.version():ge("2.9.0") and project.policy("package.cmake_generator.ninja") then
  34. -- We mark it as public, even if cmake is already installed,
  35. -- we need also to install ninja and export the ninja PATH. (above xmake 2.9.8)
  36. package:add("deps", "ninja", {public = true})
  37. end
  38. end)
  39. on_install("@macosx", "@linux", "@windows", "@msys", "@cygwin", "@bsd", function (package)
  40. import("schemes.binary")
  41. import("schemes.source")
  42. local scheme_name = package.current_scheme and package:current_scheme():name() or package:data("scheme")
  43. if scheme_name == "binary" then
  44. binary.install(package)
  45. else
  46. source.install(package)
  47. end
  48. end)
  49. on_test(function (package)
  50. os.vrun("cmake --version")
  51. end)